autoemx.config.schema_models.detector_model module

Detector model of a microscope: the physical and empirical parameters used to model its X-ray spectra.

The values of each microscope are saved in autoemx/calibrations/<microscope_ID>/detector_model.json, next to its detector efficiency (detector_efficiency.msa). The functional forms (sigmoids for the peak shape, modified Duncumb model for the background) are defined here; the file holds their coefficients.

To add a microscope, add a folder with these two files, named with its microscope ID, and its driver in autoemx/microscope_drivers. The driver is the file named as the microscope ID, unless driver names another one: instruments of the same model, each with its own calibrated detector model (e.g. ‘PhenomXL_LabB’), share the driver of that model (driver ‘PhenomXL’).

This model replaces the module XS_calibrations.py of each microscope (AutoEMX <= 1.4.1).

It centralizes all physical and empirical calibration data needed for accurate spectrum modeling, including detector characteristics, peak shape, background continuum, and system-specific factors. The channel-to-energy calibration (offset, bin width) is not part of it: it is saved separately in Detector_channel_params_calibs, since it is recalibrated regularly (Run_SDD_Calibration.py).

Notes

  • The values must be customized for every new detector or microscope system: update all calibration values and empirical fits to match the specific hardware and calibration data of each instrument. Failure to do so will result in inaccurate quantification.

  • All calibration parameters should be reviewed and updated regularly, and after the microscope system is serviced.

  • If additional EDS modes are added, every mode-dependent parameter needs an entry for the new mode.

  • All formulas and empirical fits are traceable to published literature or in-house calibration data:
    • Goldstein et al., “Scanning Electron Microscopy and X-ray Microanalysis”, 4th Ed.

    • N.W.M. Ritchie, Spectrum Simulation in DTSA-II, Microsc. Microanal. 15 (2009) 454–468. https://doi.org/10.1017/S1431927609990407

    • R. H. Redus, A. C. Huber (2015). Response Function of Silicon Drift Detectors for Low Energy X-rays. In Advances in X-ray Analysis (AXA), pp. 274–282. International Centre for Diffraction Data (ICDD).

Fine-tuning parameters

weight_Ll_ref_Ka1, escape_peak_probability, pileup_peak_probability, gen_background_time_scaling_factor, strobe_peak_int_factor, zero_strobe_peak_sigma:

  • These values are empirical and not highly sensitive for most quantification tasks; reasonable estimates suffice.

  • Calibration can be performed manually by observing the fitted values in a few high-quality spectra of EDS standards.

  • To do this, allow the parameter(s) to vary freely in your lmfit model (set vary=True), fit the spectrum, and observe the optimized value reported by lmfit. If desired, repeat for several standard spectra to confirm consistency, and use the typical fitted results, or their average.

  • Precise calibration is not critical unless the parameter is set to an extreme or unphysical value.

class autoemx.config.schema_models.detector_model.Sigmoid(*, offset: float, amplitude: float, center: float, steepness: float, scale: float = 1.0)[source]

Bases: BaseModel

scale * (offset + amplitude / (1 + exp(-steepness * (E - center))))

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

offset: float
amplitude: float
center: float
steepness: float
scale: float
class autoemx.config.schema_models.detector_model.PeakShapeParams(*, gamma: Sigmoid, f_tail: Sigmoid, R_e: Sigmoid, F_loss: Sigmoid)[source]

Bases: BaseModel

Peak shape parameters for incomplete charge collection (ICC) low-energy tailing, as functions of the X-ray energy E (keV): gamma (tailing shape), f_tail (fraction of tailing), R_e and F_loss (ICC parameters), all dimensionless.

Calibration Procedure

The energy dependence and values of these parameters should be calibrated empirically using high-count spectra from bulk standards, ideally pure elements, with the script Calibrate_Peak_Shape_Params.py: it refits the spectra with the chosen parameters (gamma, f_tail, R_e, F_loss) fitted freely for the chosen elements, fits the chosen sigmoid coefficients to their values as a function of energy, and prints the coefficients to update.

Accurate calibration of ICC parameters improves modeling of low-energy tailing and the quantitative accuracy of EDS fits, especially for light elements. These parameters are system- and detector-specific, and should be recalibrated after hardware changes or detector servicing (Redus & Huber, 2015).

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

gamma: Sigmoid
f_tail: Sigmoid
R_e: Sigmoid
F_loss: Sigmoid
class autoemx.config.schema_models.detector_model.DuncumbF(*, z_offset: float, z_scale: float)[source]

Bases: BaseModel

1 - exp(-(Z + z_offset) / z_scale)

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

