autoemx.core.quantifier.quant_flags module

Quantification flags (quant_flag) of spectra: whether a fit or quantification is reliable and, if not, why.

Pre-fit checks (flags 1-3) are made on the measured spectrum; post-fit checks (flags 0, -1, 4-9) combine the problems reported by the quantifier (XSp_Quantifier.bad_quant_flag) with checks of the fitted peaks. See the documentation page “Quantification flags” for the meaning of each flag.

Flag

Meaning

0

Quantification OK

-1

As 0, but the quantification did not converge

1

No spectral data

2

Total counts too low

3

Background counts too low (pre-fit)

4

Poor fit

5

Excessively high analytical error

6

Excessive X-ray absorption

7

Substrate peaks too intense

8

Background counts under the reference peaks too low (re-evaluated at analysis)

9

Fit interrupted for unknown reasons

autoemx.core.quantifier.quant_flags.format_min_total_counts_percent(fraction: float) → str[source]

Format a total-counts fraction as a compact percentage string.

autoemx.core.quantifier.quant_flags.detect_prefit_spectrum_issues(*, spectrum: ndarray | None, energy_vals: Sequence[float], sp_start: int, sp_end: int, target_acquisition_counts: int, min_bckgrnd_cnts: float | None, min_total_counts_fraction: float = 0.9) → tuple[int | None, str | None][source]

Detect pre-fit spectrum quality issues that map to quant flags 1-3.

autoemx.core.quantifier.quant_flags.should_interrupt_prefit_issue(prefit_quant_flag: int | None, interrupt_fits_bad_spectra: bool) → bool[source]

Return whether a detected pre-fit issue should skip fitting entirely.

autoemx.core.quantifier.quant_flags.merge_prefit_quant_flag(quant_flag: int, comment: str, prefit_quant_flag: int | None, prefit_comment: str | None) → tuple[int, str][source]

Apply pre-fit flags 2/3 when fitting proceeded without interruption.

autoemx.core.quantifier.quant_flags.flag_spectrum_for_clustering(*, min_bckgrnd_ref_lines: float, quantifier: Any, detectable_els_substrate: Sequence[str], min_bckgrnd_cnts: float | None) → tuple[bool, int, str][source]

Flag 7 (substrate peaks too intense) or 8 (background under reference peaks too low) of a quantified spectrum.

autoemx.core.quantifier.quant_flags.check_fit_quant_validity(*, is_quant_fit_valid: bool, bad_quant_flag: int | None, quantifier: Any, min_bckgrnd_ref_lines: Any, detectable_els_substrate: Sequence[str], min_bckgrnd_cnts: float | None) → tuple[int, str][source]

Quantification flag and comment of a spectrum after fitting and quantification (flags 0, -1, 4-9).