1 from configparser import ConfigParser
2 from datetime import datetime, timedelta
3 from logging import getLogger
4 from logging.config import fileConfig
5 from pathlib import Path
6 from shutil import rmtree
8 from .source.ephemeris import Ephemeris
9 from .source.meteofrance import MeteoFrance
11 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
17 def __init__(self, config_file = (Path.cwd() / 'config') / 'learn.cfg'):
18 self._config = ConfigParser()
19 self._config.read(config_file)
20 self._start = datetime.strptime(self._config['DATETIME']['start'],
22 self._end = datetime.strptime(self._config['DATETIME']['end'],
25 self._timestep = timedelta(hours =
26 self._config['DATETIME'].getfloat('hourStep'))
34 # Cleaning the data directory
35 logger.info("Cleaning and restoring data directory")
36 directory = Path.cwd() / 'data'
37 if directory.is_dir():
39 p = Path(Path.cwd() / 'data')
43 def add_features(self):
44 if self._config['FEATURES'].getboolean('meteofrance'):
45 meteofeature = MeteoFrance(config_file =
46 eval(self._config['FEATURE_CONFIG']['meteofrance']))
48 meteofeature.start = self._start
49 meteofeature.end = self._end
52 dated_features = meteofeature.dated_features
53 for date in dated_features:
54 self._X.setdefault(date,{}).update(dated_features[date])
56 if self._config['FEATURES'].getboolean('ephemeris'):
57 ephemerides = Ephemeris(config_file =
58 eval(self._config['FEATURE_CONFIG']['ephemeris']))
60 ephemerides.start = self._start
61 ephemerides.end = self._end
63 dated_features = ephemerides.dated_features
64 for date in dated_features:
65 self._X.setdefault(date,{}).update(dated_features[date])