1 from lib.source.ephemeris import Ephemeris
2 from lib.source.meteofrance import MeteoFrance
4 from datetime import datetime
5 from logging import getLogger
6 from logging.config import fileConfig
7 from pathlib import Path
8 from shutil import rmtree
10 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
15 def __init__(self, start = None, end = None, time_step = None):
16 logger.info("Predictops engine launched")
22 # Cleaning the data directory
23 logger.info("Cleaning and restoring data directory")
24 directory = Path.cwd() / 'data'
25 if directory.is_dir():
27 p = Path(Path.cwd() / 'data')
31 def add_feature(self, name, **kw):
33 if name == 'meteofrance':
34 meteofeature = MeteoFrance(**kw)
36 dated_features = meteofeature.dated_features
37 for date in dated_features:
38 self._X.setdefault(date,{}).update(dated_features[date])
39 elif name == 'ephemeris':
40 ephemerides = Ephemeris(**kw)
41 dated_features = ephemerides.dated_features
42 for date in dated_features:
43 self._X.setdefault(date,{}).update(dated_features[date])
55 start = datetime.strptime('01/01/2010 00:00:00', '%m/%d/%Y %H:%M:%S')
56 end = datetime.strptime('12/31/2010 23:00:00', '%m/%d/%Y %H:%M:%S')
59 engine.add_feature(name = 'meteofrance',
60 start = start, end = end,
61 latitude = 47.25, longitude = 6.0333, nb_stations = 3,
62 features = ['temperature', 'pressure'])
64 engine.add_feature(name = 'ephemeris',
65 start = start, end = end,
66 features = ['hour', 'dayInWeek', 'dayInMonth', 'dayInYear',
67 'weekInYear', 'month', 'year'])