|
| 1 | +import cfdm |
| 2 | + |
| 3 | + |
| 4 | +class Quantization(cfdm.Quantization): |
| 5 | + """A quantization variable. |
| 6 | +
|
| 7 | + A quantization variable describes a quantization algorithm via a |
| 8 | + collection of parameters. |
| 9 | +
|
| 10 | + The ``algorithm`` parameter names a specific quantization |
| 11 | + algorithm via one of the keys in the `algorithm_parameters` |
| 12 | + dictionary. |
| 13 | +
|
| 14 | + The ``implementation`` parameter contains unstandardised text that |
| 15 | + concisely conveys the algorithm provenance including the name of |
| 16 | + the library or client that performed the quantization, the |
| 17 | + software version, and any other information required to |
| 18 | + disambiguate the source of the algorithm employed. The text must |
| 19 | + take the form ``software-name version version-string |
| 20 | + [(optional-information)]``. |
| 21 | +
|
| 22 | + The retained precision of the algorithm is defined with either the |
| 23 | + ``quantization_nsb`` or ``quantization_nsd`` parameter. |
| 24 | +
|
| 25 | + For instance, the following parameters describe quantization via |
| 26 | + the BitRound algorithm, retaining 6 significant bits, and |
| 27 | + implemented by libnetcdf:: |
| 28 | +
|
| 29 | + >>> q = {{package}}.{{class}}( |
| 30 | + ... parameters={'algorithm': 'bitround', |
| 31 | + ... 'quantization_nsb': 6, |
| 32 | + ... 'implementation': 'libnetcdf version 4.9.4'} |
| 33 | + ... ) |
| 34 | + >>> q.parameters() |
| 35 | + {'algorithm': 'bitround', |
| 36 | + 'quantization_nsb': 6, |
| 37 | + 'implementation': 'libnetcdf version 4.9.4'} |
| 38 | +
|
| 39 | + See CF section 8.4. "Lossy Compression via Quantization". |
| 40 | +
|
| 41 | + **NetCDF interface** |
| 42 | +
|
| 43 | + {{netCDF variable}} |
| 44 | +
|
| 45 | + {{netCDF group attributes}} |
| 46 | +
|
| 47 | + .. versionadded:: NEXTVERSION |
| 48 | +
|
| 49 | + """ |
| 50 | + |
| 51 | + def __repr__(self): |
| 52 | + """Called by the `repr` built-in function. |
| 53 | +
|
| 54 | + x.__repr__() <==> repr(x) |
| 55 | +
|
| 56 | + .. versionadded:: NEXTVERSION |
| 57 | +
|
| 58 | + """ |
| 59 | + return super().__repr__().replace("<", "<CF ", 1) |
0 commit comments