⇐ ⇒

[CF-metadata] How to pack data using scale_factor and add_offset?

From: Russ Rew <russ>
Date: Tue, 11 Dec 2007 19:10:29 -0700

Hi John,
 
> When scale_factor + add_offset is used how should the data be 'rounded'
> to integers?
>
> I had a look at the CF conventions and NUG but couldn't find the
> a definitive answer.
>
> I had implicitly assumed that 'nearest integer' [NINT] is assumed (i.e.
> to best represent the unpacked data), but this is not what the NetCDF
> library would do if you passed floating point data. It would do
> the machine default (truncation or INT) I think. Other options include
> FLOOR / CEIL.

We recommend the use of NINT rather than truncation. See the short
section on packing in the Best Practices document at:

  http://www.unidata.ucar.edu/software/netcdf/docs/BestPractices.html#Packed%20Data%20Values

or the documentation in the NetCDF User's Guide on the "add_offset"
attribute, where it says:

  ... When scaled data are written, the application should first
  subtract the offset and then divide by the scale factor, rounding the
  result to the nearest integer to avoid a bias caused by truncation
  towards zero.
   
  http://www.unidata.ucar.edu/software/netcdf/docs/netcdf.html#Attribute-Conventions

--Russ
Received on Tue Dec 11 2007 - 19:10:29 GMT

This archive was generated by hypermail 2.3.0 : Tue Sep 13 2022 - 23:02:40 BST

⇐ ⇒