Closed GoogleCodeExporter closed 8 years ago
The problem is that the variable has scale_factor and add_offset attributes,
but they are set to null strings. netcdf4-python tries to apply the scale and
offset to the variable, and ends up multiplying an array by a null string,
which doesn't work. You can turn this auto-scaling off and it works (see
below). netcdf4-python could check to see if scale_factor and add_offset are
valid before trying to do the re-scaling, but the fundamental problem here is a
malformed netcdf file.
from netCDF4 import Dataset
f = Dataset('g01l01s01.nc')
v = f.variables['Prz']
v.set_auto_maskandscale(False)
print v[:]
f.close()
Original comment by whitaker.jeffrey@gmail.com
on 24 Apr 2013 at 10:06
I've added code to check that the scale_factor and add_offset attributes can be
converted to floats, if they cannot a warning is issued and the the data is not
unpacked.
Original comment by whitaker.jeffrey@gmail.com
on 24 Apr 2013 at 10:23
Thank you very much. I had some vague notion that the scale_factor might have
something to do with it, and that's not the only way that particular NetCDF
file is malformed. I encountered this difficulty while working with the file's
originator to attempt to clean it up. Thanks again!
Original comment by steven.k...@gmail.com
on 25 Apr 2013 at 3:17
Original comment by whitaker.jeffrey@gmail.com
on 26 Feb 2014 at 2:04
Original issue reported on code.google.com by
steven.k...@gmail.com
on 24 Apr 2013 at 9:21Attachments: