Bitround

class numcodecs.bitround.BitRound(keepbits: int)[source]

Floating-point bit rounding codec

Drops a specified number of bits from the floating point mantissa, leaving an array more amenable to compression. The number of bits to keep should be determined by an information analysis of the data to be compressed. The approach is based on the paper by Klöwer et al. 2021 (https://www.nature.com/articles/s43588-021-00156-2). See https://github.com/zarr-developers/numcodecs/issues/298 for discussion and the original implementation in Julia referred to at https://github.com/milankl/BitInformation.jl

Parameters
keepbits: int

The number of bits of the mantissa to keep. The range allowed depends on the dtype input data. If keepbits is equal to the maximum allowed for the data type, this is equivalent to no transform.

codec_id = 'bitround'

Codec identifier.

encode(buf)[source]

Create int array by rounding floating-point data

The itemsize will be preserved, but the output should be much more compressible.

decode(buf, out=None)[source]

Remake floats from ints

As with encode, preserves itemsize.

get_config()

Return a dictionary holding configuration parameters for this codec. Must include an ‘id’ field with the codec identifier. All values must be compatible with JSON encoding.

classmethod from_config(config)

Instantiate codec from a configuration object.