- Data.moment(axis, channel=0, moment=1, *, resultant=None)
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.
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 collapsed axis must be monotonic to produce correct results. 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
1in the dimension for which the axis is not
1) Default is 0, the first channel.
resultant (tuple of int) – The resultant shape after the moment operation. By default, it is intuited by the axis along which the moment is being taken. This default only works if that axis is 1D, so resultant is required if a multidimensional axis is passed as the first argument. The requirement of monotonicity applies on a per pixel basis.