Skip to main content


xbitinfo: Retrieve bitwise information content and compress accordingly

DOI Binder Open In SageMaker Studio Lab CI pre-commit.ci status Documentation Status pypi Conda (channel only)

Xbitinfo analyses datasets based on their bitwise real information content and applies lossy compression accordingly. Being based on xarray it integrates seamlessly into common research workflows. Additional convienient functions help users to visualize the bitwise information content and to make informed decisions on the real information threshold that is subsequently used as the preserved precision during the compression.

Xbitinfo works in four steps:

  1. Analyse the bitwise information content of a dataset
  2. Decide on a threshold of real information to preserve (e.g. 99%)
  3. Reduce the precision of the dataset accordingly (bitrounding)
  4. Apply lossless compression (e.g. zlib, blosc, zstd) and store the dataset

To fullfill these steps, Xbitinfo relies on:

  • xarray for handling multi-dimensional arrays and file formats (e.g. netcdf, zarr, hdf5, grib)
  • dask for scaling to large datasets
  • BitInformation.jl (optional) for computing the bitwise information content based on the original Julia implementation. Continuous integration tests ensure however that the python-implementation shipped with xbitinfo result in identical results.
  • numcodecs for a wide-range of lossless compression algorithms

Overall, the package presents a pipeline to compress (climate) datasets based on the real information content.

How to install

Xbitinfo is packaged and distributed both via PyPI and conda-forge and can be installed via pip or conda respectively.

Depending on whether one wants to use the Julia implementation of the bitinformation algorithm (BitInformation.jl) or the native python implementation shipped with xbitinfo, one might choose one installation option over the other.

Pure-python installation (recommended)

pip install xbitinfo

We also maintain other dependency sets for different subsets of functionality:

pip install "xbitinfo[viz]" # Optional dependencies for visualisation
pip install "xbitinfo[io]" # Optional dependencies for IO

For conda

conda install -c conda-forge xbitinfo-python

the IO and visualisation dependencies are included by default.

Installation including optional Julia backend

conda install -c conda-forge xbitinfo

or

pip install "xbitinfo[julia]"  # julia needs to be installed manually

How to use

To install all dependencies needed to run this example,

pip install "xbitinfo[example]"

is recommended.

import xarray as xr
import xbitinfo as xb

# Define output path for compressed dataset
outpath = "example_bitrounded_compressed.nc"

# Load example dataset
# (requires pooch to be installed via e.g. `pip install pooch`)
example_dataset = "eraint_uvz"
ds = xr.tutorial.load_dataset(example_dataset)
# Step 1: analyze bitwise information content
bitinfo = xb.get_bitinformation(ds, dim="longitude", implementation="python")

# Step 2: decide on a threshold of real information to preserve (e.g. 99%)
keepbits = xb.get_keepbits(
    bitinfo, inflevel=0.99
)  # get number of mantissa bits to keep for 99% real information

# Step 3: reduce the precision of the dataset accordingly (bitrounding)
ds_bitrounded = xb.xr_bitround(
    ds, keepbits
)  # bitrounding keeping only keepbits mantissa bits

# Step 4: apply lossless compression (e.g. zlib, blosc, zstd) and store the dataset
ds_bitrounded.to_compressed_netcdf(outpath)

How the science works

Paper

Klöwer, M., Razinger, M., Dominguez, J. J., Düben, P. D., & Palmer, T. N. (2021). Compressing atmospheric data into its real information content. Nature Computational Science, 1(11), 713–724. doi: 10/gnm4jj

Schulz, H., M. Klöwer, and A. Spring. 2025. “Xbitinfo: Compressing Geospatial Data Based on Information Theory.” Journal of Open Source Software 10 (116): 9178. doi: 10.21105/joss.09178.

Videos

Julia Repository

BitInformation.jl

Credits

Metadata

Release files for xbitinfo 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for xbitinfo 0.0.7
File Size Uploaded
xbitinfo-0.0.7.tar.gz 36.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for xbitinfo 0.0.7
File Interpreter ABI Platform
xbitinfo-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 65.7 kB

Release files / xbitinfo-0.0.7.tar.gz

Download URL xbitinfo-0.0.7.tar.gz
Size 36.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7653828ad783b897ae5c076f694eb3a547dca6982da8075a8efced1b41c717ac
BLAKE2b-256 checksum
How to use checksums
7b93571a19a4e4898c16de65e35850bae157d89a8f120651c1d87882c539e5da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / xbitinfo-0.0.7-py3-none-any.whl

Download URL xbitinfo-0.0.7-py3-none-any.whl
Size 29.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d7e6729ca84fde9f6786824c9eba271fba632f37141973360af57db7002a382d
BLAKE2b-256 checksum
How to use checksums
cea96a067e83bb6cdb5a065ce91ed473cdd6dad252b8821e4597ec5baead868a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page