Skip to content

Commit d08c8d3

Browse files
authored
Merge pull request #50 from CIAT-DAPA/develop
Develop
2 parents f6d319b + 30bede4 commit d08c8d3

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

src/aclimate_cpt/01_prediccion.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1170,12 +1170,13 @@ def cpt_merge_x_files(file_paths):
11701170
month_abb = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
11711171
#options(timeout=180)
11721172

1173+
11731174
#########################################################
11741175
########## NOT RUN ######################################
11751176
#########################################################
11761177
print(os.path.join("D:/", "andres"))
11771178
#define some global variables (some paths should be already defined in runMain so may not be necesary here)
1178-
root_dir = os.path.join("D:"+os.sep, "documents_andres", "pr_descarga", "Colombia","inputs")
1179+
root_dir = "D:/documents_andres/pr_1/colombia2/inputs" #os.path.join("D:"+os.sep, "documents_andres", "pr_descarga", "Colombia","inputs")
11791180
main_dir = os.path.join(root_dir, "prediccionClimatica")
11801181
path_dpto = os.path.join(main_dir, 'estacionesMensuales')#dir_response
11811182
dir_save = os.path.join(main_dir, "descarga") #paste0(dirPrediccionInputs, "descarga", sep = "", collapse = NULL)
@@ -1289,6 +1290,17 @@ def cpt_merge_x_files(file_paths):
12891290
print(f">{v[x]}")
12901291
cpt_merge_x_files(all_path_files[k][x])
12911292

1293+
1294+
#identificar si hay archivos que NO se descargaron
1295+
av_fls = {k: [ list(os.listdir(x)) for x in v] for k,v in all_path_season_dir.items()}
1296+
av_fls_lgth = list(chain(av_fls.values()))
1297+
av_fls_lgth = [[len(j) for j in x] for x in av_fls_lgth]
1298+
lgl = [ any([True if j ==0 else False for j in x]) for x in av_fls_lgth]
1299+
dir_wrong = [list(chain(all_path_season_dir.keys()))[x] for x in range(len(lgl)) if lgl[x] ]
1300+
1301+
if any(lgl):
1302+
raise ValueError(f"Some file was not downloaded properly for the stationID {dir_wrong}")
1303+
12921304
all_path_unzziped = {k: [ glob.glob(os.path.join(x,'**.tsv'))[0] for x in v] for k,v in all_path_season_dir.items()}
12931305
tsm_o = {k: [read_Files(pth, skip = 0) for pth in v] for k,v in all_path_unzziped.items()}
12941306
#time_sel = {k: {nm: get_cpt_dates(df) for nm,df in v.items()} for k,v in tsm_o.items()}

src/aclimate_cpt/prediction_class.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -1263,7 +1263,19 @@ def run_master(self):
12631263
print(f">{v[x]}")
12641264
self.cpt_merge_x_files(all_path_files[k][x])
12651265

1266-
1266+
av_fls = {k: [ list(os.listdir(x)) for x in v] for k,v in all_path_season_dir.items()}
1267+
av_fls_lgth = list(chain(av_fls.values()))
1268+
av_fls_lgth = [[len(j) for j in x] for x in av_fls_lgth]
1269+
lgl = [ any([True if j ==0 else False for j in x]) for x in av_fls_lgth]
1270+
dir_wrong = [list(chain(all_path_season_dir.keys()))[x] for x in range(len(lgl)) if lgl[x] ]
1271+
1272+
if any(lgl):
1273+
raise ValueError(f"Some file was not downloaded properly for the stationID {dir_wrong}")
1274+
1275+
1276+
1277+
1278+
12671279
all_path_unzziped = {k: [ glob.glob(os.path.join(x,'**.tsv'))[0] for x in v] for k,v in all_path_season_dir.items()}#{k: glob.glob(os.path.join(v, '**', '**.tsv')) for k, v in path_down.items()}
12681280

12691281
tsm_o = {k: [self.read_Files(x, skip = 0) for x in v] for k,v in all_path_unzziped.items()}

0 commit comments

Comments
 (0)