WrightTools.data.Data.moment

Data.moment(axis, channel=0, moment=1)[source]

Take the nth moment the dataset along one axis, adding lower rank channels.

New channels have names <channel name>_<axis name>_moment_<moment num>.

Moment 0 is the integral of the slice. Moment 1 is the weighted average or “Center of Mass”, normalized by the integral Moment 2 is the variance, the central moment about the center of mass, normalized by the integral Moments 3+ are central moments about the center of mass, normalized by the integral and by the standard deviation to the power of the moment.

Moments, especially higher order moments, are susceptible to noise and baseline. It is recommended when used with real data to use WrightTools.data.Channel.clip() in conjunction with moments to reduce effects of noise.

Parameters:
  • axis (int or str) – The axis to take the moment along. If given as an integer, the axis with that index is used. If given as a string, the axis with that name is used. The axis must exist, and be a 1D array-aligned axis. (i.e. have a shape with a single value which is not 1) The axis to collapse along is inferred from the shape of the axis.
  • channel (int or str) – The channel to take the moment. If given as an integer, the channel with that index is used. If given as a string, the channel with that name is used. The channel must have values along the axis (i.e. its shape must not be 1 in the dimension for which the axis is not 1) Default is 0, the first channel.
  • moment (int or tuple of int) – The moments to take. One channel will be created for each number given. Default is 1, the center of mass.

See also

collapse()
Reduce dimensionality by some mathematical operation
clip()
Set values above/below a threshold to a particular value