pyinterp.dask.histogram2d#
- pyinterp.dask.histogram2d(x, y, z, histogram)[source]#
Accumulate values into a 2D histogram from dask arrays.
This function processes dask arrays in parallel, accumulating values into a 2D histogram based on x and y coordinates.
- Parameters:
x (dask.array.Array) – Dask array of x coordinates.
y (dask.array.Array) – Dask array of y coordinates.
z (dask.array.Array) – Dask array of values to accumulate.
histogram (core.Histogram2DHolder) – A Histogram2D instance defining the grid. A copy is made internally, so the original is not modified.
- Returns:
A new Histogram2D instance with accumulated values.
- Raises:
ImportError – If dask is not installed.
TypeError – If inputs are not dask arrays.
ValueError – If x, y, and z have different shapes.
- Return type:
core.Histogram2DHolder
Example
>>> import dask.array as da >>> import numpy as np >>> import pyinterp >>> import pyinterp.dask as dask_stats
Create histogram and data
>>> x_axis = pyinterp.Axis(np.linspace(0, 10, 11)) >>> y_axis = pyinterp.Axis(np.linspace(0, 10, 11)) >>> hist = pyinterp.Histogram2D(x_axis, y_axis)
Create dask arrays
>>> x = da.random.uniform(0, 10, size=(10000,), chunks=1000) >>> y = da.random.uniform(0, 10, size=(10000,), chunks=1000) >>> z = da.random.random((10000,), chunks=1000)
Compute histogram
>>> result = dask_stats.histogram2d(x, y, z, hist) >>> print(result.mean()) >>> print(result.quantile(0.5))