-
Notifications
You must be signed in to change notification settings - Fork 18
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
Axis conversion for TransientSpec #205
Conversation
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #205 +/- ##
===========================================
- Coverage 100.00% 99.29% -0.71%
===========================================
Files 12 12
Lines 556 567 +11
===========================================
+ Hits 556 563 +7
- Misses 0 4 +4 ☔ View full report in Codecov by Sentry. |
>>> S1.to_invcm(laser=325) | ||
""" | ||
|
||
def to_invcm_relative(self, laser=None, inplace=True, jacobian=False): |
Check notice
Code scanning / CodeQL
Explicit returns mixed with implicit (fall through) returns Note
1f99632
to
7927533
Compare
c5c1ee9
to
20c32b3
Compare
3b2fc4b
to
0d2c439
Compare
0a0e021
to
330cc47
Compare
# along with LumiSpy. If not, see <https://www.gnu.org/licenses/#GPL>. | ||
|
||
import numpy as np | ||
import pytest |
Check notice
Code scanning / CodeQL
Unused import Note test
import pytest | ||
|
||
from lumispy.signals import LumiSpectrum, LumiTransient, LumiTransientSpectrum | ||
from hyperspy._signals.signal2d import Signal2D |
Check notice
Code scanning / CodeQL
Unused import Note test
|
||
from lumispy.signals import LumiSpectrum, LumiTransient, LumiTransientSpectrum | ||
from hyperspy._signals.signal2d import Signal2D | ||
from numpy.testing import assert_allclose |
Check notice
Code scanning / CodeQL
Unused import Note test
5882277
to
9b54af6
Compare
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.
I don't like the idea of introducing the concept of "hidden signal" because by design registered signal class are not hidden.
If I understand correctly, the purpose of the TransientSpectrumCasting
class is to assign to the correct class depending on the units of the last axis when converting to 1D signal. If so would it make sense to move this code to LumiTransient.__init__
and change to the Luminescence
signal type when necessary? It should work if the TransientSpec
signal type was added as an alias of the LumiTransient
class?
@ericpre I was also hesitating to introduce a 'hidden signal class', but it works like a charm - while I cannot make it work without. It is more elegant than what I proposed in #204 (comment) (and did not work), so I proposed this solution in #204 (comment) I tried again having the initialization in the |
42807f8
to
87551a9
Compare
c91e1b4
to
69cc43a
Compare
69cc43a
to
2d64d1a
Compare
2d64d1a
to
ae4def7
Compare
@ericpre do you have an idea why the changelog build displays a numba warning? See: https://lumispy--205.org.readthedocs.build/en/205/changelog.html Also, any idea on the Azure Pipelines failures? |
This is surprising that it appears there! Yes, adding numba as dependencies or using
mambaforge is deprecated, I will update what needs to be updated later today! 😉 |
b7911a4
to
fe8345b
Compare
@ericpre Do you want to have another look. |
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.
This looks good, I have some comments to improve the documentation.
import lumispy as lum
import numpy as np
data = np.arange(10*20).reshape(10, 20)
s = lum.signals.LumiTransientSpectrum(data)
s.axes_manager[-1].units = "ns"
s.axes_manager[-2].units = "nm"
s.sum(-1)
s.sum(-2)
|
||
.. image:: images/streakmap.svg | ||
:width: 700 | ||
:alt: Plot of a streak camera image and its one-dimensional representations |
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.
Is there code in lumispy that can make this figure? When I do lumispy.signals.luminescence_transientspec.LumiTransientSpectrum.plot
, I get a normal plot.
It would be good to add the code to make this figure, otherwise it should be removed?
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.
I had previously prepared this figure for illustration purposes and thought it could be useful here to show the principle. It is indeed a useful feature to generally faciliate such kind of plots and I will open an issue to implement that in a separate PR (which could probably be taken on by one of my students). Not as the standard plotting of this class, but as a separate plot function (alternative to using sum
an option to display spectra/transients for a certain range (or even an interactive span functionality can then be added later).
@@ -214,3 +224,300 @@ def normalize(self, pos=float("nan"), element_wise=False, inplace=False): | |||
s.metadata.Signal.quantity = "Normalized intensity" | |||
if not inplace: | |||
return s | |||
|
|||
def _reset_variance_linear_model(self): |
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.
Am I understanding correctly that this is simply moved around and doesn't need reviewed of the code itself?
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.
Yes, all the code pertaining to signal axis conversion is moved to the CommonLuminescence
class so that it is available also to LumiTransientSpectrum
. That was the origin of this PR and I probably should have merged that moving part in before doing the other changes to make it clearer.
I implemented your suggestions (and extended some to the rest of the documentation). Only the plot creation will need a separate PR. |
ecf514f
to
2a354b6
Compare
Description of the change
Move axis conversion code to
CommonLuminescence
class to make it available toLuminescenceTransientSpectrum
signals.Handle inheritance for slicing of
LuminescenceTransientSpectrum
:signal_type = 'TransientSpec'
(classTransientSpectrumCasting
)TransientSpec
is initialized in 1D withaxes_manager[-1].units
being a time unit, switch toLumiTransient
class, otherwise switch toLuminescence
classProgress of the PR