autoemx.config.schema_models.acquisition module

class autoemx.config.schema_models.acquisition.Coordinate2D(*, x: float, y: float)[source]

Bases: BaseModel

Simple 2D coordinate pair.

x: float
y: float
model_config = {'extra': 'forbid'}

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

classmethod validate_coordinate(v: float) → float[source]
class autoemx.config.schema_models.acquisition.SpotCoordinates(*, machine_coordinates: Coordinate2D | None = None, pixel_coordinates: Tuple[int, int] | None = None)[source]

Bases: BaseModel

Acquisition spot coordinates within a frame image.

machine_coordinates are normalized frame-relative coordinates (as used by the EM API), not absolute stage positions in mm. They are derived from pixel_coordinates via frame_pixel_to_rel_coords.

machine_coordinates: Coordinate2D | None
pixel_coordinates: Tuple[int, int] | None
model_config = {'extra': 'forbid'}

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

classmethod validate_pixel_coordinates(v: Tuple[int, int] | None) → Tuple[int, int] | None[source]
class autoemx.config.schema_models.acquisition.AcquisitionDetails(*, frame_id: str | None = None, particle_id: int | None = None, spot_coordinates: SpotCoordinates | None = None)[source]

Bases: BaseModel

Structured acquisition context for one spectrum.

frame_id: str | None
particle_id: int | None
spot_coordinates: SpotCoordinates | None
model_config = {'extra': 'forbid'}

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

classmethod normalize_frame_id(v: str | None) → str | None[source]
classmethod validate_particle_id(v: int | None) → int | None[source]
class autoemx.config.schema_models.acquisition.ParticleInfo(*, id: int, area_um: float | None = None, eq_diameter_um: float | None = None, coordinates: Coordinate2D | None = None, frame_id: str | None = None, image_pixel_size_um: float | None = None, clusters: List[int] = <factory>, composition: str | None = None, selection: Literal['size_stats', 'auto', 'manual', 'list'] | None=None, edge_correction: float | None = None)[source]

Bases: BaseModel

Geometry and analysis summary for one segmented particle.

coordinates are absolute stage positions in mm of the particle center. They are not the frame-relative SpotCoordinates.machine_coordinates. image_pixel_size_um is the pixel size of the particle image saved with the spectrum spots (SEM images/<sample>_par<id>_fr<frame>_xyspots), in which the SpotCoordinates.pixel_coordinates of its spectra are given. selection is how the particle was chosen: found by a particle size statistics measurement (‘size_stats’), or measured by EDS with particle selection mode ‘auto’, ‘manual’ or ‘list’ (None in ledgers saved before AutoEMX recorded it). edge_correction is the Miles-Lantuéjoul correction of a particle found by particle size statistics: the inverse of the fraction of frame positions where it would not touch the frame edge (particles touching it are left out), by which its weight is multiplied so that large particles are not under-counted.

id: int
area_um: float | None
eq_diameter_um: float | None
coordinates: Coordinate2D | None
frame_id: str | None
image_pixel_size_um: float | None
clusters: List[int]
composition: str | None
selection: Literal['size_stats', 'auto', 'manual', 'list'] | None
edge_correction: float | None
model_config = {'extra': 'forbid'}

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

classmethod validate_id(v: int) → int[source]
classmethod validate_positive_finite(v: float | None) → float | None[source]
classmethod normalize_frame_id(v: str | None) → str | None[source]
classmethod validate_edge_correction(v: float | None) → float | None[source]
class autoemx.config.schema_models.acquisition.SpectrumEntry(*, spectrum_id: str | None = None, total_counts: int | None = None, live_acquisition_time: float, acquisition_details: AcquisitionDetails | None = None, spectrum_relpath: str | None = None, instrument_background_relpath: str | None = None, quantification_results: List[QuantificationResult] = <factory>)[source]

Bases: BaseModel

Minimal per-spectrum record inside a sample ledger.

spectrum_id: str | None
total_counts: int | None
live_acquisition_time: float
acquisition_details: AcquisitionDetails | None
spectrum_relpath: str | None
instrument_background_relpath: str | None
quantification_results: List[QuantificationResult]
model_config = {'extra': 'forbid'}

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

classmethod drop_legacy_fields(data: Any) → Any[source]

Drop removed legacy fields so old ledger JSON remains loadable.

classmethod validate_live_acquisition_time(v: float) → float[source]
classmethod validate_total_counts(v: int | None) → int | None[source]
classmethod validate_spectrum_relpath(v: str | None) → str | None[source]
classmethod validate_instrument_background_relpath(v: str | None) → str | None[source]
validate_total_and_background() → SpectrumEntry[source]