[Numpy-discussion] blank values '--'
David Brown
dbrown@ucar....
Thu Feb 24 12:18:23 CST 2011
Hi Bryan,
By default PyNIO returns a NumPy masked array if a _FillValue attribute is found for the variable you are trying to load. It looks like Pauli Virtenen has pointed to the relevant NumPy documentation. Using masked array methods you can discover the values that are masked and print as '--'. From PyNIO it is also possible to control the creation of masked arrays from your
data files. See http://www.pyngl.ucar.edu/Nio.shtml under Class NioOptions / generic options / MaskedArrayMode. You can indeed create a regular non-masked NumPy array if you set
the MaskedArrayMode option to 'MaskedNever'. However, this will give you an array with 1e20 (in the case of GRIB files) in all the locations where you now see a '--'. You can of course change this to something else using the 'where' construct.
-dave
On Feb 24, 2011, at 11:00 AM, Bryan Woods wrote:
> Hello,
>
> I am loading in data from the GRIB2 files using PyNIO. Once I load them into numpy arrays I am left with a halo of values near the array boundaries that appear to be empty. When I print them or use them in conditional statements I see values of '--'. I'd like to turn these values into zeroes at the very least.
>
> As an example if I print the array I see:
>
> [[-- -- -- ..., -- -- --]
> [-- -- -- ..., -- -- --]
> [-- -- -- ..., -- -- --]
> ...,
> [-- -- -- ..., -- -- --]
> [-- -- -- ..., -- -- --]
> [-- -- -- ..., -- -- --]]
>
> though I know that there are valid values in the interior of the domain which plot properly.
>
> I can't find anything in the numpy documentation that addresses this type of missing value. Has anyone dealt with this before?
>
> Thanks,
> Bryan
> <bwoods.vcf>_______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
More information about the NumPy-Discussion
mailing list