Skip to content

Instantly share code, notes, and snippets.

@matteodefelice
Created February 22, 2019 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matteodefelice/8f7ce920296b7d5199f09661c233f826 to your computer and use it in GitHub Desktop.
Save matteodefelice/8f7ce920296b7d5199f09661c233f826 to your computer and use it in GitHub Desktop.
A script to download ERA5 entire dataset for a set of selected surface variables.
import cdsapi
import os
c = cdsapi.Client()
VARS = ['100m_u_component_of_wind','100m_v_component_of_wind','10m_u_component_of_wind', '10m_v_component_of_wind', '2m_temperature','surface_solar_radiation_downward_clear_sky','surface_solar_radiation_downwards', '2m_dewpoint_temperature','mean_sea_level_pressure']
YEARS = [x for x in map(str, range(1979, 2019))]
for V in VARS:
for Y in YEARS:
target_filename = 'era5-hourly-'+V+'-'+Y+'.nc'
if not os.path.isfile(target_filename):
c.retrieve(
'reanalysis-era5-single-levels',
{
'variable':V,
'product_type':'reanalysis',
'year': Y,
'month':[
'01','02','03',
'04','05','06',
'07','08','09',
'10','11','12'
],
'day':[
'01','02','03',
'04','05','06',
'07','08','09',
'10','11','12',
'13','14','15',
'16','17','18',
'19','20','21',
'22','23','24',
'25','26','27',
'28','29','30',
'31'
],
'time':[
'00:00','01:00','02:00',
'03:00','04:00','05:00',
'06:00','07:00','08:00',
'09:00','10:00','11:00',
'12:00','13:00','14:00',
'15:00','16:00','17:00',
'18:00','19:00','20:00',
'21:00','22:00','23:00'
],
'format':'netcdf'
},
target_filename)
@selipot
Copy link

selipot commented Feb 22, 2019

Does this script submit one request at a time? i.e. wait for one download to be finished before going to the next request? A maximum of 2 jobs running at the same time on the Climate Data Store ... which may be different from being queued.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment