pyEELSMODEL.operators.aligns package

Submodules

pyEELSMODEL.operators.aligns.align module

class pyEELSMODEL.operators.aligns.align.Align(multispectrum, other_spectra, cropping, signal_range=None, zero_index=None)

Bases: Operator

This class is the super class of different types of alignment procedures. For instance the zero loss alignment using the maximum value or model based fitting with Gaussian/Lorentzian. Also other methods of alignment such as the cross correlation can be used as child class

align()

Applies the calculated shift to the given multispectrum and other given multispectra. The new aligned spectrum is saved in the aligned attribute. The additional aligned spectra can be found in the aligned_others attribute. The difference between the ‘align’ or ‘fast_align’ function is that align uses the interpolation to shift a spectrum whereas the ‘fast_align’ uses the indices to shift so no subpixel shifts are possible.

Return type:

None.

check_valid_other_spectra(other_spectra)

Checks whether the given other_spectra have the same x and y size which is necessary to have in order to correct the drift.

Parameters:

other_spectra (list of MultiSpectrum) – A list containing the multispectra which uses the same alignment.

Returns:

bool – Returns True if no error is thrown.

Return type:

True

fast_align()

Aligns the data using a roll without any interpolation. parameter. The new aligned spectrum is saved in the aligned attribute. The additional aligned spectra can be found in the aligned_others attribute.

Return type:

None.

property index_shift

The index shift, this will be used to align the spectra using the roll function

Returns:

self._index_shift – The index shift.

Return type:

2d numpy array (int)

make_pdf_result()

Creates a pdf which summarizes the results obtained from the alignment procedure. This is helpfull to identify a problem in this procedure since it is not possible for each multispectrum which is acquired.

Returns:

fig – The figure which can then be used to modify or save

Return type:

Figure

property shift

The determined shift using a method which is given in the sub-class

Returns:

self._shift

Return type:

2d numpy array

show_alignment_result()

Figure outputs the average spectrum before and after alignment

Returns:

fig – The figure which can then be used to modify or save

Return type:

Figure

show_shift(show_index=False, nbins=20)

Shows the shift which will be applied to the spectra.

Returns:

fig – The figure which can then be used to modify or save

Return type:

Figure

show_signal_range(index=(0, 0))

Show the signal range used in the determination of the shift.

Parameters:

index (tuple) – The spectrum of the multispectrum which will be shown. (default: (0,0))

Returns:

fig – The figure which can then be used to modify or save

Return type:

Figure

property signal_range

The signal range used in the determination of the shift/index_shift

Returns

self._signal_range: tuple

update_multispectra()

If the zero loss is not centered around the zero energy then we cut too much of when cropping. This is resolved by doing a first quick update on the offset energy of the multispectrum by taking the median value of the energy at maximum intensity.

property zero_index

The reference index for the alignment of the fast align.

Returns:

self._zero_index

Return type:

int

pyEELSMODEL.operators.aligns.aligncrosscorrelation module

Created on Thu Dec 9 20:46:09 2021

@author: joverbee

class pyEELSMODEL.operators.aligns.aligncrosscorrelation.AlignCrossCorrelation(multispectrum, other_spectra=[], signal_range=None, cropping=False, interp=1, subpixel=False, is_zlp=False)

Bases: Align

Aligns the dataset using the maximum from the cross correlation of the given spectra with the reference. At this point the reference is taken as the spectrum which is set in the multispectrum. This alignment method will only work if an edge or zero loss is the same over the entire scan.

property correlationmap
determine_shift()

Sets the index_shift and shift attribute by finding the maximum value of the cross correlation between each spectrum and the reference spectrum. Reference spectrum is fixed and should be chosen beforehand.

Return type:

None.

property interp
interpolate_int(data, index)

Function which interpolates the data with the number of index points. So if index is two, the interpolated data will contain twice as many points.

Parameters:
  • data

  • index

Return type:

None.

perform_alignment()

Performs the alignment procedure by first calculating the shift and then applying it to the spectra. The roll method is chosen to perform the alignment.

Return type:

None.

property reference

Reference spectrum used in the cross correlation

property subpixel

pyEELSMODEL.operators.aligns.alignzeroloss module

Created on Thu Dec 9 20:46:09 2021

@author: joverbee

class pyEELSMODEL.operators.aligns.alignzeroloss.AlignZeroLoss(multispectrum, other_spectra=None, signal_range=None, model_type='Gaussian', cropping=False, use_bounds=True)

Bases: Align

AlignZeroLoss is a class which aligns the zero loss peak and other spectra can be added which also need to be aligned. The zero loss is fitted to a model (Gaussian or Lorentzian) and this parameter will be used to align the zero loss. Note that some interpolation step is used to shift the data. This could introduce differences in noise properties when wanting to perform the most accurate statistics on it.

calculate_model()

Fits the model to the data. The fitting region is resetted as it initially was after the fit.

estimate_start_parameters()

Estimates the starting values for every scan position to fit the zero loss peak. The A value is found by taking the maximum. The centre is chosen as the coordinate at which the maximum occurs Sigma is taken as a fixed value of 1. (better guess can be tried but it

seems to be stable)

It stores the result is the start_parameters attribute.

property fitter

The fitter used in the spectrum (now it is the LSQ since it fast and stable)

include_areas()

Sets the exlude of the spectrum such that only the integration range is taken into account.

make_zeroloss_model()

Creates a model for the zero loss peak, this depends on which model_type is chosen when creating the background object. The model is stored in the model attribute

property model

The model used for the fitting

perform_alignment()

Performs the alignment procedure by first calculating the shift and then applying it to the spectra.

Return type:

None.

set_indices()

Calculates the indices used which are excluded in the fit. These indices are also used to determine a first guess of the background model. The result is stored in the indices attribute

pyEELSMODEL.operators.aligns.fastalignzeroloss module

class pyEELSMODEL.operators.aligns.fastalignzeroloss.FastAlignZeroLoss(multispectrum, other_spectra=None, signal_range=None, cropping=True)

Bases: Align

FastAlignZeroLoss is a class which aligns the zero loss peak and other spectra can be added which also need to be aligned. It calculates the maximum value of the spectrum.

determine_fast_shift()

Sets the index_shift and shift attribute by finding the maximum value in each spectrum.

Return type:

None.

perform_alignment()

Performs the alignment procedure by first calculating the shift and then applying it to the spectra. The roll method is chosen to perform the alignment.

Return type:

None.

Module contents