欧洲数值预报中心-ERA5数据下在
本文提供了一个下载ERA5-land hourly data 的示例
import cdsapi
import numpy as np
import calendar
import os
# define directory in which data shall be stored
os.chdir("F:/era5")
#账号的url\uid\key
c = cdsapi.Client(url= "https://cds.climate.copernicus.eu/api/v2",
key = "XXX")
# 52830
# 642ea9c0-27c2-45be-a0b3-2f91f40f7bd8
# define variable to download (eg. u component 100m wind)
# var = [ '10m_u_component_of_wind',
# '10m_v_component_of_wind',
# '2m_temperature',
# '2m_dewpoint_temperature',
# 'Snowfall',
# 'Surface_pressure',
# 'Total_evaporation',
# 'Total_precipitation']
var = [ '10m_u_component_of_wind',
'10m_v_component_of_wind',
'2m_temperature',
'2m_dewpoint_temperature',
'Snowfall',
'Surface_pressure',
'Total_precipitation']
# define the years you want to download
yearstart = 2020
yearend = 2020
# define the start and end month you want to download
monthstart = 1
monthend = 4
# define the start and end day you want to download
daystart = 1
dayend = 31
# define spatial limits of download (eg. around Austria)
lon1 = 114
lon2 = 123
lat1 = 34
lat2 = 39
# create lists
years = np.array(range(yearstart,yearend+1),dtype="str")
area = [lat2, lon1, lat1, lon2]
for year in years:
if (int(year)==yearstart) and (int(year)==yearend):
months = np.array(range(monthstart,monthend+1),dtype="str")
elif (year == yearstart) :
months = np.array(range(monthstart,13),dtype="str")
elif (year == yearend):
months = np.array(range(1,monthend + 1),dtype="str")
else:
months = np.array(range(1,13),dtype="str")
for month in months:
m = '{:0>2}'.format(str(month))
# if int(month) < 10:
# m = '0' + month
# else:
# m = month
if(int(year) == yearstart) and (int(year) == yearend) and (int(month) == monthstart) and (int(month) == monthend):
days = list(np.array(range(daystart,dayend+1),dtype="str"))
elif (int(year) == yearstart) and (int(month) == monthstart):
days = list(np.array(range(daystart,calendar.monthrange(int(year),int(month))[1]+1),dtype="str"))
elif (int(year) == yearend) and (int(month) == monthend):
days = list(np.array(range(1,dayend+1),dtype="str"))
else:
days = list(np.array(range(1,calendar.monthrange(int(year),int(month))[1]+1),dtype="str"))
for day in days:
d = '{:0>2}'.format(str(day))
# if int(day) < 10:
# d = '0' + day
# else:
# d = day
c.retrieve(
'reanalysis-era5-land',
{
'variable': var,
'product_type':'reanalysis',
'year': year,
'month': month,
'day': day,
'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'
],
'area': area ,
'format':'netcdf',
'grid': '0.1/0.1'
},
'era5_' + '_' + year + m + d + '.nc')
版权声明:本文为luqialiu3392原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。