-1

嗨,我正在使用此处的代码How to read NetCDF file and write to CSV using Python我希望能够从此处的 THREDDS 目录中提取“Mean_period_of_swell_waves_ordered_sequence_of_data”,但收到以下错误。我正在使用天篷

任何想法为什么?谢谢亚历克

IndexErrorTraceback (most recent call last)
/home/GRIB-extract-SWPER.py in <module>()
     73 #vname = 'surf_el'
     74 var = nc.variables[vname]
---> 75 hs = var[istart:istop,iy,ix]
     76 tim = dtime[istart:istop]
     77 
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable.__getitem__ (netCDF4/_netCDF4.c:39739)()
netCDF4/_netCDF4.pyx in netCDF4._netCDF4.Variable._get (netCDF4/_netCDF4.c:49789)()
IndexError: 
4

1 回答 1

0

通过更改修复

var = nc.variables[vname]
hs = var[istart:istop,iy,ix]
tim = dtime[istart:istop]

var = nc.variables[vname]
tp = var[istart:istop,iy,ix]
tim = dtime[istart:istop]
于 2018-02-06T22:18:55.707 回答