ERA5数据批量下载
程序员文章站
2022-03-28 17:50:13
欧洲数值预报中心-ERA5数据下在本文提供了一个下载ERA5-land hourly data 的示例import cdsapiimport numpy as npimport calendarimport os# define directory in which data shall be storedos.chdir("F:/era5")#账号的url\uid\keyc = cdsapi.Client(url= "https://cds.climate.copernicus.eu...
欧洲数值预报中心-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 = "123:123ea9c0-23c2-12be-a0b2-2f12f40f2bd1")
# 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')
本文地址:https://blog.csdn.net/luqialiu3392/article/details/107630664
上一篇: 历史上很多朝代都进攻过缅甸,为何很多都是铩羽而归?
下一篇: android5.0后的动画
推荐阅读