I've been looking into modifying the numcodecs bitround codec to accept a user defined function to determine the number of bits to round. namely xbitinfo.bitinformation. This would streamline the process of chunk-wise bitrounding to something like
from numcodecs import Blosc, BitRound
compressor = Blosc(cname="zstd", clevel=3)
filters = [BitRound(custom_function())]
encoding = {"precip": {"compressor": compressor, "filters": filters}}
ds.to_zarr(<file_name>, encoding=encoding)
where custom_function would essentially wrap get_bitinformation and get_keepbits. All in all, that may not offer much over your current chunk-wise approach, except enabling us to use bitinformation in pangeo-forge compression and rechunking pipelines.
Alternatively, we could add some stripped down bitinfo implementation to numcodec and avoid the need for custom_function(). I'd be happy to help with that, but I don't want to advance that without permission from the xbitinfo team. Both projects have MIT license.
I've been looking into modifying the numcodecs
bitroundcodec to accept a user defined function to determine the number of bits to round. namelyxbitinfo.bitinformation. This would streamline the process of chunk-wise bitrounding to something likewhere
custom_functionwould essentially wrapget_bitinformationandget_keepbits. All in all, that may not offer much over your current chunk-wise approach, except enabling us to usebitinformationinpangeo-forgecompression and rechunking pipelines.Alternatively, we could add some stripped down
bitinfoimplementation to numcodec and avoid the need forcustom_function(). I'd be happy to help with that, but I don't want to advance that without permission from thexbitinfoteam. Both projects have MIT license.