hyperspy._signals.eds_tem module

class hyperspy._signals.eds_tem.EDSTEMParametersUI(signal)

Bases: hyperspy.signal.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.
mapping = {'Acquisition_instrument.TEM.Detector.EDS.azimuth_angle': 'azimuth_angle', 'Acquisition_instrument.TEM.Detector.EDS.elevation_angle': 'elevation_angle', 'Acquisition_instrument.TEM.Detector.EDS.energy_resolution_MnKa': 'energy_resolution_MnKa', 'Acquisition_instrument.TEM.Detector.EDS.live_time': 'live_time', 'Acquisition_instrument.TEM.Detector.EDS.real_time': 'real_time', 'Acquisition_instrument.TEM.Stage.tilt_alpha': 'tilt_stage', 'Acquisition_instrument.TEM.beam_current': 'beam_current', 'Acquisition_instrument.TEM.beam_energy': 'beam_energy', 'Acquisition_instrument.TEM.probe_area': 'probe_area'}
class hyperspy._signals.eds_tem.EDSTEMSpectrum(*args, **kwards)

Bases: hyperspy._signals.eds_tem.EDSTEM_mixin, hyperspy._signals.eds.EDSSpectrum

class hyperspy._signals.eds_tem.EDSTEM_mixin(*args, **kwards)

Bases: object

create_model(auto_background=True, auto_add_lines=True, *args, **kwargs)

Create a model for the current TEM EDS data.

Parameters:
  • auto_background (boolean, default True) – If True, adds automatically a polynomial order 6 to the model, using the edsmodel.add_polynomial_background method.
  • auto_add_lines (boolean, default True) – If True, automatically add Gaussians for all X-rays generated in the energy range by an element using the edsmodel.add_family_lines method.
  • dictionary ({None, dict}, optional) – A dictionary to be used to recreate a model. Usually generated using hyperspy.model.as_dictionary()
Returns:

model

Return type:

EDSTEMModel instance.

decomposition(normalize_poissonian_noise=True, navigation_mask=1.0, closing=True, *args, **kwargs)

Decomposition with a choice of algorithms

The results are stored in self.learning_results

Parameters:
  • normalize_poissonian_noise (bool) – If True, scale the SI to normalize Poissonian noise
  • navigation_mask (None or float or boolean numpy array) – The navigation locations marked as True are not used in the decomposition. If float is given the vacuum_mask method is used to generate a mask with the float value as threshold.
  • closing (bool) – If true, applied a morphologic closing to the maks obtained by vacuum_mask.
  • algorithm ('svd' | 'fast_svd' | 'mlpca' | 'fast_mlpca' | 'nmf' |) – ‘sparse_pca’ | ‘mini_batch_sparse_pca’
  • output_dimension (None or int) – number of components to keep/calculate
  • centre (None | 'variables' | 'trials') – If None no centring is applied. If ‘variable’ the centring will be performed in the variable axis. If ‘trials’, the centring will be performed in the ‘trials’ axis. It only has effect when using the svd or fast_svd algorithms
  • auto_transpose (bool) – If True, automatically transposes the data to boost performance. Only has effect when using the svd of fast_svd algorithms.
  • signal_mask (boolean numpy array) – The signal locations marked as True are not used in the decomposition.
  • var_array (numpy array) – Array of variance for the maximum likelihood PCA algorithm
  • var_func (function or numpy array) – If function, it will apply it to the dataset to obtain the var_array. Alternatively, it can a an array with the coefficients of a polynomial.
  • polyfit
  • reproject (None | signal | navigation | both) – If not None, the results of the decomposition will be projected in the selected masked area.

Examples

>>> s = hs.datasets.example_signals.EDS_TEM_Spectrum()
>>> si = hs.stack([s]*3)
>>> si.change_dtype(float)
>>> si.decomposition()

See also

vacuum_mask()

get_calibration_from(ref, nb_pix=1)

Copy the calibration and all metadata of a reference.

Primary use: To add a calibration to ripple file from INCA software

Parameters:
  • ref (signal) – The reference contains the calibration in its metadata
  • nb_pix (int) – The live time (real time corrected from the “dead time”) is divided by the number of pixel (spectrums), giving an average live time.

Examples

>>> ref = hs.datasets.example_signals.EDS_TEM_Spectrum()
>>> s = hs.signals.EDSTEMSpectrum(
>>>     hs.datasets.example_signals.EDS_TEM_Spectrum().data)
>>> print(s.axes_manager[0].scale)
>>> s.get_calibration_from(ref)
>>> print(s.axes_manager[0].scale)
1.0
0.020028
quantification(intensities, method, factors='auto', composition_units='atomic', navigation_mask=1.0, closing=True, plot_result=False, **kwargs)

