Skip to content

Commit

Permalink
Merge pull request #88 from CIAT-DAPA/develop
Browse files Browse the repository at this point in the history
fixed copernicus new version
  • Loading branch information
santiago123x authored Oct 8, 2024
2 parents 70ae462 + efb20a4 commit f55171b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Binary file modified requirements.txt
Binary file not shown.
9 changes: 5 additions & 4 deletions src/aclimate_resampling/complete_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def download_era5_data(self,variables=["t_max","t_min","sol_rad"], test = False)
self.manager.mkdir(save_path_era5_data_tmp)

if self.force or os.path.exists(save_path_era5) == False:
c = cdsapi.Client(timeout=600,quiet=False,verify=False)
c = cdsapi.Client(timeout=600)
c.retrieve('sis-agrometeorological-indicators',
{
'format': 'zip',
Expand Down Expand Up @@ -310,7 +310,6 @@ def extract_values(self,dir_path,var,locations, date_start,date_end,date_format)
def filter_extract_data(self, data_frame):
current_year = self.start_date.year
current_month = self.start_date.month

if "year" not in data_frame.columns:
raise ValueError("ERROR year column doesn't exists. Current columns: " + ', '.join(data_frame.columns))
if "month" not in data_frame.columns:
Expand All @@ -330,7 +329,8 @@ def extract_chirp_data(self,locations):
dir_path = os.path.join(save_path,"chirp")
data = self.extract_values(dir_path,'prec',locations,-14,-4,'%Y.%m.%d')
df = pd.DataFrame(data)
df = self.filter_extract_data(df)
if not df.empty:
df = self.filter_extract_data(df)
return df

# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand All @@ -350,7 +350,8 @@ def extract_era5_data(self,locations,variables=["t_max","t_min","sol_rad"]):
df = df_tmp.copy()
else:
df = pd.merge(df,df_tmp,how='left',on=['ws','day','month','year'])
df = self.filter_extract_data(df)
if not df.empty:
df = self.filter_extract_data(df)
return df

# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Expand Down

0 comments on commit f55171b

Please sign in to comment.