]> AND Private Git Repository - predictops.git/blobdiff - predictops/source/ephemeris.py
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
README.md is completed
[predictops.git] / predictops / source / ephemeris.py
index 33c0f2d31f2ff26beb7dcced68cc08033c495ea1..e46b296ad09efd78afdff11163e43f3606ce67fc 100644 (file)
@@ -1,21 +1,48 @@
+from configparser import ConfigParser
+from csv import DictReader
 from datetime import datetime, timedelta
+from pathlib import Path
+
 import time
 import calendar
 
+CSV_FILE = Path.cwd() / 'config' / 'features' / 'ephemeris_features.csv'
+
 class Ephemeris:
 
-    def __init__(self, start = time.strptime('19960101000000', '%Y%m%d%H%M%S'),
-                 end = datetime.now(), features = []):
-        self._start = start
-        self._end = end
-        self._features = features
+    _start = None
+    _end   = None
+
+    def __init__(self, config_file):
+
+        self._config = ConfigParser()
+        self._config.read(config_file)
+
+        # Collecting ephemeris features
+        with open(CSV_FILE, "r") as f:
+            reader = DictReader(f, delimiter=',')
+            self._features = [row['name'] for row in reader
+                              if self._config['FEATURES'].getboolean(row['name'])]
 
         self._dated_features = {}
 
 
+    @property
+    def start(self):
+        return self._start
+
+    @start.setter
+    def start(self, x):
+        self._start = x
+
+
+    @property
+    def end(self):
+        return self._end
 
-    def update(self):
-        pass
+    @end.setter
+    def end(self, x):
+        self._end = x