Quantification using Cliff-Lorimer, the zeta-factor method, or ionization cross sections.

Parameters:
  • intensities (list of signal) – the intensitiy for each X-ray lines.
  • method ('CL' or 'zeta' or 'cross_section') – Set the quantification method: Cliff-Lorimer, zeta-factor, or ionization cross sections.
  • factors (list of float) – The list of kfactors, zeta-factors or cross sections in same order as intensities. Note that intensities provided by Hyperspy are sorted by the alphabetical order of the X-ray lines. eg. factors =[0.982, 1.32, 1.60] for [‘Al_Ka’, ‘Cr_Ka’, ‘Ni_Ka’].
  • composition_units ('weight' or 'atomic') – The quantification returns the composition in atomic percent by default, but can also return weight percent if specified.
  • navigation_mask (None or float or signal) – The navigation locations marked as True are not used in the quantification. If int is given the vacuum_mask method is used to generate a mask with the int value as threhsold. Else provides a signal with the navigation shape.
  • closing (bool) – If true, applied a morphologic closing to the mask obtained by vacuum_mask.
  • plot_result (bool) – If True, plot the calculated composition. If the current object is a single spectrum it prints the result instead.
  • kwargs – The extra keyword arguments are passed to plot.
Returns:

  • A list of quantified elemental maps (signal) giving the composition of
  • the sample in weight or atomic percent.
  • If the method is ‘zeta’ this function also returns the mass thickness
  • profile for the data.
  • If the method is ‘cross_section’ this function also returns the atom
  • counts for each element.

Examples

>>> s = hs.datasets.example_signals.EDS_TEM_Spectrum()
>>> s.add_lines()
>>> kfactors = [1.450226, 5.075602] #For Fe Ka and Pt La
>>> bw = s.estimate_background_windows(line_width=[5.0, 2.0])
>>> s.plot(background_windows=bw)
>>> intensities = s.get_lines_intensity(background_windows=bw)
>>> res = s.quantification(intensities, kfactors, plot_result=True,
>>>                        composition_units='atomic')
Fe (Fe_Ka): Composition = 15.41 atomic percent
Pt (Pt_La): Composition = 84.59 atomic percent

See also

vacuum_mask()

set_microscope_parameters(beam_energy=None, live_time=None, tilt_stage=None, azimuth_angle=None, elevation_angle=None, energy_resolution_MnKa=None, beam_current=None, probe_area=None, real_time=None, display=True, toolkit=None)

Set the microscope parameters.

If no arguments are given, raises an interactive mode to fill the values.

beam_energy: float
The energy of the electron beam in keV
live_time : float
In seconds
tilt_stage : float
In degree
azimuth_angle : float
In degree
elevation_angle : float
In degree
energy_resolution_MnKa : float
In eV
beam_current: float
In nA
probe_area: float
In nm²
real_time: float
In seconds

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.

>>> s = hs.datasets.example_signals.EDS_TEM_Spectrum()
>>> print(s.metadata.Acquisition_instrument.
>>>       TEM.Detector.EDS.energy_resolution_MnKa)
>>> s.set_microscope_parameters(energy_resolution_MnKa=135.)
>>> print(s.metadata.Acquisition_instrument.
>>>       TEM.Detector.EDS.energy_resolution_MnKa)
133.312296
135.0
vacuum_mask(threshold=1.0, closing=True, opening=False)

Generate mask of the vacuum region

Parameters:
  • threshold (float) – For a given pixel, maximum value in the energy axis below which the pixel is considered as vacuum.
  • closing (bool) – If true, applied a morphologic closing to the mask
  • opnening (bool) – If true, applied a morphologic opening to the mask

Examples

>>> # Simulate a spectrum image with vacuum region
>>> s = hs.datasets.example_signals.EDS_TEM_Spectrum()
>>> s_vac = hs.signals.BaseSignal(
        np.ones_like(s.data, dtype=float))*0.005
>>> s_vac.add_poissonian_noise()
>>> si = hs.stack([s]*3 + [s_vac])
>>> si.vacuum_mask().data
array([False, False, False,  True], dtype=bool)
Returns:mask – The mask of the region
Return type:signal
class hyperspy._signals.eds_tem.LazyEDSTEMSpectrum(*args, **kwards)

Bases: hyperspy._signals.eds_tem.EDSTEMSpectrum, hyperspy._signals.eds.LazyEDSSpectrum