Retrieve information content and compress accordingly.
Project description
xbitinfo: Retrieve bitwise information content and compress accordingly
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:
- Analyse the bitwise information content of a dataset
- Decide on a threshold of real information to preserve (e.g. 99%)
- Reduce the precision of the dataset accordingly (bitrounding)
- Apply lossless compression (e.g. zlib, blosc, zstd) and store the dataset
To fullfill these steps, Xbitinfo relies on:
xarrayfor handling multi-dimensional arrays and file formats (e.g. netcdf, zarr, hdf5, grib)daskfor scaling to large datasetsBitInformation.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.numcodecsfor 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
or
conda install -c conda-forge xbitinfo-python
Installation including optional Julia backend
conda install -c conda-forge xbitinfo
or
pip install xbitinfo # julia needs to be installed manually
How to use
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
Videos
- General explanation of bitwise information content
- Xbitinfo implementation
- Compression with Varying Information Density
Julia Repository
Credits
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file xbitinfo-0.0.6.tar.gz.
File metadata
- Download URL: xbitinfo-0.0.6.tar.gz
- Upload date:
- Size: 35.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a8ca52b4c99da6331b2cc6a3114390388921e99b5b4b2f10a954d24c042ad9a4
|
|
| MD5 |
e939e780fb62926e7a58f6a8228dd0eb
|
|
| BLAKE2b-256 |
3989728dfe02a8b1b4bd3fde242c548704a4a3fdd4b49279401979343530b4a5
|
File details
Details for the file xbitinfo-0.0.6-py3-none-any.whl.
File metadata
- Download URL: xbitinfo-0.0.6-py3-none-any.whl
- Upload date:
- Size: 29.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
921fb7b010c52ff26191454402c2f771c1e5002e4915f21b8ad654d3800ede32
|
|
| MD5 |
6571b57ef4ae80f9564662659ec323b3
|
|
| BLAKE2b-256 |
0eb5cd23f9810cc861707651e94d5006e6320ba5ab5986f7b9ca4deaf04ebb6d
|