autoemx.config.schema_models.ledger module
- class autoemx.config.schema_models.ledger.LedgerConfigs(*, microscope_cfg: MicroscopeConfig, sample_cfg: SampleConfig, measurement_cfg: MeasurementConfig, sample_substrate_cfg: SampleSubstrateConfig, plot_cfg: PlotConfig)[source]
Bases:
BaseModelTyped config bundle persisted in the ledger.
- microscope_cfg: MicroscopeConfig
- sample_cfg: SampleConfig
- measurement_cfg: MeasurementConfig
- sample_substrate_cfg: SampleSubstrateConfig
- plot_cfg: PlotConfig
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod move_legacy_exp_std_w_frs(data: Any) Any[source]
Legacy compatibility: move the standard’s mass fractions from exp_stds_cfg to sample_cfg.
Old ledgers stored them in measurement_cfg.exp_stds_cfg.w_frs.
- set_exp_std_w_frs() LedgerConfigs[source]
Set the composition of an experimental standard from its formula, when not stored yet.
- property powder_meas_cfg: PowderMeasurementConfig | None
- property bulk_meas_cfg: BulkMeasurementConfig | None
- property exp_stds_cfg: ExpStandardsConfig | None
- exception autoemx.config.schema_models.ledger.LedgerVersionError[source]
Bases:
ValueErrorRaised when a ledger written by a newer AutoEMX version cannot be read by the installed one.
- class autoemx.config.schema_models.ledger.SampleLedger(*, autoemx_version: str = '1.8.0', sample_id: str, sample_path: str, configs: ~autoemx.config.schema_models.ledger.LedgerConfigs, spectra: ~typing.List[~autoemx.config.schema_models.acquisition.SpectrumEntry], particles: ~typing.List[~autoemx.config.schema_models.acquisition.ParticleInfo] = <factory>, frames: ~typing.List[~autoemx.config.schema_models.frames.FrameRecord] = <factory>, segmentations: ~typing.List[~autoemx.config.schema_models.segmentation.SegmentationConfig] = <factory>, size_measurements: ~typing.List[~autoemx.config.schema_models.particle_stats.SizeMeasurement] = <factory>, size_results: ~typing.List[~autoemx.config.schema_models.particle_stats.ParticleSizeStatsResult] = <factory>, active_size_result: int | None = None, active_quant: int | None = None, quantifications: ~typing.List[~autoemx.config.schema_models.quantification.QuantificationConfig] = <factory>)[source]
Bases:
BaseModelSingle-sample ledger with per-spectrum pointers and configuration bundle.
- autoemx_version: str
- sample_id: str
- sample_path: str
- configs: LedgerConfigs
- spectra: List[SpectrumEntry]
- particles: List[ParticleInfo]
- frames: List[FrameRecord]
- segmentations: List[SegmentationConfig]
- size_measurements: List[SizeMeasurement]
- size_results: List[ParticleSizeStatsResult]
- active_size_result: int | None
- active_quant: int | None
- quantifications: List[QuantificationConfig]
- model_config = {'extra': 'forbid'}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- classmethod move_legacy_size_statistics(data: Any) Any[source]
Legacy compatibility: particle size statistics saved before frames and segmentations were recorded.
- classmethod move_legacy_known_phase_mixture(data: Any) Any[source]
Legacy compatibility: is_known_powder_mixture_meas (powder settings) is now the quantification setting is_known_phase_mixture, stored in the options of each quantification run.
- validate_ledger_integrity() SampleLedger[source]
- property size_result: ParticleSizeStatsResult | None
The active particle size statistics result (None if there is none).
- frame(frame_id: str) FrameRecord | None[source]
- measurement(measurement_id: int | None) SizeMeasurement | None[source]
- segmentation(segmentation_id: int | None) SegmentationConfig | None[source]
- frames_of(purpose: str | None = None, measurement_id: int | None = None) List[FrameRecord][source]
Frames acquired for a purpose (‘eds_search’ or ‘size_stats’), and/or by a measurement.
- unique_frame_id(frame_id: str) str[source]
frame_id, made unique in the ledger with a#2,#3, … suffix (frame acquired again).
- add_frame(frame: FrameRecord) FrameRecord[source]
Add an acquired frame (its id made unique if needed), returned as recorded.
- append_segmentation(config: SegmentationConfig) int[source]
Id of the segmentation with these settings: an existing one, or
configadded with a new id.
- add_frame_segmentation(frame_id: str, result: FrameSegmentation) None[source]
Add the result of a segmentation of a frame (never replacing one).
- append_size_result(result: ParticleSizeStatsResult) ParticleSizeStatsResult[source]
Add a statistics result and make it the active one: it replaces a result computed from the same inputs (measurement, segmentations, frames and particles left out), e.g. recalculated after more EDS frames; otherwise it gets a new id. Returns the result as recorded.
- append_quantification_config(quant_config: QuantificationConfig) None[source]
Append a quantification config, enforcing unique config identifiers.
- append_quantification_result(spectrum_index: int, result: QuantificationResult) None[source]
Append a quantification result to the requested spectrum entry.
- classmethod from_json_file(file_path: str | Path) SampleLedger[source]
Load and validate a ledger from JSON in one call.
- Raises:
LedgerVersionError – If the ledger cannot be read because it was written by a newer AutoEMX version.