Hi,
I Recently installed the latest version of PyNIO 1.3.0b1
for Mac OS X Leopard (Intel) running Python 2.5:
PyNIO-1.3.0b1.macosx-10.5-i386-2.5.tar.gz
I was excited to learn that when reading variables from
netCDF files, Nio now returns a masked array for any var-
iable having the _FillValue or missing_value attribute
set within the input file.
When I try this, Nio still seems to return a numpy.ndarray,
instead of the desired masked array. Attached below is out-
put from my IDLE session. Could someone please help me un-
derstand what I am doing wrong?
Also, are there examples showing how to properly set the
new MaskedArrayMode options?
Thanks in advance for your help,
Daran
--
--->
Python 2.5 (r25:51918, Sep 19 2006, 08:49:13)
Type "copyright", "credits" or "license" for more information.
IPython 0.8.4 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]: import Nio as nio
In [2]: f = nio.open_file('composite.20080523.L3m_DAY_SST_4.nc', 'r')
In [3]: sst = f.variables['sst_data']
In [4]: print sst
Variable: sst_data
Type: float
Total Size: 3110400 bytes
777600 values
Number of Dimensions: 3
Dimensions and sizes: [time | 1] x [latitude | 720] x [longitude | 1080]
Coordinates:
time: [14022..14022]
latitude: [24.52084..54.47918]
longitude: [-98.47916..-53.52083]
Number of Attributes: 5
long_name : MODIS 8-day composite SST
standard_name : sea_surface_temperature
units : degC
valid_range : [-1.979918837547302, 31.75502777099609]
_FillValue : 1e+20
In [5]: s = sst.get_value()
In [6]: type(s)
Out[6]: <type 'numpy.ndarray'>
In [8]: from numpy import ma
In [9]: s = ma.masked_values(sst.get_value(), sst._FillValue) # Force
data into ma
In [10]: type(s)
Out[10]: <class 'numpy.ma.core.MaskedArray'>
<---
_______________________________________________
ncl-talk mailing list
ncl-talk_at_ucar.edu
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Fri Aug 29 2008 - 13:56:45 MDT
This archive was generated by hypermail 2.2.0 : Mon Sep 01 2008 - 06:20:11 MDT