WasuratS commited on
Commit
44c6bf0
1 Parent(s): d1c9247

Create cds_api_requestor_example.py

Browse files
Files changed (1) hide show
  1. cds_api_requestor_example.py +32 -0
cds_api_requestor_example.py ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import cdsapi
2
+
3
+ def retrieve_data(year_list, month_list, day_list, time_list):
4
+ c = cdsapi.Client()
5
+ for year in year_list:
6
+ for month in month_list:
7
+ c.retrieve('reanalysis-era5-land',
8
+ {
9
+ 'variable': [
10
+ '2m_temperature']
11
+ ,
12
+ 'year': year,
13
+ 'month': month,
14
+ 'day': day_list,
15
+ 'time': time_list,
16
+ 'format': 'grib',
17
+ 'area': [
18
+ 20.43, 97.96, 5.77,
19
+ 105.22,
20
+ ],
21
+ },
22
+ f'{year}_{month}_hourly_2m_temp_TH.grib')
23
+
24
+ def main():
25
+ month_list = [str(num).zfill(2) for num in range(1, 13)]
26
+ day_list = [str(num).zfill(2) for num in range(1, 32)]
27
+ time_list = [str(num).zfill(2) + ":00" for num in range(0, 24)]
28
+ year_list = [str(num) for num in range(2023, 2024)]
29
+ retrieve_data(year_list, month_list, day_list, time_list)
30
+
31
+ if __name__ == '__main__':
32
+ main()