hyperspy._signals.eels module
- class hyperspy._signals.eels.EELSSpectrum(*args, **kwargs)
Bases:
Signal1D
1D signal class for EELS spectra.
Create a Signal from a numpy array.
- Parameters
data (
numpy.ndarray
) – The signal data. It can be an array of any dimensions.axes ([dict/axes], optional) – List of either dictionaries or axes objects to define the axes (see the documentation of the
AxesManager
class for more details).attributes (dict, optional) – A dictionary whose items are stored as attributes.
metadata (dict, optional) – A dictionary containing a set of parameters that will to stores in the
metadata
attribute. Some parameters might be mandatory in some cases.original_metadata (dict, optional) – A dictionary containing a set of parameters that will to stores in the
original_metadata
attribute. It typically contains all the parameters that has been imported from the original data file.ragged (bool or None, optional) – Define whether the signal is ragged or not. Overwrite the
ragged
value in theattributes
dictionary. If None, it does nothing. Default is None.
- _are_microscope_parameters_missing(ignore_parameters=[])
Check if the EELS parameters necessary to calculate the GOS are defined in metadata. If not, in interactive mode raises an UI item to fill the values. The ignore_parameters list can be to ignore parameters.
- add_elements(elements, include_pre_edges=False)
Declare the elemental composition of the sample.
The ionisation edges of the elements present in the current energy range will be added automatically.
- Parameters
elements (tuple of strings) – The symbol of the elements. Note this input must always be in the form of a tuple. Meaning: add_elements((‘C’,)) will work, while add_elements((‘C’)) will NOT work.
include_pre_edges (bool) – If True, the ionization edges with an onset below the lower energy limit of the SI will be included
Examples
>>> s = hs.signals.EELSSpectrum(np.arange(1024)) >>> s.add_elements(('C', 'O'))
- Raises
- align_zero_loss_peak(calibrate=True, also_align=[], print_stats=True, subpixel=True, mask=None, signal_range=None, show_progressbar=None, crop=True, **kwargs)
Align the zero-loss peak.
This function first aligns the spectra using the result of estimate_zero_loss_peak_centre and afterward, if subpixel is True, proceeds to align with subpixel accuracy using align1D. The offset is automatically correct if calibrate is True.
- Parameters
calibrate (bool) – If True, set the offset of the spectral axis so that the zero-loss peak is at position zero.
also_align (list of signals) – A list containing other spectra of identical dimensions to align using the shifts applied to the current spectrum. If calibrate is True, the calibration is also applied to the spectra in the list.
print_stats (bool) – If True, print summary statistics of the ZLP maximum before the alignment.
subpixel (bool) – If True, perform the alignment with subpixel accuracy using cross-correlation.
mask (Signal1D of bool data type or bool array.) – It must have signal_dimension = 0 and navigation_shape equal to the shape of the current signal. Where mask is True the shift is not computed and set to nan.
signal_range (tuple of integers, tuple of floats. Optional) – Will only search for the ZLP within the signal_range. If given in integers, the range will be in index values. If given floats, the range will be in spectrum values. Useful if there are features in the spectrum which are more intense than the ZLP. Default is searching in the whole signal. Note that ROIs can be used in place of a tuple.
show_progressbar (None or bool) – If
True
, display a progress bar. IfNone
, the default from the preferences settings is used.crop (bool) – If True automatically crop the signal axis at both ends if needed.
- Raises
NotImplementedError – If the signal axis is a non-uniform axis.
Examples
>>> s_ll = hs.signals.EELSSpectrum(np.zeros(1000)) >>> s_ll.data[100] = 100 >>> s_ll.align_zero_loss_peak()
Aligning both the lowloss signal and another signal
>>> s = hs.signals.EELSSpectrum(np.range(1000)) >>> s_ll.align_zero_loss_peak(also_align=[s])
Aligning within a narrow range of the lowloss signal
>>> s_ll.align_zero_loss_peak(signal_range=(-10.,10.))
See also
estimate_zero_loss_peak_centre
,align1D
,estimate_shift1D.
Notes
Any extra keyword arguments are passed to align1D. For more information read its docstring.
- create_model(ll=None, auto_background=True, auto_add_edges=True, GOS=None, dictionary=None)
Create a model for the current EELS data.
- Parameters
ll (EELSSpectrum, optional) – If an EELSSpectrum is provided, it will be assumed that it is a low-loss EELS spectrum, and it will be used to simulate the effect of multiple scattering by convolving it with the EELS spectrum.
auto_background (bool, default True) – If True, and if spectrum is an EELS instance adds automatically a powerlaw to the model and estimate the parameters by the two-area method.
auto_add_edges (bool, default True) – If True, and if spectrum is an EELS instance, it will automatically add the ionization edges as defined in the Signal1D instance. Adding a new element to the spectrum using the components.EELSSpectrum.add_elements method automatically add the corresponding ionisation edges to the model.
GOS ({'hydrogenic' | 'Hartree-Slater'}, optional) – The generalized oscillation strength calculations to use for the core-loss EELS edges. If None the Hartree-Slater GOS are used if available, otherwise it uses the hydrogenic GOS.
dictionary ({None | dict}, optional) – A dictionary to be used to recreate a model. Usually generated using
hyperspy.model.as_dictionary()
- Returns
model
- Return type
EELSModel instance.
- Raises
NotImplementedError – If the signal axis is a non-uniform axis.
- edges_at_energy(energy='interactive', width=10, only_major=False, order='closest', display=True, toolkit=None)
Show EELS edges according to an energy range selected from the spectrum or within a provided energy window
- Parameters
energy ('interactive' or float) – If it is ‘interactive’, a table with edges are shown and it depends on the energy range selected in the spectrum. If it is a float, a table with edges are shown and it depends on the energy window defined by energy +/- (width/2). The default is ‘interactive’.
width (float) – Width of window, in eV, around energy in which to find nearby energies, i.e. a value of 10 eV (the default) means to search +/- 5 eV. The default is 10.
only_major (bool) – Whether to show only the major edges. The default is False.
order (str) – Sort the edges, if ‘closest’, return in the order of energy difference, if ‘ascending’, return in ascending order, similarly for ‘descending’. The default is ‘closest’.
- Returns
An interactive widget if energy is ‘interactive’, or a html-format
table or ASCII table, depends on the environment.
- estimate_elastic_scattering_intensity(threshold, show_progressbar=None)
Rough estimation of the elastic scattering intensity by truncation of a EELS low-loss spectrum.
- Parameters
threshold ({Signal1D, float, int}) – Truncation energy to estimate the intensity of the elastic scattering. The threshold can be provided as a signal of the same dimension as the input spectrum navigation space containing the threshold value in the energy units. Alternatively a constant threshold can be specified in energy/index units by passing float/int.
show_progressbar (None or bool) – If
True
, display a progress bar. IfNone
, the default from the preferences settings is used.
- Returns
I0 – The elastic scattering intensity.
- Return type
- estimate_elastic_scattering_threshold(window=10.0, tol=None, window_length=5, polynomial_order=3, start=1.0)
Calculate the first inflexion point of the spectrum derivative within a window.
This method assumes that the zero-loss peak is located at position zero in all the spectra. Currently it looks for an inflexion point, that can be a local maximum or minimum. Therefore, to estimate the elastic scattering threshold start + window must be less than the first maximum for all spectra (often the bulk plasmon maximum). If there is more than one inflexion point in energy the window it selects the smoother one what, often, but not always, is a good choice in this case.
- Parameters
window ({None, float}) – If None, the search for the local inflexion point is performed using the full energy range. A positive float will restrict the search to the (0,window] energy window, where window is given in the axis units. If no inflexion point is found in this spectral range the window value is returned instead.
tol ({None, float}) – The threshold tolerance for the derivative. If “auto” it is automatically calculated as the minimum value that guarantees finding an inflexion point in all the spectra in given energy range.
window_length (int) – If non zero performs order three Savitzky-Golay smoothing to the data to avoid falling in local minima caused by the noise. It must be an odd integer.
polynomial_order (int) – Savitzky-Golay filter polynomial order.
start (float) – Position from the zero-loss peak centre from where to start looking for the inflexion point.
- Returns
threshold – A Signal1D of the same dimension as the input spectrum navigation space containing the estimated threshold. Where the threshold couldn’t be estimated the value is set to nan.
- Return type
See also
estimate_elastic_scattering_intensity
,align_zero_loss_peak
,find_peaks1D_ohaver
,fourier_ratio_deconvolution.
Notes
The main purpose of this method is to be used as input for estimate_elastic_scattering_intensity. Indeed, for currently achievable energy resolutions, there is not such a thing as a elastic scattering threshold. Therefore, please be aware of the limitations of this method when using it.
- estimate_thickness(threshold=None, zlp=None, density=None, mean_free_path=None)
Estimates the thickness (relative and absolute) of a sample using the log-ratio method.
The current EELS spectrum must be a low-loss spectrum containing the zero-loss peak. The hyperspectrum must be well calibrated and aligned. To obtain the thickness relative to the mean free path don’t set the density and the mean_free_path.
- Parameters
threshold ({BaseSignal, float}, optional) – If the zero-loss-peak is not provided, use this energy threshold to roughly estimate its intensity by truncation. If the threshold is constant across the dataset use a float. Otherwise, provide a signal of the same dimension as the input spectrum navigation space containing the threshold value in the energy units.
zlp (BaseSignal, optional) – If not None the zero-loss peak intensity is calculated from the ZLP spectrum supplied by integration.
mean_free_path (float, optional) – The mean free path of the material in nanometers. If not provided, the thickness is given relative to the mean free path.
density (float, optional) – The density of the material in g/cm**3. This is used to estimate the mean free path when the mean free path is not known and to perform the angular corrections.
- Returns
s – The thickness relative to the MFP. It returns a Signal1D, Signal2D or a BaseSignal, depending on the current navigation dimensions.
- Return type
Notes
For details see Egerton, R. Electron Energy-Loss Spectroscopy in the Electron Microscope. Springer-Verlag, 2011.
- estimate_zero_loss_peak_centre(mask=None)
Estimate the position of the zero-loss peak.
This function provides just a coarse estimation of the position of the zero-loss peak centre by computing the position of the maximum of the spectra. For subpixel accuracy use estimate_shift1D.
- Parameters
mask (Signal1D of bool data type or bool array) – It must have signal_dimension = 0 and navigation_shape equal to the navigation shape of the current signal. Where mask is True the shift is not computed and set to nan.
- Returns
zlpc – The estimated position of the maximum of the ZLP peak.
- Return type
Signal1D subclass
Notes
This function only works when the zero-loss peak is the most intense feature in the spectrum. If it is not in most cases the spectrum can be cropped to meet this criterion. Alternatively use estimate_shift1D.
See also
estimate_shift1D
,align_zero_loss_peak
- fourier_log_deconvolution(zlp, add_zlp=False, crop=False)
Performs fourier-log deconvolution.
- Parameters
zlp (EELSSpectrum) – The corresponding zero-loss peak.
add_zlp (bool) – If True, adds the ZLP to the deconvolved spectrum
crop (bool) – If True crop the spectrum to leave out the channels that have been modified to decay smoothly to zero at the sides of the spectrum.
- Return type
An EELSSpectrum containing the current data deconvolved.
- Raises
NotImplementedError – If the signal axis is a non-uniform axis.
Notes
For details see: Egerton, R. Electron Energy-Loss Spectroscopy in the Electron Microscope. Springer-Verlag, 2011.
- fourier_ratio_deconvolution(ll, fwhm=None, threshold=None, extrapolate_lowloss=True, extrapolate_coreloss=True)
Performs Fourier-ratio deconvolution.
The core-loss should have the background removed. To reduce the noise amplification the result is convolved with a Gaussian function.
- Parameters
ll (EELSSpectrum) – The corresponding low-loss (ll) EELSSpectrum.
fwhm (float or None) – Full-width half-maximum of the Gaussian function by which the result of the deconvolution is convolved. It can be used to select the final SNR and spectral resolution. If None, the FWHM of the zero-loss peak of the low-loss is estimated and used.
threshold ({None, float}) – Truncation energy to estimate the intensity of the elastic scattering. If None the threshold is taken as the first minimum after the ZLP centre.
extrapolate_lowloss (bool) – If True the signals are extrapolated using a power law,
extrapolate_coreloss (bool) – If True the signals are extrapolated using a power law,
- Raises
NotImplementedError – If the signal axis is a non-uniform axis.
Notes
For details see: Egerton, R. Electron Energy-Loss Spectroscopy in the Electron Microscope. Springer-Verlag, 2011.
- generate_subshells(include_pre_edges=False)
Calculate the subshells for the current energy range for the elements present in self.elements
- Parameters
include_pre_edges (bool) – If True, the ionization edges with an onset below the lower energy limit of the SI will be included
- get_complementary_edges(edges, only_major=False)
Get other edges of the same element present within the energy range of the axis
- Parameters
edges (iterable) – A sequence of strings contains edges in the format of element_subshell for EELS. For example, [‘Fe_L2’, ‘O_K’]
only_major (bool) – Whether to show only the major edges. The default is False.
- Returns
complmt_edges – A list containing all the complementary edges of the same element present within the energy range of the axis
- Return type
- get_zero_loss_peak_mask(zero_loss_peak_mask_width=5.0, signal_mask=None)
Return boolean array with True value at the position of the zero loss peak. This mask can be used to restrict operation to the signal locations not marked as True (masked).
- Parameters
zero_loss_peak_mask_width (float) – Width of the zero loss peak mask.
signal_mask (bool array) – Restricts the operation to the signal locations not marked as True (masked).
- Return type
bool array
- kramers_kronig_analysis(zlp=None, iterations=1, n=None, t=None, delta=0.5, full_output=False)
Calculate the complex dielectric function from a single scattering distribution (SSD) using the Kramers-Kronig relations.
It uses the FFT method as in 1. The SSD is an EELSSpectrum instance containing SSD low-loss EELS with no zero-loss peak. The internal loop is devised to approximately subtract the surface plasmon contribution supposing an unoxidized planar surface and neglecting coupling between the surfaces. This method does not account for retardation effects, instrumental broadening and surface plasmon excitation in particles.
Note that either refractive index or thickness are required. If both are None or if both are provided an exception is raised.
- Parameters
zlp ({None, number, Signal1D}) – ZLP intensity. It is optional (can be None) if t is None and n is not None and the thickness estimation is not required. If t is not None, the ZLP is required to perform the normalization and if t is not None, the ZLP is required to calculate the thickness. If the ZLP is the same for all spectra, the integral of the ZLP can be provided as a number. Otherwise, if the ZLP intensity is not the same for all spectra, it can be provided as i) a Signal1D of the same dimensions as the current signal containing the ZLP spectra for each location ii) a BaseSignal of signal dimension 0 and navigation_dimension equal to the current signal containing the integrated ZLP intensity.
iterations (int) – Number of the iterations for the internal loop to remove the surface plasmon contribution. If 1 the surface plasmon contribution is not estimated and subtracted (the default is 1).
n ({None, float}) – The medium refractive index. Used for normalization of the SSD to obtain the energy loss function. If given the thickness is estimated and returned. It is only required when t is None.
t ({None, number, Signal1D}) – The sample thickness in nm. Used for normalization of the SSD to obtain the energy loss function. It is only required when n is None. If the thickness is the same for all spectra it can be given by a number. Otherwise, it can be provided as a BaseSignal with signal dimension 0 and navigation_dimension equal to the current signal.
delta (float) – A small number (0.1-0.5 eV) added to the energy axis in specific steps of the calculation the surface loss correction to improve stability.
full_output (bool) – If True, return a dictionary that contains the estimated thickness if t is None and the estimated surface plasmon excitation and the spectrum corrected from surface plasmon excitations if iterations > 1.
- Returns
eps (DielectricFunction instance) –
The complex dielectric function results,
contained in an DielectricFunction instance.
output (Dictionary (optional)) – A dictionary of optional outputs with the following keys
thickness
: the estimated thickness in nm calculated by normalization of the SSD (only whent
is None)surface plasmon estimation
: the estimated surface plasmon excitation (only ifiterations
> 1.)
- Raises
ValueError – If both n and t are undefined (None).
AttributeError – If the beam_energy or the collection semi-angle are not defined in metadata.
NotImplementedError – If the signal axis is a non-uniform axis.
Notes
This method is based in Egerton’s Matlab code 1 with a minor difference: the wrap-around problem when computing the FFTs is workarounded by padding the signal instead of subtracting the reflected tail.
- plot(plot_edges=False, only_edges=('Major', 'Minor'), **kwargs)
Plot the EELS spectrum. Markers indicating the position of the EELS edges can be added.
- Parameters
plot_edges ({False, True, list of string or string}) – If True, draws on s.metadata.Sample.elements for edges. Alternatively, provide a string of a single edge, or an iterable containing a list of valid elements, EELS families or edges. For example, an element should be ‘Zr’, an element edge family should be ‘Zr_L’ or an EELS edge ‘Zr_L3’.
only_edges (tuple of string) – Either ‘Major’ or ‘Minor’. Defaults to both.
kwargs – The extra keyword arguments for plot()
- plot_edges_label(edges, vertical_line_marker=None, text_marker=None)
Put the EELS edge label (vertical line segment and text box) on the signal
- Parameters
edges (dictionary) – A dictionary with the labels as keys and their energies as values. For example, {‘Fe_L2’: 721.0, ‘O_K’: 532.0}
vertical_line_marker (list) – A list contains HyperSpy’s vertical line segment marker, if None, determine from the given edges
text_marker (list) – A list contains HyperSpy’s text box marker, if None, determine from the given edges
- Raises
ValueError – If the size of edges, vertical_line_marker and text_marker do not match.
- power_law_extrapolation(window_size=20, extrapolation_size=1024, add_noise=False, fix_neg_r=False)
Extrapolate the spectrum to the right using a powerlaw.
- Parameters
window_size (int) – The number of channels from the right side of the spectrum that are used to estimate the power law parameters.
extrapolation_size (int) – Size of the extrapolation in number of channels
add_noise (bool) – If True, add poissonian noise to the extrapolated spectrum.
fix_neg_r (bool) – If True, the negative values for the “components.PowerLaw” parameter r will be flagged and the extrapolation will be done with a constant zero-value.
- Return type
A new spectrum, with the extrapolation.
- static print_edges_near_energy(energy=None, width=10, only_major=False, order='closest', edges=None)
Find and print a table of edges near a given energy that are within the given energy window.
- Parameters
energy (float) – Energy to search, in eV
width (float) – Width of window, in eV, around energy in which to find nearby energies, i.e. a value of 10 eV (the default) means to search +/- 5 eV. The default is 10.
only_major (bool) – Whether to show only the major edges. The default is False.
order (str) – Sort the edges, if ‘closest’, return in the order of energy difference, if ‘ascending’, return in ascending order, similarly for ‘descending’. The default is ‘closest’.
edges (iterable) – A sequence of edges, if provided, it overrides energy, width, only_major and order.
- Returns
A PrettyText object where its representation is ASCII in terminal and
html-formatted in Jupyter notebook
- rebin(new_shape=None, scale=None, crop=True, dtype=None, out=None)
Rebin the signal into a smaller or larger shape, based on linear interpolation. Specify either new_shape or scale. Scale of 1 means no binning and scale less than one results in up-sampling.
- Parameters
new_shape (list (of floats or integer) or None) – For each dimension specify the new_shape. This will internally be converted into a
scale
parameter.scale (list (of floats or integer) or None) – For each dimension, specify the new:old pixel ratio, e.g. a ratio of 1 is no binning and a ratio of 2 means that each pixel in the new spectrum is twice the size of the pixels in the old spectrum. The length of the list should match the dimension of the Signal’s underlying data array. Note : Only one of `scale` or `new_shape` should be specified, otherwise the function will not run
crop (bool) – Whether or not to crop the resulting rebinned data (default is
True
). When binning by a non-integer number of pixels it is likely that the final row in each dimension will contain fewer than the full quota to fill one pixel. For example, a 5*5 array binned by 2.1 will produce two rows containing 2.1 pixels and one row containing only 0.8 pixels. Selection ofcrop=True
orcrop=False
determines whether or not this “black” line is cropped from the final binned array or not. Please note that if ``crop=False`` is used, the final row in each dimension may appear black if a fractional number of pixels are left over. It can be removed but has been left to preserve total counts before and after binning.dtype ({None, numpy.dtype, "same"}) – Specify the dtype of the output. If None, the dtype will be determined by the behaviour of
numpy.sum()
, if “same”, the dtype will be kept the same. Default is None.out (
BaseSignal
(or subclasses) orNone
) – IfNone
, a new Signal is created with the result of the operation and returned (default). If a Signal is passed, it is used to receive the output of the operation, and nothing is returned.
- Returns
s – The resulting cropped signal.
- Return type
BaseSignal
(or subclass)- Raises
NotImplementedError – If trying to rebin over a non-uniform axis.
Examples
>>> spectrum = hs.signals.EDSTEMSpectrum(np.ones([4, 4, 10])) >>> spectrum.data[1, 2, 9] = 5 >>> print(spectrum) <EDXTEMSpectrum, title: dimensions: (4, 4|10)> >>> print ('Sum = ', sum(sum(sum(spectrum.data)))) Sum = 164.0
>>> scale = [2, 2, 5] >>> test = spectrum.rebin(scale) >>> print(test) <EDSTEMSpectrum, title: dimensions (2, 2|2)> >>> print('Sum = ', sum(sum(sum(test.data)))) Sum = 164.0
>>> s = hs.signals.Signal1D(np.ones((2, 5, 10), dtype=np.uint8) >>> print(s) <Signal1D, title: , dimensions: (5, 2|10)> >>> print(s.data.dtype) uint8
Use dtype=np.unit16 to specify a dtype
>>> s2 = s.rebin(scale=(5, 2, 1), dtype=np.uint16) >>> print(s2.data.dtype) uint16
Use dtype=”same” to keep the same dtype
>>> s3 = s.rebin(scale=(5, 2, 1), dtype="same") >>> print(s3.data.dtype) uint8
By default dtype=None, the dtype is determined by the behaviour of numpy.sum, in this case, unsigned integer of the same precision as the platform interger
>>> s4 = s.rebin(scale=(5, 2, 1)) >>> print(s4.data.dtype) uint64
- richardson_lucy_deconvolution(psf, iterations=15, show_progressbar=None, parallel=None, max_workers=None)
1D Richardson-Lucy Poissonian deconvolution of the spectrum by the given kernel.
- Parameters
psf (EELSSpectrum) – It must have the same signal dimension as the current spectrum and a spatial dimension of 0 or the same as the current spectrum.
iterations (int) – Number of iterations of the deconvolution. Note that increasing the value will increase the noise amplification.
show_progressbar (None or bool) – If
True
, display a progress bar. IfNone
, the default from the preferences settings is used.parallel (None or bool) – If
True
, perform computation in parallel using multithreading. IfNone
, the default from the preferences settings is used. The number of threads is controlled by themax_workers
argument.max_workers (None or int) – Maximum number of threads used when
parallel=True
. If None, defaults tomin(32, os.cpu_count())
.
- Raises
NotImplementedError – If the signal axis is a non-uniform axis.
Notes
For details on the algorithm see Gloter, A., A. Douiri, M. Tence, and C. Colliex. “Improving Energy Resolution of EELS Spectra: An Alternative to the Monochromator Solution.” Ultramicroscopy 96, no. 3–4 (September 2003): 385–400.
- set_microscope_parameters(beam_energy=None, convergence_angle=None, collection_angle=None, toolkit=None, display=True)
Set the microscope parameters that are necessary to calculate the GOS.
If not all of them are defined, in interactive mode raises an UI item to fill the values.
- beam_energy: float
The energy of the electron beam in keV.
- convergence_anglefloat
The microscope convergence semi-angle in mrad.
- collection_anglefloat
The collection semi-angle in mrad.
- toolkitstr, iterable of strings 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 interable of toolkit strings, the widgets of all listed toolkits are displayed or returned.
- displaybool
If True, display the user interface widgets. If False, return the widgets container in a dictionary, usually for customisation or testing.
- spikes_diagnosis(signal_mask=None, navigation_mask=None, zero_loss_peak_mask_width=None, **kwargs)
Plots a histogram to help in choosing the threshold for spikes removal.
- Parameters
signal_mask (boolean array) – Restricts the operation to the signal locations not marked as True (masked)
navigation_mask (boolean array) – Restricts the operation to the navigation locations not marked as True (masked).
zero_loss_peak_mask_width (None or float) – If None, the zero loss peak is not masked, otherwise, use the provided value as width of the zero loss peak mask. Default is None.
**kwargs (dict) – Keyword arguments pass to
get_histogram()
See also
- spikes_removal_tool(signal_mask=None, navigation_mask=None, threshold='auto', zero_loss_peak_mask_width=None, interactive=True, display=True, toolkit=None)
Graphical interface to remove spikes from EELS spectra or luminescence data. If non-interactive, it removes all spikes and returns a ~hyperspy.signals._signal_tools.SpikesRemoval object.
- Parameters
signal_mask (bool array) – Restricts the operation to the signal locations not marked as True (masked).
navigation_mask (bool array) – Restricts the operation to the navigation locations not marked as True (masked).
threshold ('auto' or int) – if int set 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 the
spikes_diagnosis()
method.zero_loss_peak_mask_width (None or float) – If None, the zero loss peak is not masked, otherwise, use the provided value as width of the zero loss peak mask. Default is None.
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_mask argument 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 strings 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 interable of toolkit strings, the widgets of all listed toolkits are displayed or returned.
**kwargs (dict) –
- Keyword arguments pass to
SpikesRemoval()
See also
spikes_diagnosis()
- vacuum_mask(threshold=10.0, start_energy=None, closing=True, opening=False)
Generate mask of the vacuum region
- Parameters
threshold (float) – For a given navigation coordinate, mean value in the energy axis below which the pixel is considered as vacuum.
start_energy (float, None) – Minimum energy included in the calculation of the mean intensity. If None, consider only the last quarter of the spectrum to calculate the mask.
closing (bool) – If True, a morphological closing is applied to the mask.
opening (bool) – If True, a morphological opening is applied to the mask.
- Returns
mask – The mask of the region.
- Return type
signal
- class hyperspy._signals.eels.EELSTEMParametersUI(signal)
Bases:
BaseSetMetadataItems
- gui(display=True, toolkit=None, **kwargs)
Display or return interactive GUI element if available.
- Parameters
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 strings 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 interable of toolkit strings, the widgets of all listed toolkits are displayed or returned.
- class hyperspy._signals.eels.LazyEELSSpectrum(*args, **kwargs)
Bases:
EELSSpectrum
,LazySignal1D
Create a Signal from a numpy array.
- Parameters
data (
numpy.ndarray
) – The signal data. It can be an array of any dimensions.axes ([dict/axes], optional) – List of either dictionaries or axes objects to define the axes (see the documentation of the
AxesManager
class for more details).attributes (dict, optional) – A dictionary whose items are stored as attributes.
metadata (dict, optional) – A dictionary containing a set of parameters that will to stores in the
metadata
attribute. Some parameters might be mandatory in some cases.original_metadata (dict, optional) – A dictionary containing a set of parameters that will to stores in the
original_metadata
attribute. It typically contains all the parameters that has been imported from the original data file.ragged (bool or None, optional) – Define whether the signal is ragged or not. Overwrite the
ragged
value in theattributes
dictionary. If None, it does nothing. Default is None.