z_offset: float
z_scale: float
class autoemx.config.schema_models.detector_model.BetaParams(*, sigmoid_offset: float, sigmoid_amplitude: float, sigmoid_steepness: float, sigmoid_center: float, gaussian_amplitude: float, gaussian_center: float, gaussian_sigma: float)[source]

Bases: BaseModel

sigmoid_offset + sigmoid_amplitude / (1 + exp(-sigmoid_steepness * (Z - sigmoid_center))) + gaussian_amplitude * exp(-(Z - gaussian_center)**2 / (2 * gaussian_sigma**2))

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

sigmoid_offset: float
sigmoid_amplitude: float
sigmoid_steepness: float
sigmoid_center: float
gaussian_amplitude: float
gaussian_center: float
gaussian_sigma: float
class autoemx.config.schema_models.detector_model.BackgroundParams(*, duncumb_P: Annotated[List[float], MinLen(min_length=3), MaxLen(max_length=3)], duncumb_F: DuncumbF, beta: BetaParams)[source]

Bases: BaseModel

Parameters of the modified Duncumb background model, as functions of the atomic number Z: P (quadratic polynomial, coefficients from the highest power), F, and beta.

Calibration Procedure

The background model parameters (P, F, and beta) should be empirically calibrated using high-count spectra from bulk standards, ideally pure elements covering a range of atomic numbers Z, with the script Calibrate_Background_Params.py: it refits the spectra with the chosen parameters (P, F, beta) fitted freely, fits the chosen coefficients of their functions to their values as a function of Z, and prints the coefficients to update. One parameter can be calibrated at a time, or all together.

Accurate calibration of the background model is essential for quantification, especially for light elements and low-count regions, since it is used for composition-dependent background corrections in the PB method. These parameters are system- and detector-specific, and should be recalibrated after hardware changes or detector servicing.

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

duncumb_P: List[float]
duncumb_F: DuncumbF
beta: BetaParams
class autoemx.config.schema_models.detector_model.DetectorModel(*, schema_version: int = 1, driver: str | None = None, Si_density: float, detector_ch_n: int, emergence_angle: float, undetectable_els: List[str], available_meas_modes: Tuple[str, ...], R_e_background: float, F_loss_background: float, F: float, elec_noise: float, conv_eff: float, weight_Ll_ref_Ka1: Dict[str, float], escape_peak_probability: Dict[str, float], pileup_peak_probability: Dict[str, float], gen_background_time_scaling_factor: Dict[str, float], strobe_peak_int_factor: Dict[str, float], zero_strobe_peak_sigma: Dict[str, float], peak_shape: Dict[str, PeakShapeParams], background: Dict[str, BackgroundParams])[source]

Bases: BaseModel

Detector model of a microscope (see the module docstring).

model_config = {'extra': 'forbid'}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

schema_version: int
driver: str | None
Si_density: float
detector_ch_n: int
emergence_angle: float
undetectable_els: List[str]
available_meas_modes: Tuple[str, ...]
R_e_background: float
F_loss_background: float
F: float
elec_noise: float
conv_eff: float
weight_Ll_ref_Ka1: Dict[str, float]
escape_peak_probability: Dict[str, float]
pileup_peak_probability: Dict[str, float]
gen_background_time_scaling_factor: Dict[str, float]
strobe_peak_int_factor: Dict[str, float]
zero_strobe_peak_sigma: Dict[str, float]
peak_shape: Dict[str, PeakShapeParams]
background: Dict[str, BackgroundParams]
classmethod from_json_file(file_path: str | Path) → DetectorModel[source]
to_json_file(file_path: str | Path, indent: int = 2) → None[source]
fingerprint() → str[source]

Short hash of all values of the detector model (not the driver), e.g. for caches of quantities computed from it.

get_calibrated_peak_shape_params(E, meas_mode: str)[source]

Peak shape parameters for incomplete charge collection (ICC) low-energy tailing.

Parameters:
  • E (float or ndarray) – X-ray energy in keV.

  • meas_mode (str) – EDS mode, must be in available_meas_modes.

Returns:

(gamma, f_tail, R_e, F_loss), see PeakShapeParams.

Return type:

tuple

get_calibrated_background_params(meas_mode: str)[source]

Parameters of the modified Duncumb background model.

Parameters:

meas_mode (str) – EDS mode, must be in available_meas_modes.

Returns:

(gen_bckgrnd_Duncumb_P, gen_bckgrnd_Duncumb_F, beta_expr) - gen_bckgrnd_Duncumb_P: str, expression for the background P parameter as a function of Z - gen_bckgrnd_Duncumb_F: str, expression for the background F parameter as a function of Z - beta_expr: sympy expression for the beta parameter as a function of Z

Return type:

tuple