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() |