- 积分
- 2317
- 贡献
-
- 精华
- 在线时间
- 小时
- 注册时间
- 2021-10-27
- 最后登录
- 1970-1-1
|
登录后查看更多精彩内容~
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
本帖最后由 沉默的狙击手 于 2023-6-27 10:21 编辑
#在完成注册以及导入.cdsapirc文件后,直接复制粘贴代码,修改idm路径以及product_type和r = c.retrieve以及
#相关时间范围等变量,即可下载
import cdsapi
import calendar
from subprocess import call
def idmDownloader(task_url,folder_path,file_name):
'''
:param task_url: 下载任务地址
:param folder_path: 存放文件夹
:param file_name: 文件名
:return:
'''
# IDM安装目录
idm_engine = "C:\\Program Files (x86)\\Internet Download Manager\\IDMan.exe"
# 将任务添加至队列
call([idm_engine, '/d', task_url, '/p', folder_path, '/f', file_name, '/a'])
# 开始任务队列
call([idm_engine, '/s'])
c = cdsapi.Client() #创建用户
# 数据信心字典
dic = {
'product_type': 'monthly_averaged_reanalysis', #产品类型
'format': 'netcdf', #数据格式
'variable': [
'divergence',
# 'geopotential',
# 'ozone_mass_mixing_ratio',
# 'potential_vorticity', 'temperature',
# 'u_component_of_wind',
# 'v_component_of_wind',
# 'vertical_velocity'
# 'specific humidity',
# 'relative humidity'
# 'geopotential',
# 'temperature'#,'u_component_of_wind','u_component_of_wind'#变量名称
],
'pressure_level': [
# '1', '2', '3',
# '5', '7', '10',
# '20', '30', '50',
# '70', '100', '125',
# '150', '175', '200',
# '225', '250', '300',
# '350', '400', '450',
'500',
# '550', '600',
# '650', '700', '750',
# '775', '800', '825',
# '850', '875', '900',
# '925', '950', '975',
# '1000',
# '300','500'
],
# 'pressure_level':['300','500','600'],
'year': [],
'month': [
'01', '02', '03',
'04', '05', '06',
'07', '08', '09',
'10', '11', '12',
],
# 'day': [
# '01', '02', '03',
# '04', '05', '06',
# '07', '08', '09',
# '10', '11', '12',
# '13', '14', '15',
# '16', '17', '18',
# '19', '20', '21',
# '22', '23', '24',
# '25', '26', '27',
# '28', '29', '30',
# '31'
# ],
'time': [
'00:00',
# '06:00',
# '12:00',
# '18:00',
],
# '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',
# ],
'grid': '0.25/0.25', #直接下载是数据默认的精度,加上grid可以修改成想要的精度
'area': [
90, -180, 0,
180,
],
}
for y in range(2018,2019):
# for m in range(1,13):#月循环
# day_num = calendar.monthrange(y,m)[1] #根据年月,获取当月日数
dic['year'] = ['2000','2001','2002','2003','2004','2005',
'2006','2007','2008','2009','2010','2011',
'2012','2013','2014','2015','2016','2017',
'2018','2019','2020','2021']
# dic['month'] = str(m).zfill(2)
# dic['day'] = [str(d).zfill(2) for d in range(1,day_num+1)]
# filename = 'G:\\PyCharm\\venv\\ERA5\\02-22 ERA5\\'\
# +str(y)+str(m).zfill(2)+'.nc' #文件存储路径
r = c.retrieve('reanalysis-era5-land',dic)
# month:reanalysis-era5-pressure-levels-monthly-means
# hours:reanalysis-era5-pressure-levels
url = r.location # 获取文件下载地址
path = 'D:\\'# 存放文件夹
# filename = 'geopotential_'+str(y) + str(m).zfill(2) + '.nc' # 文件名
filename = str(y) +'.nc' # 文件名
idmDownloader(url, path, filename) # 添加进IDM中下载
|
-
-
IDM.zip
11.54 MB, 下载次数: 49, 下载积分: 金钱 -5
售价: 1 贡献 [记录]
|