From 064a1d5cab1cd94affce2cf5f992c714df62b7f2 Mon Sep 17 00:00:00 2001 From: GotthardG <51994228+GotthardG@users.noreply.github.com> Date: Mon, 17 Aug 2026 15:36:53 +0200 Subject: [PATCH] feat(models): fluorescence ingest contract shared with AareDB MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FluorescenceScanIngestModel wraps the existing FluorescenceSpectrumOutputModel with the sample it belongs to — the payload for AareDB's POST /dispatcher/protected_router/fluorescence/ ingest. FluorescenceScanIngestResponseModel returns the stored scan id plus the elements AareDB identified from the peaks, so the beamline GUI can display what was detected. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01F3xoBJBmqJJPLg475iK6cE --- src/aarecommon/models/models.py | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/aarecommon/models/models.py b/src/aarecommon/models/models.py index 5df96c2..493f922 100644 --- a/src/aarecommon/models/models.py +++ b/src/aarecommon/models/models.py @@ -239,6 +239,34 @@ class FluorescenceSpectrumOutputModel(BaseModel): average_dead_time: Annotated[float, Field(ge=0, le=1)] +class FluorescenceElementModel(BaseModel): + """One emission line AareDB identified in a stored fluorescence spectrum.""" + + symbol: str + line: str # "Ka" or "La" + energy_ev: float # tabulated line energy + peak_energy_ev: float # where the matching peak actually sits + counts: float # peak height + confidence: float # 1.0 alpha+beta matched, 0.5 alpha only + + +class FluorescenceScanIngestModel(BaseModel): + """AareDB fluorescence ingest payload: the measured spectrum plus the + sample it belongs to (POST /dispatcher/protected_router/fluorescence/ingest).""" + + sample_id: int + scan: FluorescenceSpectrumOutputModel + comment: str | None = None + + +class FluorescenceScanIngestResponseModel(BaseModel): + """AareDB's ingest response — the beamline GUI shows the detected elements.""" + + id: int + sample_event_id: int + elements: list[FluorescenceElementModel] = [] + + class MLBoxType(Enum): LOOP_ALL = 0 PIN = 1 -- 2.54.0