Re: Variable full of nan's

From: David Brown <dbrown_at_nyahnyahspammersnyahnyah>
Date: Mon, 14 Jan 2008 16:03:47 -0700

Hi Jesper,

There is no question that this file does in fact contain the NaN
values that PyNIO reports.

The NetCDF ncdump utility (supplied with the NetCDF software) reports
NaNs as, in fact, does
ncview. When I display the Geopotential_height variable using ncview
I see a blue border around
the valid data in the plot. If I mouse over this area ncview says
the data value is NaN. Or you can see
the same thing by bringing up the 'edit' window.

Of course, unlike ncview, many tools, including PyNGL, do not always
handle data with NaNs very
gracefully, and therefore I suggest you use numpy to change the NaN
values to missing values.
This worked for me:

import numpy as N
var1 = N.where(N.isnan(var[:]),var._FillValue[0],var[:])


On Jan 11, 2008, at 4:10 AM, Larsen, Jesper wrote:

> Hi PyNIO people,
> I have encountered a problem when reading in one of the UNIDATA NetCDF
> example files:
> The variables (or at least some of them) seem to be full of nan's when
> reading it in using PyNIO. But if I use for example the ncview
> application they seem to contain valid data. My Nio version is
> 1.2.0 and
> my system (uname -a) is:
> Linux dmu-ws-202 #1 SMP Thu May 17 14:00:09 UTC
> 2007
> i686 i686 i386 GNU/Linux
> I have attached a script which (at least on my computer) shows the
> problem. A am wondering if this is due to a bug in PyNIO or something
> else?
> Kind regards,
> Jesper
> ---
> import Nio
> print Nio.__version__
> file = Nio.open_file('')
> var = file.variables['Geopotential_height']
> print var[:] # Full of nan's
> ---
> _______________________________________________
> pyngl-talk mailing list

pyngl-talk mailing list
Received on Mon Jan 14 2008 - 16:03:47 MST

This archive was generated by hypermail 2.2.0 : Thu Jan 31 2008 - 22:46:32 MST