Skip to content
Snippets Groups Projects
Commit aa9db417 authored by Frisinghelli Daniel's avatar Frisinghelli Daniel
Browse files

Split requests by year.

parent fa76b05e
No related branches found
No related tags found
No related merge requests found
...@@ -35,9 +35,7 @@ area = [52, 2, 40, 20] ...@@ -35,9 +35,7 @@ area = [52, 2, 40, 20]
# ERA5 download configuration dictionary # ERA5 download configuration dictionary
CONFIG = { CONFIG = {
'product_type': product_type, 'product_type': product_type,
'variable': variables,
'pressure_level': pressure_levels, 'pressure_level': pressure_levels,
'year': years,
'month': month, 'month': month,
'day': days, 'day': days,
'time': time, 'time': time,
...@@ -55,15 +53,17 @@ if __name__ == '__main__': ...@@ -55,15 +53,17 @@ if __name__ == '__main__':
c = cdsapi.Client() c = cdsapi.Client()
# download data for the different variables # download data for the different variables
for var in variables:
# sequential implementation # create output directory
# for var in variables: output = target.joinpath(var)
# c.retrieve(product, {**CONFIG, **{'variable': var}}, str( if not output.exists():
# target.joinpath('_'.join(['ERA5', var, years[0], years[-1]]) output.mkdir(parents=True, exist_ok=True)
# + '.nc')))
# split the download to the different years: CDS API cannot handle
# parallel implementation # requests over the whole time period
Parallel(n_jobs=min(len(variables), os.cpu_count()), verbose=51)( Parallel(n_jobs=min(len(years, os.cpu_count())), verbose=51)(
delayed(c.retrieve)(product, {**CONFIG, **{'variable': var}}, str( delayed(c.retrieve)(
target.joinpath('_'.join(['ERA5', var, years[0], years[-1]]) product,
+ '.nc'))) for var in variables) {**CONFIG, **{'variable': var, 'year': year}},
output.joinpath('_'.join(['ERA5', var, year]) + '.nc'))
for year in years)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment