Packed data is stored in a netCDF file using a smaller data type than the original data, for example, packing doubles into shorts. The netCDF library itself does not do packing and unpacking, but the Java-netCDF library will do automatic unpacking, see class VariableStandardized.
scale_factor
and add_offset
, such that
unpacked_value = packed_value * scale_factor + add_offset
scale_factor
and
add_offset
attributes should be the type
that you want the unpacked data to be, typically float or double.add_offset = dataMin scale_factor = (dataMax - dataMin) / (2^n - 1)where
n
is the number
of bits of the packed (integer) data type.
packed_value = nint((unpacked_value - add_offset) / scale_factor)
1.0 / scale_factor
.variables: short data(z, y, x) ; data:scale_offset = 34.02f ; data:add_offset = 1.54f ;