@@ -1178,7 +1178,31 @@ def run_master(self):
1178
1178
dir_names = os .listdir (self .path_inputs_monthly_stations )
1179
1179
#path_json = glob.glob(f"{self.path_inputs_monthly_stations}\\**\\cpt_areas.json", recursive = True)
1180
1180
path_json = glob .glob (os .path .join (self .path_inputs_monthly_stations , '**' , 'cpt_areas.json' ), recursive = True )
1181
+ path_stations = glob .glob (os .path .join (self .path_inputs_monthly_stations , '**' , 'stations.csv' ), recursive = True )
1181
1182
init_params = {k : self .load_json (pth ) for k ,pth in zip (dir_names , path_json )}
1183
+ #sacar del analisis departamentos donde el cpt_areas.json no tenga nada
1184
+ items_lgth = {k : sum ([len (x ["areas" ]) for x in val ]) for k ,val in init_params .items ()}
1185
+ empty_dpt = [k for k ,v in items_lgth .items () if v == 0 ]
1186
+ lgth_list = [v for k ,v in items_lgth .items ()]
1187
+ bool_lgth = [x == 0 for x in lgth_list ]
1188
+
1189
+ if len (empty_dpt ) > 0 :
1190
+ Warning ("Empty areas.json file found" )
1191
+ for idx in range (len (items_lgth )):
1192
+ if lgth_list [idx ] == 0 :
1193
+ dir_names .pop (idx )
1194
+ path_json .pop (idx )
1195
+ path_stations .pop (idx )
1196
+ for nm in empty_dpt :
1197
+ init_params .pop (nm )
1198
+
1199
+ if all (bool_lgth ):
1200
+ raise ValueError ("departments has ares.json file empty" )
1201
+
1202
+
1203
+
1204
+
1205
+
1182
1206
month_abb = ["Jan" , "Feb" , "Mar" , "Apr" , "May" , "Jun" , "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec" ]
1183
1207
ext_exe = ".bat"
1184
1208
@@ -1250,7 +1274,7 @@ def run_master(self):
1250
1274
print ("\n Archivos de entrada cargados" )
1251
1275
1252
1276
#path_stations = glob.glob(f"{self.path_inputs_monthly_stations}\\**\\stations.csv", recursive = True)
1253
- path_stations = glob . glob ( os . path . join ( self . path_inputs_monthly_stations , '**' , 'stations.csv' ), recursive = True )
1277
+
1254
1278
data_y = {k : pd .read_csv (fl ) for k ,fl in zip (dir_names , path_stations )}
1255
1279
part_id = {k : self .files_y (df , k , main_dir = self .path_inputs_prediccion ) for k ,df in data_y .items ()}
1256
1280
0 commit comments