Skip to content

Commit b636e68

Browse files
kmuehlbauerdcheriankeewis
authored
add link to CF conventions on packed data in doc/user-guide/io.rst (#9045)
* add link to CF conventions on packed data in doc/user-guide/io.rst * add whats-new.rst entry * add more details to type determination * fix whats-new.rst * remove a comma --------- Co-authored-by: Deepak Cherian <[email protected]> Co-authored-by: Justus Magin <[email protected]>
1 parent b83aef6 commit b636e68

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

doc/user-guide/io.rst

+6-2
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,8 @@ read the data.
416416
Scaling and type conversions
417417
............................
418418

419-
These encoding options work on any version of the netCDF file format:
419+
These encoding options (based on `CF Conventions on packed data`_) work on any
420+
version of the netCDF file format:
420421

421422
- ``dtype``: Any valid NumPy dtype or string convertible to a dtype, e.g., ``'int16'``
422423
or ``'float32'``. This controls the type of the data written on disk.
@@ -427,14 +428,17 @@ These encoding options work on any version of the netCDF file format:
427428
output file, unless explicitly disabled with an encoding ``{'_FillValue': None}``.
428429
- ``scale_factor`` and ``add_offset``: Used to convert from encoded data on disk to
429430
to the decoded data in memory, according to the formula
430-
``decoded = scale_factor * encoded + add_offset``.
431+
``decoded = scale_factor * encoded + add_offset``. Please note that ``scale_factor``
432+
and ``add_offset`` must be of same type and determine the type of the decoded data.
431433

432434
These parameters can be fruitfully combined to compress discretized data on disk. For
433435
example, to save the variable ``foo`` with a precision of 0.1 in 16-bit integers while
434436
converting ``NaN`` to ``-9999``, we would use
435437
``encoding={'foo': {'dtype': 'int16', 'scale_factor': 0.1, '_FillValue': -9999}}``.
436438
Compression and decompression with such discretization is extremely fast.
437439

440+
.. _CF Conventions on packed data: https://cfconventions.org/cf-conventions/cf-conventions.html#packed-data
441+
438442
.. _io.string-encoding:
439443

440444
String encoding

doc/whats-new.rst

+2
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ Bug fixes
4444

4545
Documentation
4646
~~~~~~~~~~~~~
47+
- Add link to CF Conventions on packed data and sentence on type determination in doc/user-guide/io.rst (:issue:`9041`, :pull:`9045`).
48+
By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_.
4749

4850

4951
Internal Changes

0 commit comments

Comments
 (0)