Skip to content

Commit

Permalink
add time2nav and spec2nav functions
Browse files Browse the repository at this point in the history
  • Loading branch information
jlaehne committed Jan 3, 2025
1 parent 31924b6 commit 8a4b213
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
5 changes: 5 additions & 0 deletions doc/user_guide/streak_images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,8 @@ Similarly, the transient summed over all wavelengths is obtained by:
:width: 700
:alt: Plot of a streak camera image and its one-dimensional representations
obtained by summing over either the wavelength or time dimensions.


Iteration over the spectral or time dimension
=============================================

12 changes: 7 additions & 5 deletions lumispy/hyperspy_extension.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ signals:
signal_type: Luminescence
signal_type_aliases:
- LuminescenceSpectrum
- LumiSpectrum
signal_dimension: 1
dtype: real
lazy: False
Expand All @@ -29,6 +30,7 @@ signals:
signal_type: Luminescence
signal_type_aliases:
- LuminescenceSpectrum
- LumiSpectrum
signal_dimension: 1
dtype: real
lazy: True
Expand Down Expand Up @@ -132,19 +134,19 @@ signals:
LumiTransient:
signal_type: Transient
signal_type_aliases:
- LumiTransient
- TRLumi
- TR luminescence
- time-resolved luminescence
signal_dimension: 1
dtype: real
lazy: False
module: lumispy.signals.luminescence_transient
LazyLumiTransient:
signal_type: Transient
signal_type_aliases:
- LumiTransient
- TRLumi
- TR luminescence
- time-resolved luminescence
signal_dimension: 1
dtype: real
lazy: True
Expand All @@ -153,10 +155,10 @@ signals:
TransientSpectrumCasting: # allows casting to either Luminescence or Transient when dimensionality is reduced
signal_type: TransientSpectrum
signal_type_aliases:
- LumiTransientSpectrum
- TransientSpec
- TRLumiSpec
- TR luminescence spectrum
- time-resolved luminescence spectrum
signal_dimension: 1
dtype: real
lazy: False
Expand All @@ -165,21 +167,21 @@ signals:
LumiTransientSpectrum:
signal_type: TransientSpectrum
signal_type_aliases:
- LumiTransientSpectrum
- TransientSpec
- TRLumiSpec
- TR luminescence spectrum
- time-resolved luminescence spectrum
signal_dimension: 2
dtype: real
lazy: False
module: lumispy.signals.luminescence_transientspec
LazyLumiTransientSpectrum:
signal_type: TransientSpectrum
signal_type_aliases:
- LumiTransientSpectrum
- TransientSpec
- TRLumiSpec
- TR luminescence spectrum
- time-resolved luminescence spectrum
signal_dimension: 2
dtype: real
lazy: True
Expand Down
48 changes: 48 additions & 0 deletions lumispy/signals/luminescence_transientspec.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

from hyperspy.signals import Signal1D, Signal2D
from hyperspy._signals.lazy import LazySignal
from hyperspy.docstrings.signal import OPTIMIZE_ARG

from lumispy.signals import LumiSpectrum, LumiTransient
from lumispy.signals.common_luminescence import CommonLumi
Expand Down Expand Up @@ -69,6 +70,53 @@ class LumiTransientSpectrum(Signal2D, CommonLumi, CommonTransient):
_signal_type = "TransientSpectrum"
_signal_dimension = 2

def spec2nav(self, optimize=True):
"""Return the streak image as signal with the spectral axis as navigation
axis and the time axis as signal axis. For efficient iteration over
transients as a function of the spectral positions (e.g. for fitting
transients). By default, the method ensures the data is stored optimally,
hence often making a copy of the data.
Parameters
----------
%s
See Also
--------
lumispy.signals.LumiTransientSpectrum.time2nav
hyperspy.api.signals.BaseSignal.transpose
"""
s = self.transpose(signal_axes=[-1],optimize=optimize)
return s

spec2nav.__doc__ %= (
OPTIMIZE_ARG.replace("False", "True"),
)

def time2nav(self, optimize=True):
"""Return the streak image as signal with the time axis as navigation
axis and the spectral axis as signal axis. For efficient iteration over
spectra as a function of time (e.g. for fitting spectra). By default, the
method ensures the data is stored optimally, hence often making a copy
of the data.
Parameters
----------
%s
See Also
--------
lumispy.signals.LumiTransientSpectrum.time2nav
hyperspy.api.signals.BaseSignal.transpose
"""
s = self.transpose(signal_axes=[-2],optimize=optimize)
return s
#self.axes_manager.signal_axes[-1].navigate = True
#self.set_signal_type("LumiSpectrum")

time2nav.__doc__ %= (
OPTIMIZE_ARG.replace("False", "True"),
)

class LazyLumiTransientSpectrum(LazySignal, LumiTransientSpectrum):
"""**Lazy 2D luminescence signal class (spectral+transient/time resolved dimensions)**"""
Expand Down

0 comments on commit 8a4b213

Please sign in to comment.