uxarray.grid.neighbors.Neighborhood.reduce

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. func is applied as func(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 axis keyword argument. Use functools.partial to bind any further arguments.

Returns:

Reduced data as float64, with the input’s dimension order. Lazy if the input was lazy.

Return type:

UxDataArray

Examples

>>> from scipy.stats import skew  
>>> nb.reduce(uxds["psi"], skew)