[Thread Prev][Thread Next][Index]

[ferret_users] Re: replace fillvalue with NaN ?



Hi again,

After posting this:

> I was wondering how to replace the "missing" value (a.k.a. "bad" value
> and fillvalue) of an existing dataset with a NaN.

Using ncatted, I was successful in replacing the _FillValue value with
a NaN in a netCDF file.  In THAT sense, I solved the above problem as
written.

But, that wasn't my real goal.  I want the result of calculations in
Ferret to include NaN's.  But, when the result is saved into a file,
the _FillValue is replaced with Ferret's default, -1e+34 :

   set data nc-file-that-uses-NaN-as-fillvalue.nc
   save/file=tmp.nc/clobber var
   list/format=STREAM/file=tmp.bin/clobber var

Both in the new netCDF file and in the plain binary file, the
fillvalue is replaced with -1e+34 .

Is is possible to output NaN ?

Without that capability, I can think of a workaround:

1) Carry out your operation in Ferret and write the result in a netCDF file;
2) Replace the fillvalue with a NaN using ncatted; and then
3) Extract the binary data from it using ncks -b .

Regards,

Ryo


>
> It seems you can replace it with anything except it's not obvious how
> to use NaN.  I'm attaching a complete example at the end of this
> message, but basically I tried this
>
>    let newvar = ifv var then var else (0/0)
>    set var/bad=NaN  newvar
>
> which doesn't work.   Perhaps 0/0 doesn't generate a NaN ?
>
> By "doesn't work", I mean that I saved the resultant variable to a
> binary file and examined its contents to see if NaN was there.  It
> wasn't.
>
> I use
>
>   FERRET v6.94
>   Darwin 14.1.0 - 02/26/15
>
> Regards,
>
> Ryo
>
> !--- replace with -123 ==> Works. ----
> set data coads_climatology
> let sst_gt20 = if sst gt 20 then sst
> let newsst = ifv sst_gt20 then sst_gt20 else (-123)
> set var/bad=-123 newsst
> save/clobber/l=1/file=tmp.nc newsst
> list/clobber/l=1/format=STREAM/file=tmp.bin newsst
>
> !--- Try to replace with NaN ==> Doesn't work. ----
> set data coads_climatology
> let sst_gt20 = if sst gt 20 then sst
> let newsst = ifv sst_gt20 then sst_gt20 else (0/0)
> set var/bad=NaN newsst
> save/clobber/l=1/file=tmp2.nc newsst
> list/clobber/l=1/format=STREAM/file=tmp2.bin newsst

[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement