[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[netCDF #BSJ-787826]: NetCDF4 Python Error: attribute has unsupported datatype



It is probably best if you repost this as an issue
at the netcdf4-python gihub.
https://github.com/Unidata/netcdf4-python

> 
> I have an issue using the NetCDF4 python library, and I am hoping you guys 
> can help me with it. I am trying to read the variable attributes from the 
> following file: 
> https://oco2.gesdisc.eosdis.nasa.gov/data/s4pa/OCO2_DATA/OCO2_L2_Lite_FP.8r/2018/oco2_LtCO2_180117_B8100r_180221182228s.nc4
> 
> As an example, I am trying to read the attributes for the variable 
> vertex_longitude. (It fails for the rest, as well.) When I use the latest 
> netCDF4 python in conda, I get:
> 
> >>> print dataset.variables['vertex_longitude']
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> File "netCDF4.pyx", line 2302, in netCDF4.Variable.__str__ (netCDF4.c:25699)
> File "netCDF4.pyx", line 2307, in netCDF4.Variable.__unicode__ 
> (netCDF4.c:25941)
> File "netCDF4.pyx", line 2426, in netCDF4.Variable.getncattr (netCDF4.c:27513)
> File "netCDF4.pyx", line 934, in netCDF4._get_att (netCDF4.c:12165)
> KeyError: 'attribute units has unsupported datatype
> 
> 
> This is surprising given that when I use the ncdump in conda, I see the 
> attributes fine:
> 
> >/opt/anaconda/bin/ncdump -h copy.nc4 | grep vertex_longitude
> float vertex_longitude(sounding_id, vertices) ;
> string vertex_longitude:units = "degrees_east" ;
> string vertex_longitude:long_name = "vertex_longitude" ;
> vertex_longitude:missing_value = -999999.f ;
> string vertex_longitude:comment = "corner longitudes of the measurement FOV" ;
> 
> 
> When I h5dump this variable, I see:
> 
> /opt/anaconda/bin/h5dump -A -d /vertex_longitude 
> oco2_LtCO2_180117_B8100r_180221182228s.nc4
> HDF5 "oco2_LtCO2_180117_B8100r_180221182228s.nc4" {
> DATASET "/vertex_longitude" {
> DATATYPE  H5T_IEEE_F32LE
> DATASPACE  SIMPLE { ( 193218, 4 ) / ( 193218, 4 ) }
> ATTRIBUTE "DIMENSION_LIST" {
> DATATYPE  H5T_VLEN { H5T_REFERENCE { H5T_STD_REF_OBJECT }}
> DATASPACE  SIMPLE { ( 2 ) / ( 2 ) }
> DATA {
> (0): (DATASET 7216 /sounding_id ), (DATASET 8414 /vertices )
> }
> }
> ATTRIBUTE "comment" {
> DATATYPE  H5T_STRING {
> STRSIZE H5T_VARIABLE;
> STRPAD H5T_STR_NULLTERM;
> CSET H5T_CSET_UTF8;
> CTYPE H5T_C_S1;
> }
> DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
> DATA {
> (0): "corner longitudes of the measurement FOV"
> }
> }
> ATTRIBUTE "long_name" {
> DATATYPE  H5T_STRING {
> STRSIZE H5T_VARIABLE;
> STRPAD H5T_STR_NULLTERM;
> CSET H5T_CSET_UTF8;
> CTYPE H5T_C_S1;
> }
> DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
> DATA {
> (0): "vertex_longitude"
> }
> }
> ATTRIBUTE "missing_value" {
> DATATYPE  H5T_IEEE_F32LE
> DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
> DATA {
> (0): -999999
> }
> }
> ATTRIBUTE "units" {
> DATATYPE  H5T_STRING {
> STRSIZE H5T_VARIABLE;
> STRPAD H5T_STR_NULLTERM;
> CSET H5T_CSET_UTF8;
> CTYPE H5T_C_S1;
> }
> DATASPACE  SIMPLE { ( 1 ) / ( 1 ) }
> DATA {
> (0): "degrees_east"
> }
> }
> }
> }
> 
> Could you tell me a way that I can get the attributes form this variable in 
> python? Is there a way to directly access the methods like nc_inq_att and 
> whatnot through the python library?
> 
> Thanks,
> Paul
> 
> Paul Huwe, Ph.D.
> Senior Scientific Software Developer
> 
> GES DISC Code 610.2
> BLDG 32, S131-10
> Greenbelt, MD 20771
> (301) 614-5165
> address@hidden<mailto:address@hidden>
> 
> 
> 

=Dennis Heimbigner
  Unidata


Ticket Details
===================
Ticket ID: BSJ-787826
Department: Support netCDF
Priority: Normal
Status: Open
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.