lumispy.utils.signals module

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.

Parameters:
  • 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.

Returns:

center_of_mass – The centroid of the spectrum.

Return type:

float

Examples

# 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]
lumispy.utils.signals.crop_edges(S, crop_range=None, rebin_nav=False, **kwargs)

Crop edges along the navigation axes of a signal or of a list of signal objects.

Crop the amount of pixels from the four edges of the scanning region, from the edges inwards.

Cropping can happen uniformly on all sides or by specifying the cropping range for each axis or each side independently.

If the shape of the navigation axes differs between the signals, all signals can be rebinned to match the shape of the first signal in the list.

Parameters:
  • S (Signal or list of Signals) – HyperSpy signal object(s) that should be cropped.

  • crop_range ({int | float | str} or tuple of {ints | floats | strs}) – If int the values are taken as indices. If float the values are converted to indices. If str, HyperSpy fancy indexing is used (e.g. rel0.1 will crop 10% on each side, or 100 nm will crop 100 nm on each side). If a number or a tuple of size 1 is passed, all sides are cropped by the same amount. If a tuple of size 2 is passed (crop_x, crop_y), a different amount is cropped from the x and y directions, respectively. If a tuple of size 4 is passed (crop_left, crop_bottom, crop_right, crop_top), a different amount is cropped from each edge individually.

  • rebin_nav (bool) – If the shape of the navigation axes differs between the signals, all signals can be be rebinned to match the shape of the first signal in the list. Note this does not take into account the calibration values of the navigation axes.

  • kwargs – To account for the deprecated crop_px parameter.

Returns:

S_cropped – A list of smaller, cropped Signal objects or a cropped single Signal if only one signal object is passed as input.

Return type:

Signal or list of Signals