[Thread Prev][Thread Next][Index]

Re: dealing with NaN as missing values

On Oct 10,  1:29pm, Ilana Wainer wrote:
> Subject: dealing with NaN as missing values
> I guess this question popped up a while back ... How do I tell ferret 
> that NaN means missing value in a .cdf file.


Hi Ilana,

Here's a very nice summary that was provided by Steve Jewson just
a week or so ago.

You may find that all of the solutions work ... or none. Unix systems vary
in their response to untrapped NaN -- I suspect it depends on the defaults
chosen by the system developers for trapping IEEE overflows.
(BTW: I'm not fond of NaN as a missing value flag.)

	- steve


On Oct 1,  9:01am, Steve Jewson wrote:
> Subject: Re: nan values
> I've had some very helpful answers from the mailing list.
> It seems several people have had the same problem with the same
> data set...it's the levitus temperature data from benno blumenthal's
> web site.
> The answers I got were:
> 1)some c code which uses isnan to find the nan's and then replaces them
> 2)the incredible command: 
>   ncdump filename.cdf | sed -e 's/NaNf/-1.e+10g/g' -e 
>  's/FloatInf/-1.e+10/g' >temp.out
>   edit the missing value
>   and 
>   ncgen -o filename.cdf temp.out

==> there are minor variations on what will work here ... depending Sun
or DEC or whatever. For example, the ncdump utility on OSF may crash on
NetCDF files which contain NaN. On Sun this single command seems to do
the trick:

ncdump bad_file.cdf | sed -e 's/NaNf/-1.0e+10f/g' -e 's/NaN/-1.0e+10/g' | ncgen -o good_file.cdf

> 3)the idea that fortran77 can recognise nan's using:
>       real nan/Z'7fffffff'/
>       real pin/Z'7f800000'/
>       real nin/Z'ff800000'/
> 4)or that fortran can find nan's using the following:
>       if (f.eq.f) then
>         isnan=.FALSE. 
>       else
>         isnan=.TRUE. 
>       endif
> 5)I also discovered that I could eliminate the nans using ferret
>   manipulations ie
>   let zero=temp-temp    ! a flag which is zero where the data is not nan
>   let temp1 = if (zero eq 0) then temp else 9999.0 
> I've tested out 4 and found that it works. so that solves my problem. 

[Thread Prev][Thread Next][Index]

Dept of Commerce / NOAA / OAR / ERL / PMEL / TMAP

Contact Us | Privacy Policy | Disclaimer | Accessibility Statement