Skip to content

Commit dfdf083

Browse files
committed
Correct E-OBS download script
1 parent 2d98906 commit dfdf083

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

scripts/download/insitu-gridded-observations-europe.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66

77

8-
def get_output_filename(row,dataset,year):
8+
def get_output_filename(row,dataset):
99

1010
var=row["filename_variable"]
11-
date=f"{year}"
11+
date=f"{row["cds_years_start"]}-{row["cds_years_end"]}"
1212
return f"{var}_{dataset}_{date}.nc"
1313

14-
def create_request(row,year):
14+
def create_request(row):
1515
var=row["cds_request_variable"]
1616
product_type=row["cds_product_type"]
1717
grid_resolution=row["cds_grid_resolution"]

scripts/utilities/utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ def load_path_from_df(df, variable_name, variable_column='filename_variable',
207207
# Return None if no matching variable is found
208208
return None
209209

210-
def download_files(dataset, variables_file_path, create_request_func, get_output_filename_func, monthly_request=False):
210+
def download_files(dataset, variables_file_path, create_request_func, get_output_filename_func, monthly_request=False,year_request=True):
211211
"""
212212
Download files for the specified variables and years.
213213
@@ -252,7 +252,7 @@ def download_files(dataset, variables_file_path, create_request_func, get_output
252252
logging.info(f"{path_file} already exists, skipping")
253253
continue
254254
futures.append(executor.submit(download_single_file, dataset, request, path_file))
255-
else:
255+
elif year_request:
256256
for year in year_list:
257257
request = create_request_func(row, year)
258258
file = get_output_filename_func(row, dataset, year)
@@ -261,6 +261,14 @@ def download_files(dataset, variables_file_path, create_request_func, get_output
261261
logging.info(f"{path_file} already exists, skipping")
262262
continue
263263
futures.append(executor.submit(download_single_file, dataset, request, path_file))
264+
else:
265+
request = create_request_func(row)
266+
file = get_output_filename_func(row, dataset)
267+
path_file = dest_dir / file
268+
if path_file.exists():
269+
logging.info(f"{path_file} already exists, skipping")
270+
continue
271+
futures.append(executor.submit(download_single_file, dataset, request, path_file))
264272

265273
for future in futures:
266274
try:

0 commit comments

Comments
 (0)