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
10 from .target.target import Target
12 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
18 def __init__(self, config_file = (Path.cwd() / 'config') / 'learn.cfg'):
19 self._config = ConfigParser()
20 self._config.read(config_file)
21 self._start = datetime.strptime(self._config['DATETIME']['start'],
23 self._end = datetime.strptime(self._config['DATETIME']['end'],
26 self._timestep = timedelta(hours =
27 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])
69 self._target = Target(config_file = eval(self._config['TARGET']['config']),
70 start = self._start, end = self._end,
71 timestep = self._timestep)