[Thread Prev][Thread Next][Index]

Re: [ferret_users] SAVE precision of var from binary data?



Hi Ansley,

The /OUTTYPE option is available for any netCDF write, regardless of the source of the data.

Yes!  But, what I was talking about is what happens when OUTTYPE is not specified.

If it's not specified, "SAVE/file=data.nc var" will write the variable in SINGLE precision, even though it's from a double-precision binary file --- which is inconsistent, because everywhere else precision defaults to double.

So, my guess is that there is somewhere in the Ferret code that defaults to single precision for netCDF write.

To apply that setting to all files written in the session.  (Often people use SET LIST/OUTTYPE=float or even /OUTTYPE=int, to save disk space when their data does not need double precision output.)  The default type for writing netCDF files is the input data type; does your data have more than 6-7 digits?  Are the data correct within Ferret when it reads from your binary file?

The original binary data is in double precision and when imported into Ferret, they have correct values.  You can actually run the sample script I attached at the end of my last message, which

1) saves Levitus temperature in a double-precision netCDF,
2) extracts the binary data from the netCDF file,
3) reads the binary data using the file/format=STREAM/type=r8 command, and
4) writes the variable in a new netCDF file, without specifying any OUTTYPE.

You can verify the variable from step (3) is correct in Ferret (except the bad value is not specified) and you can verify the netCDF file created at step (4) includes the variable in single precision, using ncdump -h .

Okay, I've improved my sample script so that it specifies the correct BAD value.  You can now easily see that the variable is correctly imported at step (3).

> set list/outtype=double 

That is a good idea, but I trust you can override it at each SAVE/OUTTYPE command or SET VAR/OUTTYPE= command, right?

Yes, I suppose that 'set list/outtype=double' should be the default initial state of Ferret until the user overrides it with her/his own set list/outtype command.

Cheers,

Ryo
---------------------------------------
set data levitus_climatology
save/clobber/file=tmp.nc/outtype=double temp[k=1,l=1]
cancel data/all
SPAWN ncks -O -C -b tmp.bin -v TEMP tmp.nc -o tmp2.nc
define axis/x=0:359:1 xax
define axis/y=-89.5:89.5:1 yax
define grid/x=xax/y=yax mygrid
file/form=STREAM/var=temp/type=r8/grid=mygrid tmp.bin
set var/bad=-10000000000 temp
save/clobber/file=tmp-new.nc temp


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

Privacy Policy | Disclaimer | Accessibility Statement