| 
 
	积分6813贡献 精华在线时间 小时注册时间2011-12-4最后登录1970-1-1 
 | 
 
| 
最近想下载欧洲中心的ERA5数据做一些分析,看了论坛大神的帖子用Python下载ERA5简单粗暴教程之后搞定了初步的安装工作,因为下载的数据比较多,时次又不定,再加上这网速实在是感人,所以就仅选取所需要的时次,在搜索一番之后,知乎上发现了某神所做的python批量下载ECMWF欧洲中心数据,但是不能做时次选择,再折腾了一番和求助群里大神之后终于搞定了。仅仅是小菜鸟一个,语言编写不足之处还请指教。脚本如下
x
登录后查看更多精彩内容~您需要 登录 才可以下载或查看,没有帐号?立即注册 
  import cdsapi
 
 def  download_cds():
 
 c = cdsapi.Client()
 lines = open("code.txt", 'r').readlines()
 for i in range(len(lines)):
 if i%2==0:
 fields = lines.strip('\n')
 fields = fields.split(' ') #split data
 year = fields[0]
 month = fields[1]
 day = fields[2]
 time = list()
 for j in range(len(fields)):
 int(j)
 if j > 2:
 time.append(fields[j])
 j = j-1
 else:
 continue
 t = time
 print('Download %s-%s-%s data'% (year,month,day))
 c.retrieve(
 'reanalysis-era5-single-levels',
 {
 'area':'50/95/20/125', # North, West, South, East. Default: global
 'grid': [0.1, 0.1],
 'product_type': 'reanalysis',
 'variable': [
 '10m_u_component_of_wind', '10m_v_component_of_wind', '2m_dewpoint_temperature',
 '2m_temperature', 'surface_pressure',
 ],
 'year': year,
 'month': month,
 'day': day,
 'time': t,
 'format': 'grib'
 
 },
 'd:/era_down/CDS%s%s%s'% (year,month,day)+'.grib')
 print('Datafile %s%s%s'% (year,month,day)+'.grib download successful')
 else:
 pass
 
 if __name__ == '__main__':
 download_cds()
 
 
 code.txt的格式如下
 
   
 
 | 
 |