[Thread Prev][Thread Next][Index]

Re: [ferret_users] replace fillvalue with NaN ?



Hi Ryo,
Ferret does not generate Nan's. A 0/0 will be replaced with the default missing-data flag of -1.e34.

For a netCDF file which has NaN as the missing-data flag, Ferret notes that and applies code to internally replace the NaN's with that flag. In addition a number of files use NaN as the fill but don't set a missing_value or _FillValue flag, and Ferret handles those in the same way.

Ideally we would do the reverse and write NaN's to the file on output when requested, but Ferret does not currently do that.

Ansley


On 4/19/2016 12:05 AM, Ryo Furue wrote:
Hi Ferret users,

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

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