uxarray.grid.neighbors.Neighborhood.reduce#
- Neighborhood.reduce(uxda, func)#
Reduces each neighborhood with an arbitrary callable.
This is the escape hatch for reductions with no method of their own.
funcis applied asfunc(values, axis=-1)over a block whose last axis is the neighborhood, once per grid element, in Python — which is considerably slower than the compiled methods above. Prefer a method where one exists.- Parameters:
uxda (UxDataArray) – Data to reduce.
func (Callable) – Reduction to apply. Must accept an
axiskeyword argument. Usefunctools.partialto bind any further arguments.
- Returns:
Reduced data as float64, with the input’s dimension order. Lazy if the input was lazy.
- Return type:
Examples
>>> from scipy.stats import skew >>> nb.reduce(uxds["psi"], skew)