autoemx.core.fitter.peaks module

Peaks model module for EDS spectrum fitting.

Handles construction and parameterization of spectral peaks including characteristic X-ray lines, escape peaks, and pileup peaks.

Main Class:
  • Peaks_Model: Manages peak model construction and parameterization

class autoemx.core.fitter.peaks.Peaks_Model(spectrum_vals, energy_vals, microscope_ID, meas_mode, fitting_model, fitting_pars, xray_weight_refs_dict=None, is_particle=False, free_area_el_lines=None, free_peak_shape_els=None, free_peak_shape_params=None)[source]

Bases: object

Model for X-ray spectral peaks in EDS spectra.

Handles the construction, parameterization, and constraints of peak models for EDS spectral fitting, including area weighting, escape/pileup peaks, and peak shape calibration.

Variables:
  • spectrum_vals (array-like or None) – Measured spectrum values (e.g., counts).

  • energy_vals (array-like or None) – Corresponding energy values (e.g., keV).

  • fitting_model (lmfit.Model or None) – Composite model used for fitting.

  • fitting_params (lmfit.Parameters or None) – Parameters for the current model.

  • xray_weight_refs_dict (dict) – Maps each secondary line to its reference line for area weighting.

  • xray_weight_refs_lines (list) – Unique reference lines extracted from xray_weight_refs_dict.

  • microscope_ID (str) – Identifier for the microscope/calibration to use.

  • meas_mode (str) – EDS mode, e.g., ‘point’, ‘map’, etc.

  • is_particle (bool) – Whether the sample is a particle (affects some constraints).

  • free_area_el_lines (list) – Elements/lines whose area is fitted freely (for peak intensity weight calibration).

  • free_peak_shape_els (list) – Elements whose peak shapes are calibrated (for shape calibration).

  • fixed_peaks_dict (dict) – Tracks dependencies for overlapping peaks.

  • attributes (Class)

  • ----------------

  • icc_freq_spectra (dict (class variable)) – Cache for ICC convolution spectra, shared across all instances.

  • sigma_broadening_key, (center_key, sigma_key, area_key, center_offset_key,)

  • pileup_peaks_str, (gamma_key, tail_fraction_key, F_loss_key, R_e_key,)

  • pileup_peaks_str (str) – Standardized parameter names for model building.

Notes

  • icc_freq_spectra is a class variable, shared across all instances and used for static method access.

  • Requires DetectorResponseFunction to be initialized first for correct peak sigma calculations.

icc_freq_spectra = {}
center_key = 'center'
sigma_key = 'sigma'
area_key = 'area'
center_offset_key = 'cen_offset'
sigma_broadening_key = 'sigma_broad'
gamma_key = 'gamma'
PEAK_SHAPE_PARAMS = ('gamma', 'f_tail', 'R_e', 'F_loss')
tail_fraction_key = 'f_tail'
F_loss_key = 'F_loss'
R_e_key = 'R_e'
escape_peaks_str = '_escSiKa'
TOP_HAT_PRESENCE_SIGMA = 1.5
TOP_HAT_OVERLAP_SIGMA = 5.0
pileup_peaks_str = '_pileup'
static clear_cached_icc_spectra()[source]

Clear the class-level cache for ICC convolution spectra.

This method resets the icc_freq_spectra dictionary shared by all instances of Peaks_Model, ensuring that all cached ICC spectra are removed prior new calculations that require new computations of icc_freq_spectra.

get_peaks_mod_pars()[source]

Return the current composite peak model and its associated fit parameters.

Returns:

  • model (lmfit.Model or None) – The composite model representing all fitted peaks, or None if not yet defined.

  • pars (lmfit.Parameters) – The set of parameters for the current model.