Skip to content

Commit

Permalink
Merge pull request #28 from CIAT-DAPA/develop
Browse files Browse the repository at this point in the history
fixed issue with season folders order
  • Loading branch information
andresk159 authored Aug 18, 2023
2 parents d84d34a + 5f93a33 commit b772081
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/aclimate_cpt/01_prediccion.py
Original file line number Diff line number Diff line change
Expand Up @@ -1253,7 +1253,7 @@ def cpt_merge_x_files(file_paths):
print(" \n Archivos de entrada Descargados \n")


all_path_season_dir = {k: glob.glob(f"{v}\\**") for k,v in path_down.items()}
all_path_season_dir = {k: [os.path.join(path_down[k],x) for x in v] for k, v in season.items()}
all_path_files = {k: [ glob.glob(os.path.join(x,'**.tsv')) for x in v] for k,v in all_path_season_dir.items()}

for k,v in all_path_files.items():
Expand All @@ -1263,7 +1263,7 @@ def cpt_merge_x_files(file_paths):
print(f">{v[x]}")
cpt_merge_x_files(all_path_files[k][x])

all_path_unzziped = {k: glob.glob(f"{v}\\**\\**.tsv") for k,v in path_down.items()}
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()}
tsm_o = {k: [read_Files(pth, skip = 0) for pth in v] for k,v in all_path_unzziped.items()}
#time_sel = {k: {nm: get_cpt_dates(df) for nm,df in v.items()} for k,v in tsm_o.items()}

Expand All @@ -1279,7 +1279,7 @@ def cpt_merge_x_files(file_paths):
transform = {k: [v[x]["transformation"][0]["gamma"] for x in range(len(v)) if len(v[x]["transformation"]) != 0] for k,v in init_params.items()}
p_data = {k: v.shape[1]-2 for k,v in data_y.items() }

path_x = {x: glob.glob(f"{os.path.join(dir_save,x)}\\**\\**.tsv", recursive = True) for x in os.listdir(dir_save)} # lapply(list.files(dir_save,full.names = T),function(x)list.files(x,recursive = T,full.names = T))
path_x = {k: [glob.glob(os.path.join(path_down[k], x, "**.tsv"), recursive=True) for x in v] for k,v in season.items()}#{x: glob.glob(os.path.join(x, '**.tsv'), recursive=True) for x in os.listdir(self.path_inputs_downloads)}
path_zone = {dir_names[x]: glob.glob(f"{os.path.join(main_dir, 'run_CPT')}\\**\\y_**.txt", recursive = True)[x] for x in range(len(dir_names))} #list.files(paste0(main_dir,"run_CPT"),full.names = T) %>% paste0(.,"/y_",list.files(path_dpto),".txt")
path_output_pred = {k: [ os.path.join(pth, "output","0_") for pth in v] for k,v in path_months_l.items()}
path_run = {k: [ os.path.join(pth, "run_0"+ext_exe) for pth in v] for k,v in path_months_l.items()}#lapply(path_months_l,function(x)paste0(x,"/output/0_"))
Expand Down
14 changes: 8 additions & 6 deletions src/aclimate_cpt/prediction_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,7 @@ def run_master(self):
# all_path_season_dir = {k: glob.glob(f"{v}\\**") for k,v in path_down.items()}
# all_path_files = {k: [ glob.glob(f"{x}\\**.tsv") for x in v] for k,v in all_path_season_dir.items()}

all_path_season_dir = {k: glob.glob(os.path.join(v, '**')) for k, v in path_down.items()}
all_path_season_dir = {k: [os.path.join(path_down[k],x) for x in v] for k, v in season.items()}
all_path_files = {k: [ glob.glob(os.path.join(x,'**.tsv')) for x in v] for k,v in all_path_season_dir.items()}

for k,v in all_path_files.items():
Expand All @@ -1223,10 +1223,10 @@ def run_master(self):
print(f">{v[x]}")
self.cpt_merge_x_files(all_path_files[k][x])

#all_path_unzziped = {k: glob.glob(f"{v}\\**\\**.tsv") for k,v in path_down.items()}
all_path_unzziped = {k: glob.glob(os.path.join(v, '**', '**.tsv')) for k, v in path_down.items()}

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()}

tsm_o = {k: [self.read_Files(pth, skip = 0) for pth in v] for k,v in all_path_unzziped.items()}
tsm_o = {k: [self.read_Files(x, skip = 0) for x in v] for k,v in all_path_unzziped.items()}
#time_sel = {k: {nm: get_cpt_dates(df) for nm,df in v.items()} for k,v in tsm_o.items()}

print("\n Archivos de entrada cargados")
Expand All @@ -1243,8 +1243,10 @@ def run_master(self):
p_data = {k: v.shape[1]-2 for k,v in data_y.items() }

#path_x = {x: glob.glob(f"{os.path.join(self.path_inputs_downloads,x)}\\**.tsv", recursive = True) for x in os.listdir(self.path_inputs_downloads)} # lapply(list.files(dir_save,full.names = T),function(x)list.files(x,recursive = T,full.names = T))
path_x = {x: glob.glob(os.path.join(self.path_inputs_downloads, x, '**.tsv'), recursive=True) for x in os.listdir(self.path_inputs_downloads)}

path_x = {k: [glob.glob(os.path.join(path_down[k], x, "**.tsv"), recursive=True) for x in v] for k,v in season.items()}#{x: glob.glob(os.path.join(x, '**.tsv'), recursive=True) for x in os.listdir(self.path_inputs_downloads)}



#path_zone = {dir_names[x]: glob.glob(f"{os.path.join(self.path_inputs_prediccion, 'run_CPT')}\\**\\y_**.txt", recursive = True)[x] for x in range(len(dir_names))} #list.files(paste0(main_dir,"run_CPT"),full.names = T) %>% paste0(.,"/y_",list.files(path_dpto),".txt")
path_zone = {dir_names[x]: glob.glob(os.path.join(self.path_inputs_prediccion, 'run_CPT', '**', 'y_**.txt'), recursive=True)[x] for x in range(len(dir_names))}

Expand Down

0 comments on commit b772081

Please sign in to comment.