sigpyproc.io.bits#
Bit packing and unpacking functions.
This module contains functions for packing and unpacking bits.
Classes
Class to handle bits info. |
Functions
Pack 1, 2 and 4-bit data into 8-bit numpy array. |
|
Unpack 1, 2 and 4-bit data packed as 8-bit numpy array. |
- class sigpyproc.io.bits.BitsInfo(nbits, digi_sigma=NOTHING)[source]#
Bases:
objectClass to handle bits info.
- Parameters:
- Attributes:
- nbits
- digi_sigma
dtypeType of the data.
itemsizeElement size of this data-type object.
unpackWhether to unpack/pack bits.
bitfactBit factor to unpack/pack bits.
bitorderBit order of the packed data.
digi_minMinimum value used to quantize data.
digi_maxMaximum value used to quantize data.
digi_meanMean used to quantize data.
digi_scaleScale used to quantize data.
Methods
quantize(arr_norm)Quantize normalized data to given nbit-dependent mean and sigma.
to_dict()Get a dict of all property attributes.
- Raises:
ValueErrorif input
nbitsnot in [1, 2, 4, 8, 16, 32].
- nbits_to_dtype = {1: '<u1', 2: '<u1', 4: '<u1', 8: '<u1', 16: '<u2', 32: '<f4'}#
- default_sigma = {1: 0.5, 2: 1.5, 4: 6, 8: 6, 16: 6, 32: 6}#
- default_bitorder = {1: 'little', 2: 'big', 4: 'big', 8: 'invalid', 16: 'invalid', 32: 'invalid'}#
- nbits#
- digi_sigma#
- property unpack#
Whether to unpack/pack bits.
- Returns:
boolTrue if nbits in {1, 2, 4}, False otherwise.
- sigpyproc.io.bits.pack(array, nbits, packed=None, *, bitorder='big')[source]#
Pack 1, 2 and 4-bit data into 8-bit numpy array.
- Parameters:
- Returns:
- Raises:
ValueErrorif input array is not uint8 type if nbits is not 1, 2, or 4 if bitorder is not
bigorlittleif unpacked array is not of the correct size
- sigpyproc.io.bits.unpack(array, nbits, unpacked=None, *, bitorder='big')[source]#
Unpack 1, 2 and 4-bit data packed as 8-bit numpy array.
- Parameters:
- Returns:
- Raises:
ValueErrorif input array is not uint8 type if nbits is not 1, 2, or 4 if bitorder is not
bigorlittleif unpacked array is not of the correct size