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]
# ERA5 download configuration dictionary
CONFIG = {
'product_type': product_type,
'variable': variables,
'pressure_level': pressure_levels,
'year': years,
'month': month,
'day': days,
'time': time,
......@@ -55,15 +53,17 @@ if __name__ == '__main__':
c = cdsapi.Client()
# download data for the different variables
# sequential implementation
# for var in variables:
# c.retrieve(product, {**CONFIG, **{'variable': var}}, str(
# target.joinpath('_'.join(['ERA5', var, years[0], years[-1]])
# + '.nc')))
# parallel implementation
Parallel(n_jobs=min(len(variables), os.cpu_count()), verbose=51)(
delayed(c.retrieve)(product, {**CONFIG, **{'variable': var}}, str(
target.joinpath('_'.join(['ERA5', var, years[0], years[-1]])
+ '.nc'))) for var in variables)
for var in variables:
# create output directory
output = target.joinpath(var)
if not output.exists():
output.mkdir(parents=True, exist_ok=True)
# split the download to the different years: CDS API cannot handle
# requests over the whole time period
Parallel(n_jobs=min(len(years, os.cpu_count())), verbose=51)(
delayed(c.retrieve)(
product,
{**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