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> Size: 1kB
Dimensions:     (bitfloat64: 64)
Coordinates:
  * bitfloat64  (bitfloat64) <U3 768B '±' 'e1' 'e2' 'e3' ... 'm50' 'm51' 'm52'
    dim         <U3 12B 'lon'
Data variables:
    air         (bitfloat64) float64 512B 0.0 0.0 0.0 ... 0.002847 0.0 0.0005092
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> Size: 2kB
Dimensions:     (bitfloat64: 64, dim: 3)
Coordinates:
  * bitfloat64  (bitfloat64) <U3 768B '±' 'e1' 'e2' 'e3' ... 'm50' 'm51' 'm52'
  * dim         (dim) <U4 48B 'lat' 'lon' 'time'
Data variables:
    air         (dim, bitfloat64) float64 2kB 0.0 0.0 0.0 ... 0.0 0.0004498
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:  ...