autoemx.utils.legacy.ledger_bootstrap module
Ledger bootstrap helpers with optional legacy Data.csv compatibility.
- autoemx.utils.legacy.ledger_bootstrap.strip_min_background_comment_phrase(comment: str | None) str | None[source]
Remove legacy min-background-counts text while preserving the rest of the comment.
- autoemx.utils.legacy.ledger_bootstrap.convert_machine_to_pixel_coordinates(machine_x: Any, machine_y: Any, *, sample_result_dir: str, frame_id: str | None, microscope_id: str | None, cache: Dict[str, Tuple[int, int] | None] | None = None) Tuple[float | None, float | None][source]
Convert normalized machine coordinates to pixel coordinates with em_driver.
- autoemx.utils.legacy.ledger_bootstrap.load_legacy_acquisition_details_by_spectrum_id(data_csv_path: str, *, sample_result_dir: str, microscope_id: str | None) Dict[str, AcquisitionDetails][source]
Load acquisition details keyed by spectrum id from legacy Data.csv.
- autoemx.utils.legacy.ledger_bootstrap.load_legacy_quantification_results_by_spectrum_id(data_csv_path: str) Dict[str, List[QuantificationResult]][source]
Load quantification results keyed by spectrum id from legacy Data.csv.
- autoemx.utils.legacy.ledger_bootstrap.build_legacy_import_quantification_config(*, sample_result_dir: str, ledger_configs: Any) QuantificationConfig[source]
Build legacy quantification config with standards-derived reference values.
- autoemx.utils.legacy.ledger_bootstrap.build_legacy_msa_pointer_writer(sample_result_dir: str, xperchan: float, offset: float) Callable[[...], str][source]
Build a resolver callback that writes .msa pointer files from legacy Data.csv rows.
- autoemx.utils.legacy.ledger_bootstrap.build_legacy_background_pointer_writer(sample_result_dir: str) Callable[[...], str | None][source]
Build a callback that writes manufacturer background vectors for legacy backfill.
- autoemx.utils.legacy.ledger_bootstrap.resolve_legacy_bootstrap_configs(*, sample_result_dir: str, default_ledger_configs: LedgerConfigs) Tuple[LedgerConfigs, Dict[str, Any] | None][source]
Resolve ledger/runtime configs from legacy JSON files when available.
- Returns a tuple of:
Ledger configs to use for legacy bootstrap.
Legacy runtime configs payload (or None if unavailable).
- autoemx.utils.legacy.ledger_bootstrap.load_or_create_ledger_with_legacy_data_csv(*, sample_result_dir: str, sample_id: str, microscope_id: str | None, use_instrument_background: bool, default_ledger_configs: LedgerConfigs, resolve_or_create_spectrum_pointer: Callable[[...], str], write_background_pointer: Callable[[...], str | None] | None = None) SampleLedger[source]
Load a ledger or bootstrap it from legacy Data.csv when no ledger exists yet.
- autoemx.utils.legacy.ledger_bootstrap.create_analyzer_ledger_from_legacy_data_csv(analyzer: Any, *, default_ledger_configs: LedgerConfigs, write_background_pointer: Callable[[...], str | None] | None = None) SampleLedger[source]
Create the ledger of a composition analyzer from the legacy Data.csv of its sample (no ledger.json yet).
The configurations recovered from the legacy JSON files replace those of the analyzer (and its energy axis is recomputed from the recovered detector calibration), and the spectrum files are reconstructed from Data.csv when missing.
- Parameters:
analyzer (EMXSp_Composition_Analyzer) – Analyzer of the sample (sample_result_dir, sample_id, configurations, energy_vals).
default_ledger_configs (LedgerConfigs) – Configurations of the analyzer, used for those not found in the legacy files.
write_background_pointer (callable, optional) – Writes the manufacturer background of a spectrum to its file, if instrument backgrounds are used.