EnesYildirim / netcdf4-python

Automatically exported from code.google.com/p/netcdf4-python
Other
0 stars 0 forks source link

KeyError: 'attribute title has unsupported datatype' #156

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. get this nc file (18 MB): 
ftp://ftp.ssmi.com/msu/cdr/uat4_tb_v03r03_anom_chtlt_197812_201210.nc
2. Run attached: issue.py
3.

What is the expected output? What do you see instead?
Expected:
Monthly anomalies of brightness temperatures in the Lower Troposphere on a 2.5 
degree grid
Got instead:
  File "netCDF4.pyx", line 1797, in netCDF4.Dataset.__getattr__ (netCDF4.c:19879)
  File "netCDF4.pyx", line 1742, in netCDF4.Dataset.getncattr (netCDF4.c:19161)
  File "netCDF4.pyx", line 932, in netCDF4._get_att (netCDF4.c:11573)
KeyError: 'attribute title has unsupported datatype'

What version of the product are you using? On what operating system?
Using netcdf4-python version 1.0 in Enthought Python release 7.3
Operating system: Windows XP

Please provide any additional information below.

Original issue reported on code.google.com by kylehilb...@gmail.com on 2 Jan 2013 at 10:38

Attachments:

GoogleCodeExporter commented 8 years ago
The attribute is stored as a variable length string in the netcdf file, which 
the python interface cannot handle.  I will put supporting this on my to-do 
list.  I bet this file will break a lot of clients though - variable length 
strings are a recent addition to the netcdf  format, and are not often seen in 
the wild.

Original comment by whitaker.jeffrey@gmail.com on 2 Jan 2013 at 11:39

GoogleCodeExporter commented 8 years ago
a tentative fix for this is now in SVN....

I imagine since you are on Windows, you won't be able to build from source so 
you may have to wait till the next release.

Original comment by whitaker.jeffrey@gmail.com on 3 Jan 2013 at 12:34

GoogleCodeExporter commented 8 years ago
Hi Jeff,

Thank you so much for the fast responses!  Thank you also for putting this on 
your to-do list.  I will pass your information about use of variable length 
strings to the dataset developer.

Sincerely,
Kyle.

Original comment by kylehilb...@gmail.com on 3 Jan 2013 at 5:27

GoogleCodeExporter commented 8 years ago
Kyle:  Any chance you can test my fix? 

Original comment by whitaker.jeffrey@gmail.com on 3 Jan 2013 at 6:34

GoogleCodeExporter commented 8 years ago
Only if I can do that on Windows.

Original comment by kylehilb...@gmail.com on 3 Jan 2013 at 7:13

GoogleCodeExporter commented 8 years ago
I'm unable to cythonize netCDF4.pyx. Probably the nc_get_att_string function 
needs to be added to netCDF4.pxi?

Error compiling Cython file:
------------------------------------------------------------
...
        pstring =\
        value_arr.tostring().decode(default_encoding,unicode_error).replace('\x00','')
        return pstring
    elif att_type == NC_STRING:
        if att_len == 1:
            ierr = nc_get_att_string(grp._grpid, varid, attname, &stratt)
                                   ^
------------------------------------------------------------

netCDF4.pyx:925:36: undeclared name not builtin: nc_get_att_string

Error compiling Cython file:
------------------------------------------------------------
...
        pstring =\
        value_arr.tostring().decode(default_encoding,unicode_error).replace('\x00','')
        return pstring
    elif att_type == NC_STRING:
        if att_len == 1:
            ierr = nc_get_att_string(grp._grpid, varid, attname, &stratt)
                                                                ^
------------------------------------------------------------

netCDF4.pyx:925:65: Cannot convert 'char **' to Python object

Original comment by cjgoh...@gmail.com on 9 Jan 2013 at 4:19

GoogleCodeExporter commented 8 years ago
RIght = fixed now in SVN.

Original comment by whitaker.jeffrey@gmail.com on 9 Jan 2013 at 7:34

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 7 Mar 2013 at 11:38