終於開始用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)
})