autoemx.core.em_runtime.spectrum_acquisition module

X-ray spectrum acquisition module for automated electron microscopy.

This module provides functionality for acquiring X-ray spectra (EDS/WDS) at specific sample locations, with support for manual and automated spot selection.

Classes

SpectrumAcquisition

Handles X-ray spectrum acquisition and spot coordinate determination.

Created on 2026 @author: Andrea

class autoemx.core.em_runtime.spectrum_acquisition.SpectrumAcquisition(EM_controller, sample_cfg, measurement_cfg, EM_driver_obj, im_width, im_height, results_dir=None, verbose=True)[source]

Bases: object

Handles X-ray spectrum acquisition and spot selection.

Manages initialization of spectrum analyzers and acquisition of X-ray spectra at specified positions, supporting both manual and automated spot selection modes.

Parameters:
  • EM_controller (EM_Controller) – Reference to the parent EM_Controller.

  • sample_cfg (SampleConfig) – Sample configuration.

  • measurement_cfg (MeasurementConfig) – Measurement configuration.

  • EM_driver_obj (module) – EM driver for hardware access.

  • im_width (int) – Image width in pixels.

  • im_height (int) – Image height in pixels.

  • results_dir (str or None) – Directory for saving results.

  • verbose (bool) – If True, print progress information.

initialise_XS_analyzer(beam_voltage: float = None) → None[source]

Initialize the EDS (Energy Dispersive X-ray Spectroscopy) analyzer.

Optionally sets the electron beam voltage. If unspecified, uses the voltage set during microscope initialization.

Parameters:

beam_voltage (float, optional) – Desired EM beam voltage in kilovolts (kV). If provided, sets the high tension to this value.

get_XSp_coords(n_tot_sp_collected: int, frame_navigator, microscope_ctrl) → Tuple[bool, List[Tuple[float, float]] | None, int | None][source]

Determine X-ray spectrum acquisition coordinates for the next spectrum.

Depending on the navigation mode, either prompts the user to select a spot manually, or automatically selects the next particle spot for ‘powder’ samples.

Parameters:
  • n_tot_sp_collected (int) – Current total number of spectra collected (used for labeling).

  • frame_navigator (FrameNavigator) – Reference to frame navigator.

  • microscope_ctrl (MicroscopeController) – Reference to microscope controller.

Returns:

  • success (bool) – True if a spot was selected/found, False if user stopped or no more particles.

  • spots_xy_list (list of tuple[float, float] or None) – List of (x, y) coordinates for acquisition spots, or None if unsuccessful.

  • particle_cntr (int or None) – The particle counter/index, or None if not applicable.

acquire_XS_spot_spectrum(x: float, y: float, max_acquisition_time: float, target_acquisition_counts: int, elements: List[str] | None = None, msa_file_path: str | None = None) → Tuple[source]

Acquire an X-ray spectrum (EDS/WDS) at the specified position.

Parameters:
  • x (float) – X, Y pixel coordinates for spectrum acquisition.

  • y (float) – X, Y pixel coordinates for spectrum acquisition.

  • max_acquisition_time (float) – Maximum allowed acquisition time in seconds.

  • target_acquisition_counts (int) – Target total X-ray counts for the spectrum.

  • elements (list[str], optional) – Element symbols used by the microscope proprietary quantification to estimate instrument background.

Returns:

  • spectrum_data (Any) – The acquired spectrum data.

  • background_data (Any) – The measured background data.

Raises:

EMError – If the spectrum acquisition fails.