]> AND Private Git Repository - predictops.git/commitdiff
Logo AND Algorithmique Numérique Distribuée

Private GIT Repository
refactoring, and working on ToArea target
authorChristophe Guyeux <christophe.guyeux@univ-fcomte.fr>
Wed, 12 Feb 2020 14:46:52 +0000 (15:46 +0100)
committerChristophe Guyeux <christophe.guyeux@univ-fcomte.fr>
Wed, 12 Feb 2020 14:46:52 +0000 (15:46 +0100)
12 files changed:
main.py
predictops/__init__.py [moved from lib/__init__.py with 100% similarity]
predictops/learn/__init__.py [moved from lib/learn/__init__.py with 100% similarity]
predictops/source/__init__.py [moved from lib/source/__init__.py with 100% similarity]
predictops/source/ephemeris.py [moved from lib/source/ephemeris.py with 100% similarity]
predictops/source/festivals.py [moved from lib/source/festivals.py with 100% similarity]
predictops/source/hydro.py [moved from lib/source/hydro.py with 100% similarity]
predictops/source/meteofrance.py [moved from lib/source/meteofrance.py with 97% similarity]
predictops/target/__init__.py [moved from lib/target/__init__.py with 100% similarity]
predictops/target/frombarrack.py [moved from lib/target/barracks.py with 100% similarity]
predictops/target/toarea.py [new file with mode: 0644]
requirements.txt

diff --git a/main.py b/main.py
index a6a8d742d6c4c21d1447e92221880bae1dae4632..b43c188627d52c218cb527d5dce3ee16dde1575d 100644 (file)
--- a/main.py
+++ b/main.py
@@ -1,5 +1,6 @@
-from lib.source.ephemeris import Ephemeris
-from lib.source.meteofrance import MeteoFrance
+from predictops.source.ephemeris import Ephemeris
+from predictops.source.meteofrance import MeteoFrance
+from predictops.target.toarea import ToArea
 
 from datetime import datetime
 from logging import getLogger
@@ -7,6 +8,8 @@ from logging.config import fileConfig
 from pathlib import Path
 from shutil import rmtree
 
+import geopandas as gpd
+
 fileConfig((Path.cwd() / 'config') / 'logging.cfg')
 logger = getLogger()
 
@@ -66,6 +69,11 @@ engine.add_feature(name = 'ephemeris',
                    features = ['hour', 'dayInWeek', 'dayInMonth', 'dayInYear',
                                'weekInYear', 'month', 'year'])
 
+print(engine.X[datetime.strptime('06/30/2010 21:00:00', '%m/%d/%Y %H:%M:%S')])
+
+depts = gpd.read_file( Path.cwd() / 'data' / 'targets' / 'departments' / "departements-20180101.shp")
+Doubs = depts.loc[depts['nom'] == 'Doubs'].iloc[0]
 
+ToArea(area=Doubs.geometry,
+       start = start, end = end)
 
-print(engine.X[datetime.strptime('06/30/2010 21:00:00', '%m/%d/%Y %H:%M:%S')])
\ No newline at end of file
similarity index 100%
rename from lib/__init__.py
rename to predictops/__init__.py
similarity index 97%
rename from lib/source/meteofrance.py
rename to predictops/source/meteofrance.py
index 88706ead406777ef0e119f0798cd1d169b6daf7f..2326e16c92e2f097a7e4853221e7006d5008becd 100644 (file)
@@ -4,7 +4,7 @@ from datetime import datetime
 from geopy.distance import vincenty
 from logging import getLogger
 from logging.config import fileConfig
-from os import listdir, remove, system
+from os import listdir, remove
 from os.path import isfile, basename
 from pathlib import Path
 from shutil import rmtree
@@ -48,7 +48,7 @@ class MeteoFrance:
         self._end = end
         self._features = features
 
-        self._data_directory = (Path.cwd() / 'data') / 'meteo_france'
+        self._data_directory = (Path.cwd() / 'data') / 'features' / 'meteo_france'
 
         self._dated_features = None
 
@@ -204,7 +204,7 @@ class MeteoFrance:
                                        'type': row['type']  # qualitative (2) or quantitative (1)
                                     }
                                 for row in reader if row['name'] in self._features}
-            dir_data = Path.cwd() / 'data' / 'meteo_france' / 'historical'
+            dir_data = Path.cwd() / 'data' / 'features' / 'meteo_france' / 'historical'
             self._dated_features = {}
             for csv_meteo in listdir(dir_data):
                 date = datetime.strptime(csv_meteo.split('.')[1], '%Y%m')
diff --git a/predictops/target/toarea.py b/predictops/target/toarea.py
new file mode 100644 (file)
index 0000000..72a8ad0
--- /dev/null
@@ -0,0 +1,47 @@
+from csv import DictReader
+from datetime import datetime
+from os import listdir
+from pathlib import Path
+
+class ToArea:
+
+    def __init__(self, area = None,
+                 start = datetime.strptime('19960101000000', '%Y%m%d%H%M%S'),
+                 end = datetime.now()):
+        self._get_located_interventions()
+
+
+
+    def _get_located_interventions(self):
+        self._data_directory = Path.cwd() / 'data' / 'targets' / 'sdis25'
+        self._dict_interv = {}
+        for year in range(2006,2018):
+            if year < 2012:
+                file_place = self._data_directory / 'interventions' / (str(year)+'.csv')
+            else:
+                file_place = self._data_directory / 'victims' / ('Liste_des_victimes_'+str(year)+'.csv')
+            with open(file_place, "r") as f:
+                reader = DictReader(f, delimiter='£')
+                for row in reader:
+                    self._dict_interv.update({
+                        row['N° intervention']: {
+                            'X' : row['Coord X'],
+                            'Y' : row['Coord Y']
+                        } for row in reader
+                    })
+        for csv_file in listdir(self._data_directory / 'interventions'):
+            with open(self._data_directory / 'interventions' / csv_file, "r") as f:
+                reader = DictReader(f, delimiter='£')
+                for row in reader:
+                    if row['N° intervention'] in self._dict_interv:
+                        self._dict_interv[row['N° intervention']].update(
+                            {
+                                'start': row['Début'],
+                                'end'  : row['Fin']
+                            })
+                    else:
+                        print(row['N° intervention'])
+
+
+
+
index 0cf261a94bfed271531a07f4352b5a382a75de63..3fdb9fb1a945b4166f8df1a8a765517943c84982 100644 (file)
@@ -1,2 +1,17 @@
+attrs==19.3.0
+Click==7.0
+click-plugins==1.1.1
+cligj==0.5.0
+Fiona==1.8.13
 geographiclib==1.50
+geopandas==0.6.3
 geopy==1.21.0
+munch==2.5.0
+numpy==1.18.1
+pandas==1.0.1
+pyproj==2.4.2.post1
+python-dateutil==2.8.1
+pytz==2019.3
+Shapely==1.7.0
+six==1.14.0
+xlrd==1.2.0