File size: 1,004 Bytes
44c6bf0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import cdsapi

def retrieve_data(year_list, month_list, day_list, time_list):
    c = cdsapi.Client()
    for year in year_list:
        for month in month_list:
            c.retrieve('reanalysis-era5-land',
            {
                'variable': [
                    '2m_temperature']
            ,
            'year': year,
            'month': month,
            'day': day_list,
            'time': time_list,
            'format': 'grib',
            'area': [
                        20.43, 97.96, 5.77,
                        105.22,
                    ],
                    },
            f'{year}_{month}_hourly_2m_temp_TH.grib')

def main():
    month_list = [str(num).zfill(2) for num in range(1, 13)]
    day_list = [str(num).zfill(2) for num in range(1, 32)]
    time_list = [str(num).zfill(2) + ":00" for num in range(0, 24)]
    year_list = [str(num) for num in range(2023, 2024)]
    retrieve_data(year_list, month_list, day_list, time_list)

if __name__ == '__main__':
    main()