align_zero_loss_peak erroring with IndexError: too many indices for array

54 views
Skip to first unread message

za...@berkeley.edu

unread,
Sep 30, 2016, 6:28:09 PM9/30/16
to hyperspy-users
I'm running in a jupyter notebook (anaconda 3.5, hyperspy 1.1.1):

s = hs.load('Image_77.dm3')
print(s.estimate_zero_loss_peak_centre().data)
s.plot()
s.align_zero_loss_peak()

It loads, fine, gives a correct estimate for the ZLP position, and plots well, but the align zero loss peak yields an error.  Any insight would be appreciated!

Thanks,

Zack

Output from s.align_zero_loss_peak():

Initial ZLP position statistics
-------------------------------
Summary statistics
------------------
mean:	14.600
std:	0.000

min:	14.600
Q1:	14.600
median:	14.600
Q3:	14.600
max:	14.600
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
<ipython-input-18-3bf92e26f44c> in <module>()
      2 #print(s.estimate_zero_loss_peak_centre().data)
      3 #s.plot()
----> 4 s.align_zero_loss_peak()
      5 #s.plot()

/Users/Zack/anaconda/envs/conda35/lib/python3.5/site-packages/hyperspy/_signals/eels.py in align_zero_loss_peak(self, calibrate, also_align, print_stats, subpixel, mask, signal_range, show_progressbar, **kwargs)
    293             also_align=also_align,
    294             show_progressbar=show_progressbar,
--> 295             **kwargs)
    296         zlpc = self.estimate_zero_loss_peak_centre(mask=mask)
    297         if calibrate is True:

/Users/Zack/anaconda/envs/conda35/lib/python3.5/site-packages/hyperspy/_signals/signal1d.py in align1D(self, start, end, reference_indices, max_shift, interpolate, number_of_interpolation_points, interpolation_method, crop, expand, fill_value, also_align, mask, show_progressbar)
    650             number_of_interpolation_points=number_of_interpolation_points,
    651             mask=mask,
--> 652             show_progressbar=show_progressbar)
    653         for signal in also_align + [self]:
    654             signal.shift1D(shift_array=shift_array,

/Users/Zack/anaconda/envs/conda35/lib/python3.5/site-packages/hyperspy/_signals/signal1d.py in estimate_shift1D(self, start, end, reference_indices, max_shift, interpolate, number_of_interpolation_points, mask, show_progressbar)
    551                         dat = interpolate1D(ip, dat)
    552                     shift_array[indices] = np.argmax(
--> 553                         np.correlate(ref, dat, 'full')) - len(ref) + 1
    554                 pbar.update(1)
    555 

IndexError: too many indices for array



Magnus Nord

unread,
Oct 2, 2016, 4:12:22 AM10/2/16
to hyperspy-users
Is "Image_77.dm3" a single low loss spectrum? Ergo not from a line scan or spectrum image?

If yes, this should work:

s = hs.load(['Image_77.dm3', 'Image_77.dm3'], stack=True)
print(s.estimate_zero_loss_peak_centre().data)
s.plot()
s.align_zero_loss_peak()

Which will basically treat s as a line scan consisting of two spectrums. You can convert it to a single low loss by doing: s = s.inav[0]

This is due to a bug somewhere in the function align1D, I'll make a Issue about it on the HyperSpy GitHub page.

Magnus

Zack Gainsforth

unread,
Oct 2, 2016, 10:24:27 AM10/2/16
to hypersp...@googlegroups.com
Yes, that works.

Thank you!

Zack

--
You received this message because you are subscribed to a topic in the Google Groups "hyperspy-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/hyperspy-users/VmgVelkCbiw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to hyperspy-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages