autoemx.core.quantifier.peak_overlaps module

Peak overlap warnings

Identifies reference lines used to quantify sample elements that overlap with other lines whose area is fitted freely, which may compromise the quantification of those elements.

Lines whose area is fitted freely are the reference lines of every fitted element (sample and substrate), i.e. the lines that are their own weight reference in XSp_Fitter (Ka1, La1 or Ll when La1 is absent, Ma1 for Z > 58, Mz1 for Z <= 58), and the lines listed in free_area_el_lines. All other lines have their area tied to a reference line of the same element.

The overlap criteria are defined per measurement method in autoemx/data/Xray_lines/common_peak_overlaps.json (generated by make_common_peak_overlaps_file.py, which also lists the candidate pairs of reference lines used by the automated peak identification). Methods without an entry (anything other than ‘EDS’, currently) produce no warnings. The pairs are computed here at runtime, as they also depend on free_area_el_lines. For EDS, the severity of an overlap depends on the separation of the two lines in units of sigma_eff = sqrt((sigma1^2 + sigma2^2) / 2), with sigma the detector resolution at each line energy, computed with the calibration of the microscope used (DetectorResponseFunction.det_sigma).

autoemx.core.quantifier.peak_overlaps.get_peak_overlaps(meas_type: str, els_sample: Iterable[str], els_substrate: Iterable[str] = (), beam_energy_keV: float | None = None, energy_range_keV: Tuple[float, float] | None = None, microscope_ID: str | None = None, free_area_el_lines: Sequence[str] | None = None) → List[dict][source]

Find the reference lines used to quantify sample elements that overlap with other lines whose area is fitted freely, which may compromise the quantification of those elements.

Parameters:
  • meas_type (str) – Measurement method (e.g. ‘EDS’). Methods without overlap criteria return no overlaps.

  • els_sample (iterable of str) – Element symbols of the sample (quantified) and of the substrate (fitted, not quantified).

  • els_substrate (iterable of str) – Element symbols of the sample (quantified) and of the substrate (fitted, not quantified).

  • beam_energy_keV (float, optional) – Beam energy. If None, lines are not filtered by overvoltage and all reference lines of an element are considered as possible quantification lines.

  • energy_range_keV ((float, float), optional) – Energy range of the fitted spectrum. If None, lines are not filtered by energy.

  • microscope_ID (str, optional) – Microscope whose detector calibration defines the resolution. Defaults to the default microscope.

  • free_area_el_lines (sequence of str, optional) – Additional lines whose area is fitted freely (e.g. ‘Ge_Lb1’). Defaults to the fitter’s default.

Returns:

One entry per overlapping quantification line, sorted by increasing separation in sigmas, with keys ‘element’ (sample element whose quantification may be inaccurate), ‘line’ (its quantification line, a dict with ‘element’, ‘line’, ‘energy_keV’), ‘severity’ (of the closest overlap) and ‘overlapping’ (lines with free area overlapping with it, dicts with ‘element’, ‘line’, ‘energy_keV’, ‘separation_eV’, ‘separation_sigma’, ‘severity’, sorted by increasing separation).

Return type:

list of dict

autoemx.core.quantifier.peak_overlaps.format_line(line: dict) → str[source]

Format a line entry, e.g. ‘S Ka1 (2.307 keV)’.

autoemx.core.quantifier.peak_overlaps.format_overlap(overlap: dict) → str[source]

Format an overlap returned by get_peak_overlaps, e.g. ‘S may be inaccurately quantified: its reference peak S Ka1 (2.307 keV) overlaps with Mo La1 (2.293 keV; severe, ΔE = 14 eV = 0.4σ), whose area is also fitted freely.’

autoemx.core.quantifier.peak_overlaps.affected_elements(overlaps: Sequence[dict]) → List[str][source]

Sample elements whose quantification may be compromised by the overlaps.

autoemx.core.quantifier.peak_overlaps.format_peak_overlaps_warning(overlaps: Sequence[dict]) → str[source]

Format the warning message for a list of overlaps returned by get_peak_overlaps.

autoemx.core.quantifier.peak_overlaps.warn_peak_overlaps(meas_type: str, els_sample: Iterable[str], els_substrate: Iterable[str] = (), beam_energy_keV: float | None = None, energy_range_keV: Tuple[float, float] | None = None, microscope_ID: str | None = None, free_area_el_lines: Sequence[str] | None = None) → List[dict][source]

Log a warning, enclosed in double separators, listing the overlaps found by get_peak_overlaps.