cmomy.wrap

Contents

cmomy.wrap#

cmomy.wrap(obj, *, mom_ndim=None, mom_axes=None, mom_dims=None, mom_params=None, dtype=None, copy=False, fastpath=False)[source]#

Wrap object with central moments class.

Overloads:

This will choose the correct wrapper class given the type of array (ndarray or xarray object).

Parameters:
Returns:

wrapped (CentralMomentsArray or CentralMomentsData) – Wrapped object. If input data is an xarray object, then return CentralMomentsData instance. Otherwise, return CentralMomentsArray instance.

Examples

>>> data = [10.0, 2.0, 3.0]
>>> wrap(data)
<CentralMomentsArray(mom_ndim=1)>
array([10.,  2.,  3.])
>>> xdata = xr.DataArray(data, dims="mom")
>>> wrap(xdata)
<CentralMomentsData(mom_ndim=1)>
<xarray.DataArray (mom: 3)> Size: 24B
array([10.,  2.,  3.])
Dimensions without coordinates: mom