- xbitinfo version:
0.1.dev587+g10a08dd
- Python version:
3.9.18
- Operating System: `macOS Sonoma Version 14.4 (23E214) (Apple M1 Processor)
Description
Was trying the xbitinfo and following the tutorial presented and when compressing the .grib datasets it seems that the compression fails as the get_keepbits function returns negative values.
What I Did
import xbitinfo as xb
import xarray as xr
dataset = xr.tutorial.load_dataset("era5-2mt-2019-03-uk.grib").astype("float32")
info_p_bit = xb.get_bitinformation(dataset, dim="longitude", implementation="python")
keepbits = xb.get_keepbits(
info_p_bit, 0.99
) # returns negative number due to lossy compression
ds_bitrounded = xb.xr_bitround(
dataset, keepbits
) # raises a warning as keepbits is negative