Python NetCDF:I / O失败python

时间:2015-10-24 23:08:56

标签: python netcdf

我尝试使用Python从OpenDAP服务器读取NetCDF文件,但是当我转换时间变量时,我得到了I / O故障。错误出现在循环的不同步骤,并且始终存在以下值并且有效。

错误消息是:

   nc_time.append(netcdftime.DateFromJulianDay(variable[i]+refjulday,calendar='gregorian'))
File "netCDF4.pyx", line 3064, in netCDF4.Variable.__getitem__ (netCDF4.c:42706)
File "netCDF4.pyx", line 3717, in netCDF4.Variable._get (netCDF4.c:50959)
RuntimeError: NetCDF: I/O failure

代码是:

import numpy as np
import netcdftime
from datetime import datetime, date, timedelta as td


# Read data from an opendap server
import netCDF4
url = 'http://hydro1.sci.gsfc.nasa.gov:80/dods/GLDAS_NOAH025SUBP_3H'
# create a dataset object
dataset = netCDF4.Dataset(url)

variable = dataset.variables['time']
nc_n_times = variable.shape[0]
print(nc_n_times)
nc_time = []
reftime = datetime(1, 1, 1, 0, 0, 0)
refjulday = netcdftime.JulianDayFromDate(reftime, calendar='standard')
for i in range(0, nc_n_times-1):
  nc_time.append(netcdftime.DateFromJulianDay(variable[i]+refjulday,calendar='gregorian'))

print ("done")

这里有什么问题?

非常感谢提前!

克莱门

1 个答案:

答案 0 :(得分:0)

我希望这是一个互联网或服务器问题,虽然我不熟悉背后的技术。 试图执行程序昨天它在进入循环之前停止了。今天尝试它,它经历了整个循环。