From efb20a4478b9ce059117c012a7254a1c6f56aa96 Mon Sep 17 00:00:00 2001 From: santiagoC Date: Tue, 8 Oct 2024 07:42:41 -0500 Subject: [PATCH] fixed copernicus new version --- requirements.txt | Bin 1650 -> 1650 bytes src/aclimate_resampling/complete_data.py | 9 +++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 63a7e625c7741ca27594a10752dcbbc70a48dc20..e84d46c1534a540d35fb6304f965ef31eefc13d5 100644 GIT binary patch delta 16 Xcmeyw^ND9d9;-Qn9)r=w;{U7wGqVN1 delta 16 Xcmeyw^ND9d9;+FH9)sb=;{U7wGo=N+ diff --git a/src/aclimate_resampling/complete_data.py b/src/aclimate_resampling/complete_data.py index 29bf193..2acde49 100644 --- a/src/aclimate_resampling/complete_data.py +++ b/src/aclimate_resampling/complete_data.py @@ -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', @@ -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: @@ -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 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= @@ -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 # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=