Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Makes the spectrum image "bss_spectra[0]" and the single spectra in "mlls_objects" the same lengths.
# Make signal starting point and length equal
signal_min = bss_spectra[0].axes_manager[-1].axis.min() # This is a float
signal_shortest_len = len(bss_spectra[0].axes_manager[-1].axis) # This is an int
# Get largest value of s
for s in mlls_objects:
if s.axes_manager[0].axis.min() > signal_min:
signal_min = s.axes_manager[0].axis.min()
# Crop all the spectra to start at the same energy index
for i in range(len(mlls_objects)):
mlls_objects[i].crop_spectrum(signal_min, None)
bss_spectra[0].crop_spectrum(signal_min, None)
# Get shortest length of spectra
for s in mlls_objects:
if len(s.axes_manager[0].axis) < signal_shortest_len:
signal_shortest_len = len(s.axes_manager[0].axis)
# Crop all spectra to start at the signal_min index and be as long as signal_shortest_len
# I had to do use the signal_min here as well as before, as otherwise it was one short - look into later.
for i in range(len(mlls_objects)):
mlls_objects[i].crop_spectrum(signal_min, signal_shortest_len)
bss_spectra[0].crop_spectrum(signal_min, signal_shortest_len)
pp.pprint((bss_spectra[0], mlls_objects)) # Use prettyprint (pprint) to print the signals with their length
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.