Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Please note that when reading and writing NetCDF files using software applications compliant with Unidata specifications , these should deal with "scale_factor" and "add_offset" automatically, making unpacking (read) and packing (write) completely transparent to the user. This means that the user always sees the unpacked data values and doesn't have to deal with "scale_factor" and "add_offset" directly.

However, please be aware that these factors can be the source of some confusion as the software application might display the values of "scale_factor" and "add_offset" for reference, similar to a ZIP compression software displaying the compression factor.


For example:

  • Matlab (ncread, ncwrite) applies "scale_factor" and "add_offset" automatically
  • R (ncvar_get) applies "scale_factor" and "add_offset" automatically
  • Panoply applies "scale_factor" and "add_offset" automatically. It also displays the values of "scale_factor" and "add_offset", causing many users to believe they have to calculate something - no, you don't.
  • Metview from version 5 onwards applies "scale_factor" and "add_offset" automatically; Metview 4.x does not.
  • The Unidata NetCDF4 module for Python (which is an interface to the NetCDF C library) applies the values of "scale_factor" and "add_offset" automatically

The above is how application software should be implemented, i.e. to show unpacked data values.

Some software applications might be implemented differently and display the packed data values. In this case the user has to calculate the unpacked values using scale_factor and add_offset, using these formulae:

  • unpacked_data_value = (packed_data_value * scale_factor) + add_offset
  • packed_data_value = nint((unpacked_data_value - add_offset) / scale_factor)

In any case we strongly recommend you check your processing software's documentation on how it deals with "scale_factor" and "add_offset", and if at all possible, unpack the data as described above before using the files.

...