我正在尝试提取一些netcdf数据,但出现错误。任何帮助,将不胜感激。
我尝试了data.variables ['instrument_avail']。instrument_A_lat_deg,但这不起作用。还有另一种提取方法吗?
from netCDF4 import Dataset as NetCDFFile
data=NetCDFFile('my_data.nc')
data.variables['instrument_avail']
#this is the result to the above call:
<type 'netCDF4._netCDF4.Variable'>
|S1 instrument_avail()
instrument_Loc_A_lat_deg: 38
instrument_Loc_A_lat_min: 5
instrument_Loc_A_lat_sec: 5
instrument_Loc_A_lon_deg: -75
instrument_Loc_A_lon_min: 35
instrument_Loc_A_lon_sec: 8
unlimited dimensions:
current shape = ()
filling on, default _FillValue of � used
上面列出了调用data.variables ['instrument_avail']的结果。
我收到以下错误:
data.variables['instrument_avail'].instrument_A_lat_deg
Traceback (most recent call last):
File "<ipython-input-32-c85db34c651e>", line 1, in <module>
data.variables['instrument_avail'].instrument_A_lat_deg
File "netCDF4/_netCDF4.pyx", line 4057, in netCDF4._netCDF4.Variable.__getattr__
File "netCDF4/_netCDF4.pyx", line 3868, in netCDF4._netCDF4.Variable.getncattr
File "netCDF4/_netCDF4.pyx", line 1289, in netCDF4._netCDF4._get_att
File "netCDF4/_netCDF4.pyx", line 1745, in netCDF4._netCDF4._ensure_nc_success
AttributeError: NetCDF: Attribute not found
如何准确获取实际数据; lat_deg,lat_min,lat_sec等?