Re: Can _FillValue as NaN work as i/p to functions?

From: Mary Haley <haley_at_nyahnyahspammersnyahnyah>
Date: Mon Jun 18 2012 - 12:40:40 MDT

Hi Paul,

No, unfortunately "NaN" is not a valid value to use as a _FillValue or as a regular value when calling computational or plotting routines in NCL. You must first convert the NaN values to missing values, and then set _FillValue to a missing value, like "1e20".

To do this, use the "replace_ieeenan" function to convert the NaNs to missing values. You can optionally use "isnan_ieee" to first determine if any of your values are equal to NaN:

If "x" already has a _FillValue attribute:

  if (any(isnan_ieee(x))) then
    replace_ieeenan (x, x@_FillValue, 0)
  end if

If "x" doesn't have a _FillValue attribute:

  if (any(isnan_ieee(x))) then
    x@_FillValue = 1.e20 ; or whatever value you want to use
    replace_ieeenan (x, x@_FillValue, 0)
  end if

http://www.ncl.ucar.edu/Document/Functions/Built-in/isnan_ieee.shtml
http://www.ncl.ucar.edu/Document/Functions/Built-in/replace_ieeenan.shtml

--Mary

On Jun 18, 2012, at 11:10 AM, Paul Scorer wrote:

> Greetings,
>
> Another _FillValue question:
>
> Can I set _FillValue to be NaN?
>
> Certainly, this script does what you would expect:
>
> x = new ((/3,3/), float)
> x@_FillValue = sqrt(-1.0)
> x(0,0) = 42.0
> x(1,2) = 24.0
> print(x)
>
> Variable: x
> Type: float
> Total Size: 36 bytes
> 9 values
> Number of Dimensions: 2
> Dimensions and sizes: [3] x [3]
> Coordinates:
> Number Of Attributes: 1
> _FillValue : -nan
> (0,0) 42
> (0,1) -nan
> (0,2) -nan
> (1,0) -nan
> (1,1) -nan
> (1,2) 24
> (2,0) -nan
> (2,1) -nan
> (2,2) -nan
>
> [Not sure how it knows NaN is negative!!]
>
> The question is whether this will propagate meaningfully through
> functions such as wrf_user_interp(), gsn_contour_map() and
> gsn_csn_vector() ?
>
> For the record, the plot is intended to display wind vectors at a
> pressure level that happens to be below the surface. A seemingly ideal
> use for NaN :-)
>
>
> Thanks and Best Regards
>
> PaulS
>
> _______________________________________________
> ncl-talk mailing list
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk
Received on Mon Jun 18 12:40:48 2012

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2012 - 09:57:23 MDT