【问题标题】:Automated download of NetCDF file自动下载 NetCDF 文件
【发布时间】:2013-07-30 08:41:33
【问题描述】:

只是想知道是否有人可以帮助我尝试在我的代码中从 Internet 下载 NetCDF 文件。希望下载的网站是:

http://www.esrl.noaa.gov/psd/cgi-bin/db_search/DBListFiles.pl?did=3&tid=38354&vid=20

我要下载的文件名是air.sig995.2013.nc

如果是手动下载的,链接是:

ftp://ftp.cdc.noaa.gov/Datasets/ncep.reanalysis.dailyavgs/surface/air.sig995.2013.nc

谢谢

【问题讨论】:

    标签: python netcdf


    【解决方案1】:

    我会使用urllib 来检索文件

    像这样:

    urllib.urlretrieve(url, filename)
    

    其中url 是下载的网址,filename 是您要命名的文件

    【讨论】:

      【解决方案2】:

      你可以试试这个:

      #!/usr/bin/env python
      # Read data from an opendap server
      import netCDF4
      # specify an url, the JARKUS dataset in this case
      url = 'http://dtvirt5.deltares.nl:8080/thredds/dodsC/opendap/rijkswaterstaat/jarkus/profiles/transect.nc'
      # for local windows files, note that '\t' defaults to the tab character in python, so use prefix r to indicate that it is a raw string.
      url = r'f:\opendap\rijkswaterstaat\jarkus\profiles\transect.nc'
      # create a dataset object
      dataset = netCDF4.Dataset(url)
      
      # lookup a variable
      variable = dataset.variables['id']
      # print the first 10 values
      print variable[0:10]
      

      来自 https://publicwiki.deltares.nl/display/OET/Reading%2Bdata%2Bfrom%2BOpenDAP%2Busing%2Bpython

      【讨论】:

        猜你喜欢
        • 2020-04-12
        • 2012-04-26
        • 1970-01-01
        • 2018-10-07
        • 2019-01-27
        • 2017-03-21
        • 2016-11-01
        • 2017-01-13
        • 2018-11-21
        相关资源
        最近更新 更多