autoemxsp.runners.batch_fit_spectra module

Batch fitting of multiple X-ray spectra for fitting parameter extraction.

This module allows running the fitting step for multiple spectra across multiple samples. It uses the fit_and_quantify_spectrum function internally with quantification disabled, then extracts the values of desired fitting parameters.

Features

  • Accepts a list of sample IDs and spectrum IDs.

  • Supports ‘all’ spectra mode for each sample.

Example

>>> from autoemxsp.runners import batch_fit_spectra
>>> batch_fit_spectra(
...     sample_IDs=["Sample1", "Sample2"],
...     spectrum_IDs="all",
...     plot_signal=False
... )

Created on Fri Aug 20 09:34:34 2025

@author: Andrea

autoemxsp.runners.batch_fit_spectra.batch_fit_spectra(sample_IDs, spectrum_IDs, is_standard: bool, fit_params_vals_to_extract: List[str] | None = None, spectrum_lims: tuple = None, samples_path: str = None, output_path: str = 'Fitting output', use_instrument_background: bool = False, quantify_plot: bool = True, plot_signal: bool = True, zoom_plot: bool = False, line_to_plot: str = '', els_substrate: list = None, fit_tol: float = 0.0001, is_particle: bool = True, max_undetectable_w_fr: float = 0, force_single_iteration: bool = False, interrupt_fits_bad_spectra: bool = False, print_results: bool = True, quant_verbose: bool = True, fitting_verbose: bool = True)[source]

Run fitting for multiple spectra across multiple samples to extract values of fitting parameters.

Parameters:
  • sample_IDs (list of str) – List of sample identifiers.

  • spectrum_IDs (list of int or str) – List of spectrum IDs to process (values reported in ‘Spectrum #’ column in Data.csv), or ‘all’ to process all spectra in each sample.

  • is_standard (bool) – Defines whether measurement is of a standard (i.e., well defined composition) or not

  • fit_params_vals_to_extract (list of str, optional) – List of fitting parameter names whose value to extract and save

  • samples_path (str, optional) – Base directory where results are stored. Default: autoemxsp/Results

  • output_path (str, optional) – Directory where the extracted values of fitted parameters are saved. Default: /Fitting output

  • use_instrument_background (bool, optional) – Whether to use instrument background if present.

  • quantify_plot (bool, optional) – Whether to plot quantification results.

  • plot_signal (bool, optional) – Whether to plot the signal.

  • zoom_plot (bool, optional) – Whether to zoom on a specific line.

  • line_to_plot (str, optional) – Line to zoom in plot.

  • els_substrate (list, optional) – List of substrate elements.

  • fit_tol (float, optional) – Fit tolerance.

  • is_particle (bool, optional) – If True, treat sample as particle (powder).

  • max_undetectable_w_fr (float, optional) – Maximum allowed weight fraction for undetectable elements (default: 0).

  • force_single_iteration (bool, optional) – If True, quantification will be run for a single iteration only (default: False).

  • interrupt_fits_bad_spectra (bool, optional) – If True, interrupt fitting if bad spectra are detected (default: False).

  • print_results (bool, optional) – If True, prints all fitted parameters and their values (default: True).

  • quant_verbose (bool, optional) – If True, prints quantification operations

  • fitting_verbose (bool, optional) – If True, prints fitting operations

Returns:

quantifier – The quantifier object containing the results, fit parameters, and methods for further analysis and plotting.

Return type:

XSp_Quantifier