-
-
Notifications
You must be signed in to change notification settings - Fork 323
Bit-Packing Codec for ADC Data Optimization #2942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: asim <[email protected]>
thanks for working on this. It seems like numcodecs already has a I'm not an expert but it seems to me that your PR and these other |
This would be best suited as an array-to-bytes codec (like
|
Hi @d-v-b, Thank you for your feedback and for highlighting these related implementations! You're absolutely right—the naming similarity could lead to confusion. Would Looking forward to your thoughts! |
Hii, @LDeakin Thank you for the insightful feedback! You’re absolutely right. Initially, I modeled this after Would you recommend Appreciate your guidance! |
This should definitely be an array -> bytes codec. However, potentially it could make sense to combine this with the My packbits proposal is designed to work with In contrast, your codec proposed here works with the existing whole-number-of-bytes data types and retains only the specified number of least-significant bits. Would it make sense to extend my |
Note: A separate issue is that your implementation, being pure Python that loops over each element, will surely be very slow. You will want to implement in cython or otherwise ensure the bulk of the work gets handled by optimized native code. |
Thank you for your detailed feedback, @jbms! I'll definitely refactor this as an Your suggestion about extending packbits with Regarding performance, you're absolutely right. My current implementation is a proof-of-concept focused on correctness, but production use would require optimization. I'd be interested in exploring:
|
I modified my packbits proposal to include a It is now a fair bit more complicated though --- but still it probably makes sense to keep those options integrated rather than as a separate codec. There could still be partial implementations of packbits that do not support them. |
This PR implements a prototype BitPackingCodec that efficiently stores ADC integer values (10-bit, 12-bit) that typically waste space when stored as 16-bit integers.
Key Features
Implementation Details
The codec works by:
Key algorithms:
Demo
Tried to bitpack an array of 4 values with dtype =
uint16
into 10 bitsPacking Data
Unpacking Data