lumispy.signals
1D scanning electron microscopy cathodoluminescence signal class. |
|
1D scanning transmission electron microscopy cathodoluminescence signal class. |
|
General 1D cathodoluminescence signal class. |
|
General 1D electroluminescence signal class |
|
General 1D luminescence signal class. |
|
General 1D luminescence signal class (transient/time resolved) |
|
2D luminescence signal class (spectrum+transient/time resolved dimensions) |
|
General 1D photoluminescence signal class |
Lazy 1D scanning electron microscopy cathodoluminescence signal class. The computation is delayed until explicitly requested. |
|
Lazy 1D scanning transmission electron microscopy cathodoluminescence signal class. The computation is delayed until explicitly requested. |
|
General lazy 1D cathodoluminescence signal class. The computation is delayed until explicitly requested. |
|
Lazy general 1D electroluminescence signal class The computation is delayed until explicitly requested. |
|
General lazy 1D luminescence signal class. The computation is delayed until explicitly requested. |
|
General lazy 1D luminescence signal class (transient/time resolved) The computation is delayed until explicitly requested. |
|
Lazy 2D luminescence signal class (spectral+transient/time resolved dimensions) The computation is delayed until explicitly requested. |
|
Lazy general 1D photoluminescence signal class The computation is delayed until explicitly requested. |
Modules containing the LumiSpy signals and their lazy counterparts.
- class lumispy.signals.CLSEMSpectrum(*args, **kwargs)
1D scanning electron microscopy cathodoluminescence signal class.
- correct_grating_shift(cal_factor_x_axis, corr_factor_grating, sem_magnification, **kwargs)
Applies shift caused by the grating offset wrt the scanning centre. Authorship: Gunnar Kusch (gk419@cam.ac.uk)
- Parameters:
cal_factor_x_axis – The navigation correction factor.
corr_factor_grating – The grating correction factor.
sem_magnification – The SEM (real) magnification value. For the Attolight original metadata, take the SEM.Real_Magnification value
kwargs – The parameters passed to hyperspy.align1D() function like: interpolation_method (‘linear’, ‘nearest’, ‘zero’, ‘slinear’, ‘quadratic, ‘cubic’) parallel: Bool crop, expand, fill_value …
- class lumispy.signals.CLSTEMSpectrum(*args, **kwargs)
1D scanning transmission electron microscopy cathodoluminescence signal class.
- class lumispy.signals.CLSpectrum(*args, **kwargs)
General 1D cathodoluminescence signal class.
- remove_spikes(threshold='auto', show_diagnosis_histogram=False, inplace=False, luminescence_roi=None, signal_mask=None, add_noise=False, navigation_mask=None, interactive=False, **kwargs)
HyperSpy-based spike removal tool adapted to LumiSpy to run non-interactively and without noise addition by default. Graphical interface to remove spikes from EELS spectra or luminescence data. If non-interactive, it removes all spikes.
- Parameters:
signal_mask (numpy.ndarray of bool) – Restricts the operation to the signal locations not marked as True (masked).
navigation_mask (numpy.ndarray of bool) – Restricts the operation to the navigation locations not marked as True (masked).
threshold (
'auto'or int) – ifintset the threshold value use for the detecting the spikes. If"auto", determine the threshold value as being the first zero value in the histogram obtained from thespikes_diagnosis()method.interactive (bool) – If True, remove the spikes using the graphical user interface. If False, remove all the spikes automatically, which can introduce artefacts if used with signal containing peak-like features. However, this can be mitigated by using the
signal_maskargument to mask the signal of interest.display (bool) – If True, display the user interface widgets. If False, return the widgets container in a dictionary, usually for customisation or testing.
toolkit (str, iterable of str or None) – If None (default), all available widgets are displayed or returned. If string, only the widgets of the selected toolkit are displayed if available. If an iterable of toolkit strings, the widgets of all listed toolkits are displayed or returned.
**kwargs (dict) – Keyword arguments pass to
SpikesRemoval.
See also
hyperspy.api.signals.Signal1D.spikes_diagnosis,hyperspy.api.signals.BaseSignal.remove_spikes- Parameters:
show_diagnosis_histogram (bool) – Plot or not the derivative histogram to show the magnitude of the spikes present.
inplace (bool) – If False, a new signal object is created and returned. If True, the original signal object is modified.
luminescence_roi (array) – The peak position and peak widths of the peaks in the luminescence spectrum. In the form of an array of pairwise elements [[peak1_x, peak1_width], [peak2_x, peak2_width],…] in the units of the signal axis. It creates a signal_mask protecting the peak regions. To be used instead of signal_mask.
- Returns:
Depends on inplace, returns or overwrites the CLSpectrum after spike removal.
- Return type:
None or CLSpectrum
- class lumispy.signals.ELSpectrum(*args, **kwargs)
General 1D electroluminescence signal class
- class lumispy.signals.LazyCLSEMSpectrum(*args, **kwargs)
Lazy 1D scanning electron microscopy cathodoluminescence signal class. The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.CLSEMSpectrum(data).as_lazy()
- class lumispy.signals.LazyCLSTEMSpectrum(*args, **kwargs)
Lazy 1D scanning transmission electron microscopy cathodoluminescence signal class. The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.CLSTEMSpectrum(data).as_lazy()
- class lumispy.signals.LazyCLSpectrum(*args, **kwargs)
General lazy 1D cathodoluminescence signal class. The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.CLSpectrum(data).as_lazy()
- class lumispy.signals.LazyELSpectrum(*args, **kwargs)
Lazy general 1D electroluminescence signal class The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.ELSpectrum(data).as_lazy()
- class lumispy.signals.LazyLumiSpectrum(*args, **kwargs)
General lazy 1D luminescence signal class. The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.LumiSpectrum(data).as_lazy()
- class lumispy.signals.LazyLumiTransient(*args, **kwargs)
General lazy 1D luminescence signal class (transient/time resolved) The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.LumiTransient(data).as_lazy()
- class lumispy.signals.LazyLumiTransientSpectrum(*args, **kwargs)
Lazy 2D luminescence signal class (spectral+transient/time resolved dimensions) The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.LumiTransientSpectrum(data).as_lazy()
- class lumispy.signals.LazyPLSpectrum(*args, **kwargs)
Lazy general 1D photoluminescence signal class The computation is delayed until explicitly requested.
This class is not expected to be instantiated directly, instead use:
>>> data = da.ones((10, 10)) >>> s = hs.signals.PLSpectrum(data).as_lazy()
- class lumispy.signals.LumiSpectrum(*args, **kwargs)
General 1D luminescence signal class.
- centroid(signal_range=None, **kwargs)
Find the centroid (center of mass) of a peak.
It basically represents a “weighted average” of the peak.
Notes
This function only works for a single peak. If you have multiple peaks, slice the signal beforehand or use the signal_range parameter.
TODO: Implement this function for multiple peaks (with the npeaks parameter) by finding the top 2 peaks from mean spectrum and then returning a signal with 2 com.
- Parameters:
signal_range (tuple of ints or floats, optional) – A tuple representing the indices of the signal axis (start index, end index) where the peak is located. If the tuple contains int, it slices on index. If the tuple contains float, it slices on signal units (default HyperSpy s.inav[:] functionality).
kwargs (dictionary) – For the scipy.interpolate.interp1d function.
- Returns:
signal – Signal object containing the center of mass for every pixel. Depending on the dimensionality the type is Signal2D or a BaseSignal (for single spectrum).
- Return type:
Signal2D, BaseSignal
- px_to_nm_grating_solver(gamma_deg, deviation_angle_deg, focal_length_mm, ccd_width_mm, grating_central_wavelength_nm, grating_density_gr_mm, inplace=False)
Convert signal axis of 1D signal (in pixels) to wavelength, solving the grating equation. See lumispy.axes.solve_grating_equation for more details.
- Parameters:
gamma_deg (float) – Inclination angle between the focal plane and the centre of the grating (found experimentally from calibration). In degree.
deviation_angle_deg (float) – Also known as included angle. It is defined as the difference between angle of diffraction (\(\beta\)) and angle of incidence (\(\alpha\)). Given by manufacturer specsheet. In degree.
focal_length_mm (float) – Given by manufacturer specsheet. In mm.
ccd_width_mm (float) – The width of the CDD. Given by manufacturer specsheet. In mm.
grating_central_wavelength_nm (float) – Wavelength at the centre of the grating, where exit slit is placed. In nm.
grating_density_gr_mm (int) – Grating density in gratings per mm.
inplace (bool) – If False, it returns a new object with the transformation. If True, the original object is transformed, returning no object.
- Returns:
signal – A signal with calibrated wavelength units.
- Return type:
Examples
>>> s = LumiSpectrum(np.ones(20),)) >>> s.px_to_nm_grating_solver(*params, inplace=True) >>> s.axes_manager.signal_axes[0].units == 'nm'
- remove_background_from_file(background=None, inplace=False, **kwargs)
Subtract the background to the signal in all navigation axes. If no background file is passed as argument, the remove_background() from HyperSpy is called with the GUI.
- Parameters:
background (array shape (2, n) or Signal1D) – An array containing the background x-axis and the intensity values [[xs],[ys]] or a Signal1D object. If the x-axis values do not match the signal_axes, then interpolation is done before subtraction. If only the intensity values are provided, [ys], the functions assumes no interpolation needed.
inplace (boolean) – If False, it returns a new object with the transformation. If True, the original object is transformed, returning no object.
- Returns:
signal – A background subtracted signal.
- Return type:
Notes
This function does not work with non-uniform axes.
- savetxt(filename, fmt='%.5f', delimiter='\t', axes=True, transpose=False, **kwargs)
Write luminescence spectrum object to simple text file.
Writes single spectra to a two-column data file with signal axis as X and data as Y. Writes linescan data to file with signal axis as first row and navigation axis as first column (flipped if transpose=True).
- Parameters:
filename (string)
fmt (str or sequence of strs, optional) – A single or sequence of format strings. Default is ‘%.5f’.
delimiter (str, optional) – String or character separating columns. Default is ‘,’
axes (bool, optional) – If True (default), include axes in saved file. If False, save the data array only.
transpose (bool, optional) – If True, transpose data array and exchange axes. Default is false. Ignored for single spectra.
**kwargs – Takes any additional arguments of numpy.loadtxt, e.g. newline header, footer, comments, or encoding.
See also
numpy.savetxtExamples
>>> import lumispy as lum >>> import numpy as np ... >>> # Spectrum: >>> S = lum.signals.LumiSpectrum(np.arange(5)) >>> S.savetxt('spectrum.txt') 0.00000 0.00000 1.00000 1.00000 2.00000 2.00000 3.00000 3.00000 4.00000 4.00000 ... >>> # Linescan: >>> L = lum.signals.LumiSpectrum(np.arange(25).reshape((5,5))) >>> L.savetxt('linescan.txt') 0.00000 0.00000 1.00000 2.00000 3.00000 4.00000 0.00000 0.00000 5.00000 10.00000 15.00000 20.00000 1.00000 1.00000 6.00000 11.00000 16.00000 21.00000 2.00000 2.00000 7.00000 12.00000 17.00000 22.00000 3.00000 3.00000 8.00000 13.00000 18.00000 23.00000 4.00000 4.00000 9.00000 14.00000 19.00000 24.00000
- to_array(axes=True, transpose=False)
Return luminescence spectrum object as numpy array.
Returns single spectra as two-column array. Returns linescan data as array with signal axis as first row and navigation axis as first column (flipped if transpose=True).
- Parameters:
axes (bool, optional) – If True (default), include axes in array. If False, return the data array only.
transpose (bool, optional) – If True, transpose data array and exchange axes. Default is false. Ignored for single spectra.
**kwargs – Takes any additional arguments of numpy.loadtxt, e.g. newline header, footer, comments, or encoding.
Notes
The output of this function can be used to convert a signal object to a pandas dataframe, e.g. using df = pd.Dataframe(S.to_array()).
Examples
>>> import lumispy as lum >>> import numpy as np ... >>> # Spectrum: >>> S = lum.signals.LumiSpectrum(np.arange(5)) >>> S.to_array() array([[0., 0.], [1., 1.], [2., 2.], [3., 3.], [4., 4.]]) ... >>> # Linescan: >>> L = lum.signals.LumiSpectrum(np.arange(25).reshape((5,5))) >>> L.to_array() array([[ 0., 0., 1., 2., 3., 4.], [ 0., 0., 1., 2., 3., 4.], [ 1., 5., 6., 7., 8., 9.], [ 2., 10., 11., 12., 13., 14.], [ 3., 15., 16., 17., 18., 19.], [ 4., 20., 21., 22., 23., 24.]])
- class lumispy.signals.LumiTransient(*args, **kwargs)
General 1D luminescence signal class (transient/time resolved)
- class lumispy.signals.LumiTransientSpectrum(*args, **kwargs)
2D luminescence signal class (spectrum+transient/time resolved dimensions)
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 that the data is stored optimally, hence often making a copy of the data.
- Parameters:
optimize (bool) – If
True, the location of the data in memory is optimised for the fastest iteration over the navigation axes. This operation can cause a peak of memory usage and requires considerable processing times for large datasets and/or low specification hardware. See the Transposing (changing signal spaces) section of the HyperSpy user guide for more information. When operating on lazy signals, ifTrue, the chunks are optimised for the new axes configuration.- Returns:
signal – A signal of type
LumiTransient.- Return type:
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 that the data is stored optimally, hence often making a copy of the data.
- Parameters:
optimize (bool) – If
True, the location of the data in memory is optimised for the fastest iteration over the navigation axes. This operation can cause a peak of memory usage and requires considerable processing times for large datasets and/or low specification hardware. See the Transposing (changing signal spaces) section of the HyperSpy user guide for more information. When operating on lazy signals, ifTrue, the chunks are optimised for the new axes configuration.- Returns:
signal – A signal of type
LumiSpectrum.- Return type:
- class lumispy.signals.PLSpectrum(*args, **kwargs)
General 1D photoluminescence signal class