- lumispy.utils.signals.com(spectrum_intensities, signal_axis, **kwargs)
Finds the centroid (center of mass) of a peak in the spectrum based from the intensity at each pixel value and its respective signal axis.
spectrum_intensities (array) – An array with the intensities of the spectrum.
signal_axis (hyperspy.axes.BaseDataAxis subclass) – A HyperSpy signal axis class containing an array with the wavelength/ energy for each intensity/signal value.
kwargs (dictionary) – For the scipy.interpolate.interp1d function.
center_of_mass – The centroid of the spectrum.
- Return type:
# Assume we have a spectrum with wavelengths and intensities >>> wavelengths = [200, 300, 400, 500, 600, 700] >>> intensities = [1, 2, 3, 2, 1, 0] >>> from hyperspy.axes import DataAxis >>> signal_axis = DataAxis(axis=wavelengths)
>>> center_of_mass = com(intensities, signal_axis) >>> print(center_of_mass) # Outputs: [400.0]