anjaroesel / netcdf4-python

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

netCDF4 with |S1 datatype worked with 1.0.4 version but not for the latest #206

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
hi,

as reported here:
http://stackoverflow.com/questions/18887399/netcdf4-variable-getitem-not-impleme
nted-for-this-type

some netCDF4 files have a strange datatype |S1 for char variable.

I got one of this file and got the same error with the version 1.0.5 and 1.0.6.
File "netCDF4.pyx", line 2780, in netCDF4.Variable.__getitem__ (netCDF4.c:34558)
  File "netCDF4.pyx", line 2819, in netCDF4.Variable._toma (netCDF4.c:35257)
TypeError: Not implemented for this type

As mentioned in the forum stackoverflow, I had to go back to the 1.0.4 version 
to read the variable without error.

Could you explore more in details what is the problem ?
I attach the "strange" file to this post.

Regards

Original issue reported on code.google.com by sebastie...@gmail.com on 5 Nov 2013 at 3:46

Attachments:

GoogleCodeExporter commented 8 years ago
The problem seems to be with the automatic conversion of missing values to 
masked values. If you turn this off, like this:

>>> from netCDF4 import Dataset
>>> nc = Dataset('toto.nc')
>>> v = nc.groups['Sounding'].variables['gain']
>>> v.set_auto_maskandscale(False)
>>> v[:]
array(['H', 'H....

all is well.  On the other hand, using the default setup an error is raised

>>> v.set_auto_maskandscale(True)
>>> v[:]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "netCDF4.pyx", line 2792, in netCDF4.Variable.__getitem__ (netCDF4.c:34831)
    data = self._toma(data)
  File "netCDF4.pyx", line 2820, in netCDF4.Variable._toma (netCDF4.c:35353)
    if mval.shape == () and numpy.isnan(mval):
TypeError: Not implemented for this type

This should be easy to fix, but as a workaround you can just set the 
set_auto_maskandscale variable method to turn off auto-masking.

Original comment by whitaker.jeffrey@gmail.com on 5 Nov 2013 at 5:14

GoogleCodeExporter commented 8 years ago
Fix is now in svn.

Original comment by whitaker.jeffrey@gmail.com on 5 Nov 2013 at 5:25

GoogleCodeExporter commented 8 years ago
Thanks mate !!!

Original comment by sebastie...@gmail.com on 12 Nov 2013 at 3:03

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 26 Feb 2014 at 2:04