xbitinfo.bitround.bitround_along_dim#
- xbitinfo.bitround.bitround_along_dim(ds, info_per_bit, dim, inflevels=[1.0, 0.9999, 0.99, 0.975, 0.95], keepbits=None)[source]#
Apply bitrounding on slices along dim based on inflevels. Helper function to generate data for Fig. 3 in Klöwer et al. 2021.
Klöwer, M., Razinger, M., Dominguez, J. J., Düben, P. D., & Palmer, T. N. (2021). Compressing atmospheric data into its real information content. Nature Computational Science, 1(11), 713–724. doi: 10/gnm4jj
- Parameters:
ds (
xarray.Dataset
,xarray.DataArray
) – Inputinfo_per_bit (
dict
) – Information content of each bit for each variable in ds. This is the output from get_bitinformation.dim (
str
) – Name of dimension for slicinginflevels (
list
offloats
) – Level of information that shall be preserved. Defaults to[1.0, 0.9999, 0.99, 0.975, 0.95]
.keepbits (
int
,dict
of{str: int}
,xarray.DataArray
orxarray.Dataset
) – How many bits to keep as int
- Returns:
ds (
xarray.Dataset
,xarray.DataArray
) – Bitrounded on slices alongdim
based oninflevels
- Raises:
ValueError – If both inflevels and keepbits are specified, or if neither is specified.
Example
>>> ds = xr.tutorial.load_dataset("air_temperature") >>> info_per_bit = xb.get_bitinformation(ds, dim="lon") >>> ds_bitrounded_along_lon = xb.bitround.bitround_along_dim( ... ds, info_per_bit, dim="lon" ... ) >>> (ds - ds_bitrounded_along_lon)["air"].isel(time=0).plot() <matplotlib.collections.QuadMesh object at ...>