利用python批量下載ERA的資料
阿新 • • 發佈:2018-12-13
終於開始用python了,只學了兩天的python小白上線下載資料(被逼的)。
其實這個有一些很好的教程,我直接貼上好了。批量下載的教程
其中的一些引數官網的解釋很清楚的,可以先試著下載一個月的資料,再獲取它的request提供參考
最後是我的一些程式碼,以及註釋
這是下載era-40裡面的2mt資料,並且只下載緯度80N以北的資料,注意看引數。格網為0.75
from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() polynya_boundary = "90/-180/80/180" day_month_dic = {1:31,2:28,3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30,12:31} for year in range(1959, 1979): for month in range(1, 13): date_varied = "{}-{:0>2d}-01/to/{}-{:0>2d}-{}".format(year, month, year, month, day_month_dic[month]) server.retrieve({ 'stream' : "oper", 'levtype' : "sfc", 'param' : "167.128", 'dataset' : "era40", 'step' : "0", 'grid' : "0.75/0.75", 'time' : "00/06/12/18", 'date' : date_varied, 'type' : "an", 'class' : "E4", 'area' : polynya_boundary, 'format' : "netcdf", 'target' : "F:\\ERAInterim\\2TM\\{0}\\{1}_{2:0>2d}.nc".format(year,year,month) })
下面這個是下載ERA-Interim的2tm的資料,注意時間,範圍基本一致。
from ecmwfapi import ECMWFDataServer server = ECMWFDataServer() polynya_boundary = "90/-180/80/180" day_month_dic = {1:31,2:28,3:31, 4:30, 5:31, 6:30, 7:31, 8:31, 9:30, 10:31, 11:30,12:31} for year in range(2018, 2019): for month in range(1, 10): date_varied = "{}-{:0>2d}-01/to/{}-{:0>2d}-{}".format(year, month, year, month, day_month_dic[month]) server.retrieve({ 'stream' : "oper", 'levtype' : "sfc", 'param' : "167.128", 'dataset' : "interim", 'step' : "0", 'grid' : "0.75/0.75", 'time' : "00/06/12/18", 'date' : date_varied, 'type' : "an", 'class' : "ei", 'area' : polynya_boundary, 'format' : "netcdf", 'target' : "F:\\ERAInterim\\2TM\\{0}\\{1}_{2:0>2d}.nc".format(year,year,month) })