cf.Field._set_quantization

Field._set_quantization(quantization, copy=True)[source]

Set quantization metadata.

Quantization eliminates false precision, usually by rounding the least significant bits of floating-point mantissas to zeros, so that a subsequent compression on disk is more efficient.

Quantization metadata describes any existing quantization that has already been applied to the data. Any existing quantization metadata are automatically removed prior to the new setting. Setting quantization metadata does not change the data in any way, and will not cause the data to be quantized when written to a netCDF dataset. It is up to the user to ensure that the new quantization metadata is consistent with the data, i.e. that the data has in fact been quantized in the manner described by the new quantization metadata.

Added in version (cfdm): 1.12.2.0

Parameters:
quantization: Quantization

The new quantization metadata.

copy: bool, optional

If True (the default) then copy quantization prior to insertion.

Returns:

None

Examples

>>> f.get_quantization()
<CF Quantization: algorithm=bitgroom, quantization_nsd=4>
>>> q = f._del_quantization()
>>> print(f.get_quantization(None))
None
>>> f._set_quantization(q)
>>> f.get_quantization()
<CF Quantization: algorithm=bitgroom, quantization_nsd=4>