autoemx.runners.batch_fit_experimental_stds module
Batch fitting of experimental standards spectra (PB ratios) from existing ledgers.
This script is analogous to batch_acquire_experimental_stds.py, but instead of running collection and quantification, it directly fits and updates standards from existing data using run_exp_std_fit.
- Usage:
Edit the ‘std_list’ list to define your standards (same as in batch_acquire_experimental_stds.py)
Adjust configuration parameters as needed
Run the script, or import and call batch_fit_experimental_stds() to fit/update standards for one or multiple samples
Created on May 20, 2026 @author: Andrea
- autoemx.runners.batch_fit_experimental_stds.batch_fit_experimental_stds(std_ids: List[str], spectrum_lims: Tuple[float, float] = (14, 1100), use_instrument_background: bool = False, min_bckgrnd_cnts: float | None = None, update_std_library: bool = True, force_refitting: bool = False, els_sample: List[str] | None = None, els_w_frs: Dict[str, float] | None = None, els_substrate: List[str] | None = None, els_to_use_for_mean_PB_calc: List[str] | None = None, min_acceptable_PB_ratio: float | None = None, quant_flags_accepted: List[int] | None = None, generate_separate_std_dict: bool | None = None, output_filename_suffix: str = '', verbose: bool = True, stds_path: str | Path | None = None, standards_dict_path: str | Path | None = None) List[EMXSp_Composition_Analyzer | None][source]
Batch fitting of experimental standard spectra from existing ledgers.
- Parameters:
std_ids (list of str) – List of identifiers for the experimental standards.
spectrum_lims (tuple of float, optional) – Lower and upper energy limits for spectrum fitting in eV.
use_instrument_background (bool, optional) – Whether to use instrument background files during fitting.
min_bckgrnd_cnts (float, optional) – Minimum background counts required for a spectrum not to be filtered out (ClusteringConfig.min_bckgrnd_cnts). If None (default), keeps the value of the standard’s active analysis.
update_std_library (bool, optional) – If True, the experimental standard library will be updated with the newly fitted PB ratios.
force_refitting (bool, optional) – If True, force refitting even if results with same fitting configurations already exist for a standard. Default is False.
els_sample (Optional[List[str]], optional) – List of elements in the sample. If None, defaults to all elements in the sample. If the first entry is “” or None, the rest of the list is appended to the list loaded from the ledger; otherwise, the provided list replaces it.
els_w_frs (Optional[Dict[str, float]], optional) – Dictionary of weight fractions for the elements in the sample to provide if they differ from those in the ledger. Keys should be element symbols. Used to compute PB correction.
els_substrate (Optional[List[str]], optional) – List of elements in the substrate. If None, defaults to all elements in the sample. If the first entry is “” or None, the rest of the list is appended to the list loaded from the ledger; otherwise, the provided list replaces it.
els_to_use_for_mean_PB_calc (list of str, optional) – Elements whose P/B ratios are used for the mean reference values (ExpStandardsConfig.els_to_use_for_mean_PB_calc): e.g. [“Fe”, “O”]; [“all”] for all elements; [] or [“none”] for none.
min_acceptable_PB_ratio (float, optional) – Minimum P/B ratio for a peak to be accepted as a standard (ExpStandardsConfig.min_acceptable_PB_ratio).
quant_flags_accepted (list of int, optional) – Quantification flags of the spectra used for the standard (ExpStandardsConfig.quant_flags_accepted).
generate_separate_std_dict (bool, optional) – Whether to update a separate standards file in the project folder instead of the main one (ExpStandardsConfig.generate_separate_std_dict). For these four parameters, None (default) keeps the value saved in each standard’s ledger. Values given apply to this run only, like the other parameters of this function.
output_filename_suffix (str, optional) – Suffix for the output filename.
verbose (bool, optional) – If True, print verbose output.
stds_path (Optional[str or pathlib.Path], optional) – Directory containing experimental standard data.
standards_dict_path (Optional[str or pathlib.Path], optional) – Path to a standards dictionary file.
- Returns:
results – A list of the composition analysis objects (one per sample).
- Return type: