foxes.utils.compute_scale_and_offset(min, max, n, hasnan=True)[source]

Computes scale_factor and add_offset for packing data into n-bit integers.

Parameters

min: float

Minimum value of the data

max: float

Maximum value of the data

n: int

Number of bits for packing

hasnan: bool

NaN present in the data

Returns

scale_factor: float

The scale factor

add_offset: float

The add offset

fill_value: float

The fill value for NaN

Notes

Source: https://docs.unidata.ucar.edu/nug/current/best_practices.html