Motivated by radio astronomy, where low bitwidths are common.
Project built with pybind11. Pack/unpack code based on sigpyproc.
You can either:
-
Install numbits from PyPI with:
pip install numbits
or you can:
-
Clone this repository. and then:
-
Build shared object .so locally, using:
python setup.py build_ext -i
-
Or install the package globally, using:
python -m pip install .
or:
python setup.py install
-
import numpy as np
import numbits
a = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8], dtype='uint8')
b = numbits.unpack(a, nbits=2, bitorder="big", parallel=False)
>>> array([0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 2, 0, 0, 0, 3, 0, 0, 1, 0, 0, 0,
1, 1, 0, 0, 1, 2, 0, 0, 1, 3, 0, 0, 2, 0], dtype=uint8)