autoemxsp.runners package
Package initializer for autoemxsp.runners
Automatically imports all submodules and re-exports their public symbols. Symbols must be declared in the module’s __all__ to be exported.
- autoemxsp.runners.analyze_sample(sample_ID: str, results_path: str = None, output_filename_suffix: str = '', ref_formulae: List[str] | None = None, els_excluded_clust_plot: List[str] | None = None, clustering_features: List[str] | None = None, k_finding_method: str | None = None, k_forced: int | None = None, do_matrix_decomposition: bool = True, max_analytical_error_percent: float = 5, quant_flags_accepted: List[int] | None = None, plot_custom_plots: bool = False, show_unused_compositions_cluster_plot: bool = True) None[source]
Run clustering and analysis for a single sample.
- Parameters:
sample_ID (str) – Sample identifier.
results_path (str, optional) – Directory where results are loaded and stored. If None, defaults to autoemxsp/Results
output_filename_suffix (str, optional) – Suffix for output files.
ref_formulae (list of str, optional) – Reference formulae for clustering. If the first entry is “” or None, the rest are appended to the list loaded from Comp_analysis_configs.json; otherwise, the provided list replaces it.
els_excluded_clust_plot (list of str, optional) – Elements to exclude from cluster plot.
clustering_features (list of str, optional) – Features to use for clustering.
k_finding_method (str, optional) –
- Method for determining optimal number of clusters. Set to “forced” if a value of ‘k’ is specified manually.
Allowed methods are “silhouette”, “calinski_harabasz”, “elbow”.
k_forced (int, optional) – Forced number of clusters.
do_matrix_decomposition (bool, optional) – Whether to compute matrix decomposition for intermixed phases. Slow if many candidate phases are provided. Default: True..
max_analytical_error_percent (float, optional) – Maximum analytical error allowed for clustering.
quant_flags_accepted (list of int, optional) – Accepted quantification flags.
plot_custom_plots (bool, optional) – Whether to use custom plots.
show_unused_compositions_cluster_plot (bool, optional) – Whether to show unused compositions in cluster plot.
- Returns:
comp_analyzer – The composition analysis object containing the results and methods for further analysis.
- Return type:
- autoemxsp.runners.batch_acquire_experimental_stds(stds: List[Dict[str, Any]], microscope_ID: str = 'PhenomXL', microscope_type: str = 'SEM', measurement_type: str = 'EDS', measurement_mode: str = 'point', sample_halfwidth: float = 3.0, sample_substrate_type: str = 'Ctape', sample_substrate_shape: str = 'circle', working_distance: float = 5, working_distance_tolerance: float = 1, beam_energy: float = 15.0, spectrum_lims: Tuple[float, float] = (14, 1100), use_instrument_background: bool = False, min_bckgrnd_cnts: float = 5, fit_during_collection=True, update_std_library=False, is_auto_substrate_detection: bool = False, auto_adjust_brightness_contrast: bool = True, contrast: float = 4.3877, brightness: float = 0.4504, min_n_spectra: int = 50, max_n_spectra: int = 100, target_Xsp_counts: int = 250000, max_XSp_acquisition_time: float = None, els_substrate: List[str] = None, powder_meas_cfg_kwargs: Dict[str, Any] = None, bulk_meas_cfg_kwargs: Dict[str, Any] = None, exp_stds_meas_cfg_kwargs: Dict[str, Any] = None, output_filename_suffix: str = '', development_mode: bool = False, verbose: bool = True, exp_std_dir: str = None) None[source]
Batch acquisition (and optional quantification) of X-ray spectra for a list of powder samples.
- Parameters:
stds (list of dict) –
List of experimental standard definitions. Each dictionary must contain:
’ID’ (str): Identifier for the standard sample (SampleConfig.ID).
’formula’ (str): Chemical formula of the standard (ExpStandardsConfig.formula).
’pos’ (tuple of float): (x, y) stage coordinates in mm (SampleConfig.center_pos).
’sample_type’ (str): Sample type (‘powder’, ‘bulk’, etc.) (SampleConfig.type).
’is_manual_meas’ (bool): If True, navigation to positions is manual (MeasurementConfig.is_manual_navigation).
microscope_ID (str, optional) – Identifier for the microscope hardware. Must correspond to a calibration folder in ./XSp_calibs/Microscopes/<ID> (MicroscopeConfig.ID). Default is ‘PhenomXL’.
microscope_type (str, optional) – Type of microscope. Allowed: ‘SEM’ (implemented), ‘STEM’ (not implemented). Default is ‘SEM’ (MicroscopeConfig.type).
measurement_type (str, optional) – Measurement type. Allowed: ‘EDS’ (implemented), ‘WDS’ (not implemented). Default is ‘EDS’ (MeasurementConfig.type).
measurement_mode (str, optional) – Acquisition mode (e.g., ‘point’, ‘map’), defining beam/detector calibration settings. Default is ‘point’ (MeasurementConfig.mode).
sample_halfwidth (float, optional) – Half-width of the sample area in mm for mapping/acquisition. Default is 3.0 (SampleConfig.half_width_mm).
sample_substrate_type (str, optional) – Type of sample substrate. Allowed: ‘Ctape’, ‘None’. Default is ‘Ctape’ (SampleSubstrateConfig.type).
sample_substrate_shape (str, optional) – Shape of the substrate. Allowed: ‘circle’, ‘square’. Default is ‘circle’ (SampleSubstrateConfig.shape).
working_distance (float, optional) – Working distance in mm for acquisition. If None, taken from microscope driver. Default is 5.0 (MeasurementConfig.working_distance).
working_distance_tolerance (float, optional) –
- Defines maximum accepted deviation of working distance from its typical value, in mm.
Used to prevent gross mistakes from EM autofocus. Default: 1 mm.
beam_energy (float, optional) – Electron beam energy in keV. Default is 15.0 (MeasurementConfig.beam_energy_keV).
spectrum_lims (tuple of float, optional) – Lower and upper energy limits for spectrum fitting in eV. Default is (14, 1100) (QuantConfig.spectrum_lims).
use_instrument_background (bool, optional) – Whether to use instrument background files during fitting. If False, background is computed during fitting. Default is False (QuantConfig.use_instrument_background).
min_bckgrnd_cnts (float, optional) – Minimum background counts required for a spectrum not to be filtered out. Default is 5 (QuantConfig.min_bckgrnd_cnts).
fit_during_collection (bool, optional) – If True, fit spectra during acquisition; otherwise fit later. Default is True.
update_std_library (bool, optional) – If True, update the stored experimental standards library after acquisition. Default is False.
is_auto_substrate_detection (bool, optional) – If True, substrate elements are detected automatically. Implemented only for ‘Ctape’ substrates. Default is False (SampleSubstrateConfig.auto_detection).
auto_adjust_brightness_contrast (bool, optional) – If True, brightness/contrast are set automatically. Default is True (MicroscopeConfig.is_auto_BC).
contrast (float, optional) – Manual contrast setting (required if auto_adjust_brightness_contrast is False). Default is 4.3877 (MicroscopeConfig.contrast).
brightness (float, optional) – Manual brightness setting (required if auto_adjust_brightness_contrast is False). Default is 0.4504 (MicroscopeConfig.brightness).
min_n_spectra (int, optional) – Minimum number of spectra to acquire. Default is 50 (MeasurementConfig.min_n_spectra).
max_n_spectra (int, optional) – Maximum number of spectra to acquire. Default is 100 (MeasurementConfig.max_n_spectra).
target_Xsp_counts (int, optional) – Target counts for spectrum acquisition. Default is 250000 (MeasurementConfig.target_acquisition_counts).
max_XSp_acquisition_time (float, optional) – Maximum acquisition time in seconds. If None, estimated from target counts. Default is None (MeasurementConfig.max_acquisition_time).
els_substrate (list of str, optional) – List of substrate element symbols. Default is [‘C’, ‘O’, ‘Al’] (SampleSubstrateConfig.elements).
powder_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for PowderMeasurementConfig.
bulk_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for BulkMeasurementConfig.
exp_stds_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for ExpStandardsConfig. Used to customize experimental standard acquisition and PB ratio filtering.
output_filename_suffix (str, optional) – String appended to output filenames. Default is ‘’.
development_mode (bool, optional) – If True, enables development/debug features. Default is False.
verbose (bool, optional) – If True, print verbose output. Default is True.
exp_std_dir (str, optional) – Directory where experimental standard results are saved. Default is None.
- Returns:
results – A list of the composition analysis objects (one per sample) containing the results and methods for further analysis.
- Return type:
- autoemxsp.runners.batch_acquire_and_analyze(samples: List[Dict[str, Any]], microscope_ID: str = 'PhenomXL', microscope_type: str = 'EDS', measurement_type: str = 'EDS', measurement_mode: str = 'point', quantification_method: str = 'PB', sample_type: str = 'powder', sample_halfwidth: float = 3.0, sample_substrate_type: str = 'Ctape', sample_substrate_shape: str = 'circle', sample_substrate_width_mm: float = 12, working_distance: float = 5, working_distance_tolerance: float = 1, beam_energy: float = 15.0, spectrum_lims: Tuple[float, float] = (14, 1100), use_instrument_background: bool = False, use_project_specific_std_dict: bool = False, interrupt_fits_bad_spectra: bool = True, max_analytical_error_percent: float = 5, min_bckgrnd_cnts: float = 5, quant_flags_accepted: List[int] = [0, -1], max_n_clusters: int = 6, show_unused_comps_clust: bool = True, is_manual_navigation: bool = False, is_auto_substrate_detection: bool = False, auto_adjust_brightness_contrast: bool = True, contrast: float = 4.3877, brightness: float = 0.4504, quantify_spectra: bool = False, min_n_spectra: int = 50, max_n_spectra: int = 100, target_Xsp_counts: int = 50000, max_XSp_acquisition_time: float = None, els_substrate: List[str] = None, powder_meas_cfg_kwargs: Dict[str, Any] = None, bulk_meas_cfg_kwargs: Dict[str, Any] = None, standards_dict: Dict[str, float] = None, output_filename_suffix: str = '', development_mode: bool = False, verbose: bool = True, results_dir: str = None) None[source]
Batch acquisition (and optional quantification) of X-ray spectra for a list of powder samples.
- Parameters:
samples (list of dict) –
- List of sample definitions. Each dictionary must contain:
’ID’ (str): Sample identifier (SampleConfig.ID).
’els’ (list of str): List of expected element symbols (SampleConfig.elements).
’pos’ (tuple of float): (x, y) stage coordinates in mm (SampleConfig.center_pos).
’cnd’ (list of str, optional): Reference chemical formulae for known phases (ClusteringConfig.ref_formulae).
microscope_ID (str, optional) – Identifier for the microscope hardware. Must correspond to a calibration folder in ./XSp_calibs/Microscopes/<ID> (MicroscopeConfig.ID). Default is ‘PhenomXL’.
microscope_type (str, optional) – Type of microscope. Allowed: ‘SEM’ (implemented), ‘STEM’ (not implemented). Default is ‘SEM’ (MicroscopeConfig.type).
measurement_type (str, optional) – Measurement type. Allowed: ‘EDS’ (implemented), ‘WDS’ (not implemented). Default is ‘EDS’ (MeasurementConfig.type).
measurement_mode (str, optional) – Acquisition mode (e.g., ‘point’, ‘map’), defining beam/detector calibration settings. Default is ‘point’ (MeasurementConfig.mode).
quantification_method (str, optional) – Quantification method. Currently only ‘PB’ (Phi-Rho-Z) is implemented. Default is ‘PB’ (QuantConfig.method).
sample_type (str, optional) – Sample type. Allowed: ‘powder’ (implemented), ‘bulk’, ‘film’ (not implemented). Default is ‘powder’ (SampleConfig.type).
sample_halfwidth (float, optional) – Half-width of the sample area in mm for mapping/acquisition. Default is 3.0 (SampleConfig.half_width_mm).
sample_substrate_type (str, optional) – Type of sample substrate. Allowed: ‘Ctape’, ‘None’. Default is ‘Ctape’ (SampleSubstrateConfig.type).
sample_substrate_shape (str, optional) – Shape of the substrate. Allowed: ‘circle’, ‘square’. Default is ‘circle’ (SampleSubstrateConfig.shape).
sample_substrate_width_mm (float, optional) – Lateral dimension of substrate holder in mm (SampleSubstrateConfig.stub_w_mm).
working_distance (float, optional) – Working distance in mm for acquisition. If None, taken from microscope driver. Default is 5.0 (MeasurementConfig.working_distance).
working_distance_tolerance (float, optional) –
- Defines maximum accepted deviation of working distance from its typical value, in mm.
Used to prevent gross mistakes from EM autofocus. Default: 1 mm.
beam_energy (float, optional) – Electron beam energy in keV. Default is 15.0 (MeasurementConfig.beam_energy_keV).
spectrum_lims (tuple of float, optional) – Lower and upper energy limits for spectrum fitting in eV. Default is (14, 1100) (QuantConfig.spectrum_lims).
use_instrument_background (bool, optional) – Whether to use instrument background files during fitting. If False, background is computed during fitting. Default is False (QuantConfig.use_instrument_background).
use_project_specific_std_dict (bool, optional) – If True, loads standards from project folder (i.e. results_dir) during quantification. Default: False
interrupt_fits_bad_spectra (bool, optional) – If True, fitting stops early for poor-quality spectra. Default is True (QuantConfig.interrupt_fits_bad_spectra).
max_analytical_error_percent (float, optional) – Maximum allowed analytical error (%) for compositions to be included in clustering. Default is 5 (ClusteringConfig.max_analytical_error_percent).
min_bckgrnd_cnts (float, optional) – Minimum background counts required for a spectrum not to be filtered out. Default is 5 (QuantConfig.min_bckgrnd_cnts).
quant_flags_accepted (list of int, optional) – List of acceptable quantification flags; others are filtered out before clustering. Default is [0, -1] (ClusteringConfig.quant_flags_accepted).
max_n_clusters (int, optional) – Maximum number of clusters allowed in compositional clustering. Default is 6 (ClusteringConfig.max_k).
show_unused_comps_clust (bool, optional) – Whether to display unused compositions in clustering plots. Default is True (PlotConfig.show_unused_comps_clust).
is_manual_navigation (bool, optional) – If True, navigation to sample positions is manual. Default is False (MeasurementConfig.is_manual_navigation).
is_auto_substrate_detection (bool, optional) – If True, substrate elements are detected automatically. Implemented only for ‘Ctape’ substrates. Default is False (SampleSubstrateConfig.auto_detection).
auto_adjust_brightness_contrast (bool, optional) – If True, brightness/contrast are set automatically. Default is True (MicroscopeConfig.is_auto_BC).
contrast (float, optional) – Manual contrast setting (required if auto_adjust_brightness_contrast is False). Default is 4.3877 (MicroscopeConfig.contrast).
brightness (float, optional) – Manual brightness setting (required if auto_adjust_brightness_contrast is False). Default is 0.4504 (MicroscopeConfig.brightness).
quantify_spectra (bool, optional) – If True, perform quantification after acquisition. Default is False.
min_n_spectra (int, optional) – Minimum number of spectra to acquire. Default is 50 (MeasurementConfig.min_n_spectra).
max_n_spectra (int, optional) – Maximum number of spectra to acquire. Default is 100 (MeasurementConfig.max_n_spectra).
target_Xsp_counts (int, optional) – Target counts for spectrum acquisition. Default is 50000 (MeasurementConfig.target_acquisition_counts).
max_XSp_acquisition_time (float, optional) – Maximum acquisition time in seconds. If None, estimated from target counts. Default is None (MeasurementConfig.max_acquisition_time).
els_substrate (list of str, optional) – List of substrate element symbols. Default is [‘C’, ‘O’, ‘Al’] (SampleSubstrateConfig.elements).
powder_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for PowderMeasurementConfig.
bulk_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for BulkMeasurementConfig.
standards_dict (dict, optional) – Dictionary of reference PB values from experimental standards. Default : None. If None, dictionary of standards is loaded from the XSp_calibs/Your_Microscope_ID directory. Provide standards_dict only when providing different standards from those normally used for quantification.
output_filename_suffix (str, optional) – String appended to output filenames. Default is ‘’.
development_mode (bool, optional) – If True, enables development/debug features. Default is False.
verbose (bool, optional) – If True, print verbose output. Default is True.
results_dir (str, optional) – Directory where results are saved. Default is None.
- Returns:
comp_analyzer – The composition analysis object containing the results and methods for further analysis.
- Return type:
- autoemxsp.runners.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:
- autoemxsp.runners.batch_quantify_and_analyze(sample_IDs: List[str], quantification_method: str = None, results_path: str = None, min_bckgrnd_cnts: float = None, output_filename_suffix: str = '', use_instrument_background: bool = False, max_analytical_error: float = 5, run_analysis: bool = True, num_CPU_cores: int = None, quantify_only_unquantified_spectra: bool = False, interrupt_fits_bad_spectra: bool = False, use_project_specific_std_dict: bool = None, is_known_precursor_mixture: bool | None = None, standards_dict: dict = None) None[source]
Batch quantification and analysis for a list of samples.
- Parameters:
sample_IDs (List[str]) – List of sample identifiers.
quantification_method (str, optional) – Method to use for quantification. Uses quant_cfg.method if unspecified. Currently only supports ‘PB’.
results_path (str, optional) – Base directory where results are stored. Default: autoemxsp/Results
min_bckgrnd_cnts (float, optional) – Minimum number of background counts underneath reference peaks below which spectra are flagged. If None, leaves it unchanged. Default: None
output_filename_suffix (str, optional) – Suffix to append to output filenames.
use_instrument_background (bool, optional) – Whether to use instrument background if present (Default: False).
max_analytical_error (float, optional) – Maximum allowed analytical error for analysis.
run_analysis (bool, optional) – Whether to run clustering/statistical analysis after quantification.
num_CPU_cores (bool | None, optional) – Number of CPU cores to use during fitting and quantification. If None, half of the available cores are used.
quantify_only_unquantified_spectra (bool, optional) – If True, only quantify spectra that lack analytical error.
interrupt_fits_bad_spectra (bool, optional) – If True, interrupt fitting if bad spectra are encountered. Speeds up computations
use_project_specific_std_dict (bool, optional) – If True, loads standards from project folder (i.e. results_dir) during quantification. Default: None. Loads it from quant_cfg file
is_known_precursor_mixture (bool, optional) –
Whether sample is a mixture of two known powders. Used to characterize extent of intermixing in powders. See example at:
L. N. Walters et al., Synthetic Accessibility and Sodium Ion Conductivity of the Na 8– x A x P 2 O 9 (NAP) High-Temperature Sodium Superionic Conductor Framework, Chem. Mater. 37, 6807 (2025).
standards_dict (dict, optional) – Dictionary of reference PB values from experimental standards. Default : None. If None, dictionary of standards is loaded from the XSp_calibs/Your_Microscope_ID directory. Provide standards_dict only when providing different standards from those normally used for quantification.
- Returns:
quant_results – List of EMXSp_Composition_Analyzer, the composition analysis object containing the results and methods for further analysis.
- Return type:
list()
- autoemxsp.runners.collect_particle_statistics(samples: List[Dict[str, Any]], n_par_target: int, microscope_ID: str = 'PhenomXL', microscope_type: str = 'SEM', detector_type: str = 'BSD', sample_halfwidth: float = 3.0, sample_substrate_type: str = 'Ctape', sample_substrate_shape: str = 'circle', sample_substrate_width_mm: float = 12, working_distance: float = 5, is_manual_navigation: bool = False, is_auto_substrate_detection: bool = False, auto_adjust_brightness_contrast: bool = True, contrast: float = 4.3877, brightness: float = 0.4504, powder_meas_cfg_kwargs: Dict[str, Any] = None, output_filename_suffix: str = '', development_mode: bool = False, verbose: bool = True, results_dir: str = None) None[source]
Batch acquisition (and optional quantification) of X-ray spectra for a list of powder samples.
- Parameters:
samples (list of dict) –
- List of sample definitions. Each dictionary must contain:
’ID’ (str): Sample identifier (SampleConfig.ID).
’pos’ (tuple of float): (x, y) stage coordinates in mm (SampleConfig.center_pos).
n_par_target (int) – Target amount of particles to analyse
microscope_ID (str, optional) – Identifier for the microscope hardware. Must correspond to a calibration folder in ./XSp_calibs/Microscopes/<ID> (MicroscopeConfig.ID). Default is ‘PhenomXL’.
microscope_type (str, optional) – Type of microscope. Allowed: ‘SEM’ (implemented), ‘STEM’ (not implemented). Default is ‘SEM’ (MicroscopeConfig.type).
detector_type (str, optional) – Default : BSD
sample_halfwidth (float, optional) – Half-width of the sample area in mm for mapping/acquisition. Default is 3.0 (SampleConfig.half_width_mm).
sample_substrate_type (str, optional) – Type of sample substrate. Allowed: ‘Ctape’, ‘None’. Default is ‘Ctape’ (SampleSubstrateConfig.type).
sample_substrate_shape (str, optional) – Shape of the substrate. Allowed: ‘circle’, ‘square’. Default is ‘circle’ (SampleSubstrateConfig.shape).
sample_substrate_width_mm (float, optional) – Lateral dimension of substrate holder in mm (SampleSubstrateConfig.stub_w_mm).
working_distance (float, optional) – Working distance in mm for acquisition. If None, taken from microscope driver. Default is 5.0 (MeasurementConfig.working_distance).
is_manual_navigation (bool, optional) – If True, navigation to sample positions is manual. Default is False (MeasurementConfig.is_manual_navigation).
is_auto_substrate_detection (bool, optional) – If True, substrate elements are detected automatically. Implemented only for ‘Ctape’ substrates. Default is False (SampleSubstrateConfig.auto_detection).
auto_adjust_brightness_contrast (bool, optional) – If True, brightness/contrast are set automatically. Default is True (MicroscopeConfig.is_auto_BC).
contrast (float, optional) – Manual contrast setting (required if auto_adjust_brightness_contrast is False). Default is 4.3877 (MicroscopeConfig.contrast).
brightness (float, optional) – Manual brightness setting (required if auto_adjust_brightness_contrast is False). Default is 0.4504 (MicroscopeConfig.brightness).
powder_meas_cfg_kwargs (dict, optional) – Additional keyword arguments for PowderMeasurementConfig.
output_filename_suffix (str, optional) – String appended to output filenames. Default is ‘’.
development_mode (bool, optional) – If True, enables development/debug features. Default is False.
verbose (bool, optional) – If True, print verbose output. Default is True.
results_dir (str, optional) – Directory where results are saved. Default is None.
- Returns:
comp_analyzer – The composition analysis object containing the results and methods for further analysis.
- Return type:
- autoemxsp.runners.fit_and_quantify_spectrum(spectrum_vals, spectrum_lims, microscope_ID, meas_type, meas_mode, det_ch_offset, det_ch_width, beam_energy, emergence_angle, sp_collection_time=None, sample_ID='', els_sample: list = None, els_substrate: list = None, background_vals=None, fit_tol: float = 0.0001, is_particle: bool = False, quantify_plot: bool = True, max_undetectable_w_fr: float = 0, force_single_iteration: bool = False, interrupt_fits_bad_spectra: bool = False, standards_dict=None, plot_signal: bool = True, plot_title='', zoom_plot: bool = False, line_to_plot: str = '', print_results: bool = True, quant_verbose: bool = True, fitting_verbose: bool = True)[source]
Fit and (optionally) quantify a single spectrum.
- Parameters:
spectrum_vals (numpy.ndarray) – The measured EDS spectrum (counts per channel).
spectrum_lims (tuple of int) – Tuple specifying the start and end indices for the spectrum region to analyze.
microscope_ID (str) – Microscope identifier for detector calibration data.
meas_type (str) – Measurement type (e.g., ‘EDS’).
meas_mode (str) – Measurement mode, defining detector calibrations and (optionally) beam current (e.g., ‘point’).
det_ch_offset (float) – Detector channel energy offset (keV).
det_ch_width (float) – Detector channel width (keV).
beam_energy (float) – Electron beam energy (keV).
emergence_angle (float) – Detector emergence (take-off) angle (degrees).
sp_collection_time (float or None) – Live time of spectrum acquisition (in seconds).
sample_ID (str) – Sample identifier.
els_sample (list, optional) – List of elements in the sample.
els_substrate (list, optional) – List of substrate elements.
background_vals (array-like or None, optional) – Background spectrum to subtract. If None, the background will be modeled during fitting.
fit_tol (float, optional) – scipy fit tolerance. Defines conditions of fit convergence
is_particle (bool, optional) – If True, treats sample as particle (powder). Uses particle geometry fitting parameters
quantify_plot (bool, optional) – Whether to quantify the spectrum.
max_undetectable_w_fr (float, optional) – Maximum allowed weight fraction for undetectable elements (default: 0). Total mass fraction of fitted elements is forced to be between [1-max_undetectable_w_fr, 1]
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 spectrum is detected to lead to poor quantification (default: False).
standards_dict (dict, optional) – Dictionary of standard values to use for quantification.
plot_signal (bool, optional) – Whether to plot the fitted spectrum.
plot_title (str) – String printed as plot title.
zoom_plot (bool, optional) – Whether to zoom on a specific line.
line_to_plot (str, optional) – Line to zoom on.
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:
- autoemxsp.runners.fit_and_quantify_spectrum_fromDatacsv(sample_ID: str, spectrum_ID: int, els_sample: list = None, els_substrate: list = None, is_standard: bool = False, spectrum_lims: tuple = None, results_path: str = None, use_instrument_background: bool = False, quantify_plot: bool = True, plot_signal: bool = True, zoom_plot: bool = False, line_to_plot: str = '', 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, standards_dict: dict = None, print_results: bool = True, quant_verbose: bool = True, fitting_verbose: bool = True)[source]
Fit and (optionally) quantify a single spectrum.
- Parameters:
sample_ID (str) – Sample identifier.
spectrum_ID (int) – Value reported in ‘Spectrum #’ column in Data.csv.
els_sample (list, optional) – List of elements in the sample.
els_substrate (list, optional) – List of substrate elements.
is_standard (bool) – Defines whether measurement is from an experimental standard (i.e., sample of known composition)
results_path (str, optional) – Base directory where results are stored. Default: autoemxsp/Results
use_instrument_background (bool, optional) – Whether to use instrument background if present. Default: False
quantify_plot (bool, optional) – Whether to quantify the spectrum.
plot_signal (bool, optional) – Whether to plot the fitted spectrum.
zoom_plot (bool, optional) – Whether to zoom on a specific line.
line_to_plot (str, optional) – Line to zoom on.
fit_tol (float, optional) – scipy fit tolerance. Defines conditions of fit convergence
is_particle (bool, optional) – If True, treats sample as particle (powder). Uses particle geometry fitting parameters
max_undetectable_w_fr (float, optional) – Maximum allowed weight fraction for undetectable elements (default: 0). Total mass fraction of fitted elements is forced to be between [1-max_undetectable_w_fr, 1]
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 spectrum is detected to lead to poor quantification (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:
Submodules
- autoemxsp.runners.analyze_sample module
- autoemxsp.runners.batch_acquire_and_analyze module
- autoemxsp.runners.batch_acquire_experimental_stds module
- autoemxsp.runners.batch_fit_spectra module
- autoemxsp.runners.batch_quantify_and_analyze module
- autoemxsp.runners.collect_particle_statistics module
- autoemxsp.runners.fit_and_quantify_spectrum module