您的位置:首页 > 编程语言 > Python开发

利用python下载ECMWF数据

2018-05-01 11:51 369 查看

1.注册ECMWF数据下载账号;

2.下载 ECMWF web-API client version in python,下载网址为https://software.ecmwf.int/wiki/display/WEBAPI/Web-API+Downloads,然后pip install 下载的包即可

3.登录账号获取下载数据的key,网址https://api.ecmwf.int/v1/key/,然后将获取的信息保存成名为.ecmwfapirc文件,windows放置在 C:\Users\<USERNAME>\.ecmwfapirc,文件内容样例如下:

4.修改需要下载数据的pytho程序样例。重点修改下载的时间,变量(变量编号或变量名),垂直层以及覆盖的区域。ECMWF网站上有关说明:https://softwarepythonchen.ecmwf.int/wiki/display/WEBAPI/Accessing+ECMWF+data+servers+in+batch

5.所附程序为下载ECMWF interim气压层的数据

#!/usr/bin/python #-*-coding: UTF-8 -*- from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() # This script downloads ERA-Interim forecasts, on pressure levels. # Adapt the script to your requirements. # The data volume for all pressure level data is about 5GB per day, and all pressure level data for more than a single day will exceed the WebAPI limit of 600.000 fields. Thus please restrict the download to what you really need. # It is likely you need to split your request, this is best done by time periods, ie. first download for month 1, then for month 2, etc. year=['2012','2013','2014','2015','2016','2017'] month=['05','06','07','08','09'] day=['31','30','31','31','30'] for i in year[0:6]: k=0 for j in month[0:5]: print i+'-'+j+'-01/to/'+i+'-'+j+'-'+day[k] server.retrieve({ # Specify the ERA-Interim data archive. Don't change. "class": "ei", "dataset": "interim", "expver": "1", "stream": "oper", # pressure levels (levtype:pl), all available levels (levelist) "levtype": "pl", "levelist": "100/200/225/250/300/350/400/450/500/550/600/650/700/750/775/800/825/850/875/900/925/950/975/1000", # forecast (type:fc), from both daily forecast runs (time) with all available forecast steps (step, in hours) "type": "an", "time": "00/06/12/18", "step": "0", # all available parameters, for codes see http://apps.ecmwf.int/codes/grib/param-db "param": "60.128/129.128/130.128/131.128/132.128/133.128/135.128/138.128/155.128/157.128", # two days worth of data "date": i+'-'+j+'-01/to/'+i+'-'+j+'-'+day[k], # in 0.75 degrees lat/lon "grid": "0.75/0.75", # optionally restrict area to Europe (in N/W/S/E). #"area": "75/-20/10/60", # Optionally get output in NetCDF format. However, for NetCDF timestamps (time+step) must not overlap, so use e.g. "time":"00:00:00/12:00:00","step":"12" "format" : "netcdf", # set an output file name "target": "E:\\ERA-Interim\\"+i+"-"+j+"-01to"+i+"-"+j+"-"+day[k]+"-pl.nc" }) k = k + 1 print "Download finished"


阅读更多
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: