xbitinfo.xbitinfo.get_keepbits#
- xbitinfo.xbitinfo.get_keepbits(info_per_bit, inflevel=0.99, information_filter=None, **kwargs)[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
orlist
) – Level of information that shall be preserved.Kwargs –
- threshold(` float `)defaults to
0.7
Minimum cumulative sum of information content before artificial information filter is applied.
- tolerance(` float `)defaults to
0.001
The tolerance is the value below which gradient starts becoming constant
- threshold(` float `)defaults to
- 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> Size: 28B Dimensions: (inflevel: 1) Coordinates: dim <U3 12B 'lon' * inflevel (inflevel) float64 8B 0.99 Data variables: air (inflevel) int64 8B 7 >>> xb.get_keepbits(info_per_bit, inflevel=0.99999999) <xarray.Dataset> Size: 28B Dimensions: (inflevel: 1) Coordinates: dim <U3 12B 'lon' * inflevel (inflevel) float64 8B 1.0 Data variables: air (inflevel) int64 8B 7 >>> xb.get_keepbits(info_per_bit, inflevel=1.0) <xarray.Dataset> Size: 28B Dimensions: (inflevel: 1) Coordinates: dim <U3 12B 'lon' * inflevel (inflevel) float64 8B 1.0 Data variables: air (inflevel) int64 8B 52 >>> info_per_bit = xb.get_bitinformation(ds) >>> xb.get_keepbits(info_per_bit) <xarray.Dataset> Size: 80B Dimensions: (dim: 3, inflevel: 1) Coordinates: * dim (dim) <U4 48B 'lat' 'lon' 'time' * inflevel (inflevel) float64 8B 0.99 Data variables: air (dim, inflevel) int64 24B 5 7 6