Created
June 7, 2016 15:41
-
-
Save thomasaarholt/b4197390fc94fd415d323016bfa3f264 to your computer and use it in GitHub Desktop.
Makes the spectrum image "bss_spectra[0]" and the single spectra in "mlls_objects" the same lengths.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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