pyinterp.Histogram2D#
- pyinterp.Histogram2D(x: pyinterp.core.Axis, y: pyinterp.core.Axis, compression: int | None = None, dtype: object | None = None) object#
Create a 2D histogram for binning continuous values into a grid using TDigest.
Groups continuous values into bins located on a 2D grid. Each bin maintains statistical distributions using the TDigest algorithm for efficient quantile estimation and statistical analysis.
- Parameters:
x – Definition of the bin centers for the X axis of the grid.
y – Definition of the bin centers for the Y axis of the grid.
compression – TDigest compression parameter (default: 100). Higher values provide better accuracy at the cost of memory usage. Typical values range from 100 to 1000.
dtype – Data type for internal storage, either ‘float32’ or ‘float64’. Determines precision and memory usage. Defaults to ‘float64’.
Examples
>>> import pyinterp >>> import numpy as np >>> x = pyinterp.Axis(np.arange(0, 360, 1), period=360) >>> y = pyinterp.Axis(np.arange(-90, 90, 1)) >>> hist = pyinterp.Histogram2D(x, y)
Create with custom compression for better accuracy
>>> hist = pyinterp.Histogram2D(x, y, compression=500)
Create with float32 for reduced memory usage
>>> hist = pyinterp.Histogram2D(x, y, dtype='float32')
- Returns:
Histogram2D instance with the specified dtype.