xbitinfo.xbitinfo.get_bitinformation

xbitinfo.xbitinfo.get_bitinformation#

xbitinfo.xbitinfo.get_bitinformation(ds, dim=None, axis=None, label=None, overwrite=False, implementation='julia', **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

  • implementation (str) –

    Bitinformation algorithm implementation. Valid options are
    • julia, the original implementation of julia in julia by Milan Kloewer

    • python, a copy of the core functionality of julia in python

  • kwargs

    to be passed to bitinformation:

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

    • mask: use masked_value instead

    • set_zero_insignificant (bool): defaults to True (julia implementation) or False (python implementation)

    • 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:     (bitfloat32: 32)
Coordinates:
  * bitfloat32  (bitfloat32) <U3 '±' 'e1' 'e2' 'e3' ... 'm20' 'm21' 'm22' 'm23'
    dim         <U3 'lon'
Data variables:
    air         (bitfloat32) 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:     (bitfloat32: 32, dim: 3)
Coordinates:
  * bitfloat32  (bitfloat32) <U3 '±' 'e1' 'e2' 'e3' ... 'm20' 'm21' 'm22' 'm23'
  * dim         (dim) <U4 'lat' 'lon' 'time'
Data variables:
    air         (dim, bitfloat32) float64 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:  ...