xbitinfo.xbitinfo.get_keepbits
xbitinfo.xbitinfo.get_keepbits#
- xbitinfo.xbitinfo.get_keepbits(info_per_bit, inflevel=0.99)[source]#
Get the number of mantissa bits to keep. To be used in
xbitinfo.bitround.xr_bitround()
andxbitinfo.bitround.jl_bitround()
.- Parameters
info_per_bit (
xarray.Dataset
) – Information content of each bit. This is the output fromxbitinfo.xbitinfo.get_bitinformation()
.inflevel (float or list) – Level of information that shall be preserved.
- Returns
keepbits (dict) – Number of mantissa bits to keep per variable
Example
>>> ds = xr.tutorial.load_dataset("air_temperature") >>> info_per_bit = xb.get_bitinformation(ds, dim="lon") >>> xb.get_keepbits(info_per_bit) <xarray.Dataset> Dimensions: (inflevel: 1) Coordinates: dim <U3 'lon' * inflevel (inflevel) float64 0.99 Data variables: air (inflevel) int64 7 >>> xb.get_keepbits(info_per_bit, inflevel=0.99999999) <xarray.Dataset> Dimensions: (inflevel: 1) Coordinates: dim <U3 'lon' * inflevel (inflevel) float64 1.0 Data variables: air (inflevel) int64 14 >>> xb.get_keepbits(info_per_bit, inflevel=1.0) <xarray.Dataset> Dimensions: (inflevel: 1) Coordinates: dim <U3 'lon' * inflevel (inflevel) float64 1.0 Data variables: air (inflevel) int64 23 >>> info_per_bit = xb.get_bitinformation(ds) >>> xb.get_keepbits(info_per_bit) <xarray.Dataset> Dimensions: (dim: 3, inflevel: 1) Coordinates: * dim (dim) <U4 'lat' 'lon' 'time' * inflevel (inflevel) float64 0.99 Data variables: air (dim, inflevel) int64 5 7 6