[Thread Prev][Thread Next][Index]

Re: [ferret_users] zero values to NaN



Hi Ansley,

Because many files written with other software use NaN for missing values, Ferret will read netCDF files that use NaN, but  when writing netCDF data, it doesn't write NaN as the missing flag.

I was just wondering about that!  On what condition does Ferret do so?

I was surprised that you can actually save variables with bad = NaN by

! FERRET V6.94   17-Aug-17
yes? set data coads_climatology
yes? let var = SST  !!!<==
yes? set var/bad=NaN var !!! <- NaN
yes? save/clobber/file=tmp.nc var
 LISTing to file tmp.nc
yes? quit
 
I examined the generated file tmp.nc with ncdump and found that NaN is correctly used as the _FillValue .

But, if the variable is defined like

yes? let var = if SST lt 25 then SST

instead of the "<==" line in the script, NaN doesn't occur in the generate netCDF file.

I think the capability to have NaN in the netCDF file is nice. I sometimes extract the binary data from a netCDF file generated by Ferret and process it with Forttan and sometimes wish NaN in it(*footnote).

Ryo
----------------
(*footnote) Normal values often suffer from the precision problem. The dataset I used above uses single precision and its _FillValue is -1.E+34 , but when ferret saves a new variable derived from one in the dataset, it saves it in double precision and the new _FillValue is -9.99999979021477E+33, not the double precision -9.9999999999999E+33 .  This makes dealing with the _FillValue somewhat cumbersome. In addition, if you write a Fortran program that reads various netCDF files and does some calculation on the variables from them, you would want to unify _FillValues to avoid a program like

   if (var1 == fillvalue1 .and. var2 == fillvalue2 .and. var3 == fillvalue3)

If the _FillValues are NaNs, you can forget about all these problems.

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

Privacy Policy | Disclaimer | Accessibility Statement