-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_get_era5.py
More file actions
executable file
·71 lines (60 loc) · 2.05 KB
/
Copy pathmain_get_era5.py
File metadata and controls
executable file
·71 lines (60 loc) · 2.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#
# Driver: get ERA5 fields
#
import era5_helper as era5
#
# select format ('grib' or 'netcdf')
#
file_format = 'netcdf'
# set
if file_format=='netcdf':
file_root_dir = 'netcdf_tmp/'
elif file_format=='grib':
file_root_dir = 'grib/'
else:
print('ERA5: Format must be either grib or netcdf')
# define variable names to be downloaded
variable_names = ['10m_u_component_of_wind',
'10m_v_component_of_wind',
'2m_dewpoint_temperature',
'2m_temperature',
'evaporation',
'runoff',
'surface_pressure',
'surface_solar_radiation_downwards',
'surface_thermal_radiation_downwards',
'total_precipitation']
# select file names
file_names = ['ERA5_sowise_u10m',
'ERA5_sowise_v10m',
'ERA5_sowise_dewpt2m',
'ERA5_sowise_tmp2m_degK',
'ERA5_sowise_evap',
'ERA5_sowise_runoff',
'ERA5_sowise_pres',
'ERA5_sowise_dsw',
'ERA5_sowise_dlw',
'ERA5_sowise_precip']
# add the root
file_names = [file_root_dir + s for s in file_names]
# select years to download
#years = ['1992','1993','1994','1995','1996','1997','1998','1999','2000','2001',
# '2002','2003','2004','2005','2006','2007','2008','2009','2010','2011',
# '2012','2013','2014','2015','2016','2017','2018','2019','2020']
years = ['1992']
#
# -- loop over variables and years to download individual files
#
for variable_name, file_name in zip(variable_names, file_names):
for year in years:
# show which request we're now making
print('Now acquiring field: ',variable_name,'\n',
'Local filename: ',file_name,'\n',
'Year: ',year,'\n',
'Format: ',file_format)
# call function to make the API request
era5.get_field(variable_name,
year,
file_name + '_' + year,
file_format=file_format)
#