xarray_moments

PlasmaCalcs.tools.xarray_tools.xarray_sci.xarray_moments(array, dim=None)

returns Dataset of the “normalized” moments of array along dim,

with data_vars ‘moment_0’, ‘moment_1’, ‘moment_2’, where
moment_0 = sum(array) along dim
moment_1 = sum(array * x) / moment_0
moment_2 = (sum(array * x**2) / moment_0) - moment_1**2
array: xarray.DataArray
dim: str or None
dimension along which to compute the moments.
if None, array must be 1D, and uses dim = array.dims[0].