利用python批量下载ERA的数据

终于开始用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)
         })

 

你可能感兴趣的:(python)