xbitinfo.xbitinfo.get_bitinformation#

xbitinfo.xbitinfo.get_bitinformation(ds, dim=None, axis=None, label=None, overwrite=False, **kwargs)[source]#

Wrap BitInformation.jl.bitinformation().

Parameters
  • ds (xarray.Dataset) – Input dataset to analyse

  • dim (str) – Dimension over which to apply mean. Only one of the dim and axis arguments can be supplied. If no dim or axis is given (default), the bitinformation is retrieved along all dimensions.

  • axis (int) – Axis over which to apply mean. Only one of the dim and axis arguments can be supplied. If no dim or axis is given (default), the bitinformation is retrieved along all dimensions.

  • label (str) – Label of the json to serialize bitinfo. When string, serialize results to disk into file {{label}}.json to be reused later. Defaults to None.

  • overwrite (bool) – If False, try using serialized bitinfo based on label; if true or label does not exist, run bitinformation

  • kwargs

    to be passed to bitinformation:

    • masked_value: defaults to NaN (different to bitinformation.jl defaulting to "nothing"), set None disable masking

    • mask: use masked_value instead

    • set_zero_insignificant (bool): defaults to True

    • confidence (float): defaults to 0.99

Returns

info_per_bit (xarray.Dataset) – Information content per bit and variable (and dim)

Example

>>> ds = xr.tutorial.load_dataset("air_temperature")
>>> xb.get_bitinformation(ds, dim="lon")  
<xarray.Dataset>
Dimensions:  (bit32: 32)
Coordinates:
  * bit32    (bit32) <U3 '±' 'e1' 'e2' 'e3' 'e4' ... 'm20' 'm21' 'm22' 'm23'
    dim      <U3 'lon'
Data variables:
    air      (bit32) float64 0.0 0.0 0.0 0.0 ... 0.0 3.953e-05 0.0006889
Attributes:
    xbitinfo_description:       bitinformation calculated by xbitinfo.get_bit...
    python_repository:          https://github.com/observingClouds/xbitinfo
    julia_repository:           https://github.com/milankl/BitInformation.jl
    reference_paper:            http://www.nature.com/articles/s43588-021-001...
    xbitinfo_version:           ...
    BitInformation.jl_version:  ...
>>> xb.get_bitinformation(ds)
<xarray.Dataset>
Dimensions:  (bit32: 32, dim: 3)
Coordinates:
  * bit32    (bit32) <U3 '±' 'e1' 'e2' 'e3' 'e4' ... 'm20' 'm21' 'm22' 'm23'
  * dim      (dim) <U4 'lat' 'lon' 'time'
Data variables:
    air      (dim, bit32) float64 0.0 0.0 0.0 0.0 ... 0.0 6.327e-06 0.0004285
Attributes:
    xbitinfo_description:       bitinformation calculated by xbitinfo.get_bit...
    python_repository:          https://github.com/observingClouds/xbitinfo
    julia_repository:           https://github.com/milankl/BitInformation.jl
    reference_paper:            http://www.nature.com/articles/s43588-021-001...
    xbitinfo_version:           ...
    BitInformation.jl_version:  ...