EnesYildirim / netcdf4-python

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

no masked array is created when _FillValue is nan #168

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. if _FillValue is nan, then the mask should be created with 
numpy.isnan(data), instead of data==_FillValue
2. Attached file provides a provisional code suggestion

What is the expected output? What do you see instead?
With this code:

import netCDF4
ds = 
netCDF4.Dataset('http://dtvirt5.deltares.nl:8080/thredds/dodsC/opendap/tno/ahn10
0m/mv250.nc')
print ds.variables['AHN250'][0,0]
ds.close()

The output is:
nan

The expected output is:
masked_array(data = --,
             mask = True,
       fill_value = nan)

What version of the product are you using? On what operating system?
4.1.3 of Jan 14 2012 16:45:47 $

Please provide any additional information below.

Original issue reported on code.google.com by denheije...@gmail.com on 8 Mar 2013 at 2:02

Attachments:

GoogleCodeExporter commented 8 years ago
Good catch - support for NaN missing_value and _FillValue added in svn revision 
1231.  I went ahead and let the fill_value for the masked array be NaN in that 
case also (instead of the default _FillValue as in your patch) since it didn't 
seem to cause any problems in my limited testing.

Original comment by whitaker.jeffrey@gmail.com on 8 Mar 2013 at 5:06

GoogleCodeExporter commented 8 years ago
Thanks a lot. It works like a charm  now.

Original comment by denheije...@gmail.com on 12 Mar 2013 at 8:18

GoogleCodeExporter commented 8 years ago

Original comment by whitaker.jeffrey@gmail.com on 12 Mar 2013 at 3:57