cf.Field.set_quantize_on_write¶
- Field.set_quantize_on_write(quantization=None, algorithm=None, quantization_nsd=None, quantization_nsb=None)[source]¶
Set a quantize-on-write instruction.
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.
The existence of a quantize-on-write instruction does not mean that the data in memory has been quantized, rather it means that if the data is written to a netCDF dataset with
cf.write
, then quantization will be applied to the data in the netCDF dataset on disk, leaving the data in memory unchanged.An existing quantization-on-write instruction is removed prior to the new setting.
Added in version (cfdm): 1.12.2.0
- Parameters:
- quantization:
Quantization
orNone
, optional The quantize-on-write instructions. By default, or if
None
, aQuantization
objects with no parameters is used.Its parameters may be overridden by the algorithm, quantization_nsd or quantization_nsb keywords. If the “implementation” parameter is defined then it is removed (because it will get reset during a subsequent call to
cf.write
).- algorithm:
str
orNone
, optional Set the “algorithm” parameter of quantization.
- quantization_nsd:
int
orNone
, optional Set the “quantization_nsd” parameter of quantization.
- quantization_nsb:
int
orNone
, optional Set the “quantization_nsb” parameter of quantization.
- quantization:
- Returns:
Examples
>>> f.set_quantize_on_write(algorithm='bitgroom', quantization_nsd=6)
>>> q = cf.Quantization({'algorithm': 'bitgroom', ... 'quantization_nsd': 6}) >>> f.set_quantize_on_write(q)
Use the quantization metadata from another construct, overriding its per-variable quantization parameter:
>>> q = g.get_quantization() >>> f.set_quantize_on_write(q, quantization_nsd=13)