xdas.average#

xdas.average(da, dim=None, weights=None, **kwargs)[source]#

Compute the weighted average along the specified dimension.

Parameters:
  • da (DataArray) – Input data.

  • dim (str, optional) – Dimension along which the weighted average is computed. If None, the weighted average of the flattened array is returned. Default is None.

  • weights (array-like, optional) – An array of weights associated with the values in da. If None, all values are assumed to have equal weight. Default is None.

  • **kwargs – Additional keyword arguments passed to the NumPy function.

Returns:

Weighted average value(s) along the specified dimension. If dim is None, a single scalar value is returned; if dim is specified, the result has the same shape as the input data.

Return type:

scalar or DataArray