-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
align_zero_loss_peak should take left and right arguments for low loss spectra #7
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #7 +/- ##
==========================================
- Coverage 91.83% 88.09% -3.74%
==========================================
Files 67 67
Lines 7274 7284 +10
Branches 0 1175 +1175
==========================================
- Hits 6680 6417 -263
+ Misses 594 593 -1
- Partials 0 274 +274 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, it would be useful to add these as argument, however, it is slightly more complicated as it is currently done in this PR, in some situation it can be wrong. These argument are passed to align1D
, which used usual hyperspy syntax: axis indices (when integers are passed) or axis values (with float). However, when using calibrate the argument will convert to float when adding the mean of the zero loss peak position, which then become wrong.
In this case, because of the calibrate option, it may be good to cast int
to float
to enforce the use of axis values as oppose to axis indices.
To be consistent with other functions, such as align1D
, it may be more suitable to use start
and end
- however, it may be worth checking the syntax of other similar functions to figure out if one of the two wording is better.
It would also need some tests to cover the behaviour described above.
So I changed left and right to start and end. I think this way is more intuitive and consistent with align1D. Also I think just forcing them to be float is much easier. How do I add the tests? |
There is some guidance at https://hyperspy.org/hyperspy-doc/dev/dev_guide/testing.html#writing-tests and you can have a look at other tests which are similar: exspy/exspy/test/signals/test_eels.py Lines 128 to 194 in 7be640b
Typically, it is a matter to add tests against cases that cover the expected behaviour. |
@ericpre I am not exactly sure if this is what you mean but I added two cases to make sure the function works when start and end inputs are floats and ints. In the function both start and end should be enforced as float. |
@HanHsuanWu, thank you for your contribution. I push a few commits to do the following:
You can go through the commits to follow the various steps in case you are interested in understanding more the details. |
Thank you @ericpre. I appreciated the help very much! |
Since now exspy is split hyperspy/hyperspy#3249, I moved the PR here.
Description of the change
Adding additional description for align_zero_loss_peak and added left and right arguments.
When subpixel = True, align1D (with cross-correlation) is used. The range of align1D depends on variables "left" and "right."
Currently by default, left and right are set to be -3. and 3. I think these are in whichever unit the energy axis is in.
Thus, for low loss data that are in the units of meV being about to adjust them will be helpful.