From 9b368d8221cc01afe84b5a49d8680b05d819f6c0 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Mon, 29 Jul 2024 16:59:17 +0200 Subject: [PATCH] fix: move checking da/affixes numbers to corr notebook only --- .../Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb | 9 +++++---- notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb | 3 +++ src/cal_tools/gotthard2/gotthard2lib.py | 7 +------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb index 2b63c4f9b..5c49f27a3 100644 --- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb @@ -134,9 +134,7 @@ "source": [ "run_dc = RunDirectory(in_folder / f\"r{run_nums[0]:04d}\")\n", "proposal = list(filter(None, str(in_folder).strip('/').split('/')))[-2]\n", - "file_loc = raw_data_location_string(proposal, run_nums)\n", - "da_to_source = gotthard2lib.map_da_to_source(\n", - " karabo_da, receiver_affixes, receiver_template, run_dc)" + "file_loc = raw_data_location_string(proposal, run_nums)" ] }, { @@ -235,7 +233,10 @@ "else:\n", " karabo_da = list(da_to_pdu.keys())\n", "\n", - "print(f\"Processing {karabo_da}\")" + "print(f\"Processing {karabo_da}\")\n", + "\n", + "da_to_source = gotthard2lib.map_da_to_source(\n", + " karabo_da, receiver_affixes, receiver_template, run_dc)" ] }, { diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb index 3a0f6234c..cc5859219 100644 --- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb @@ -239,6 +239,9 @@ " db_modules = [da_to_pdu[da] for da in karabo_da]\n", "\n", "print(f\"Process modules: {db_modules} for run {run}\")\n", + "if len(receiver_affixes) != len(karabo_da):\n", + " raise ValueError(\n", + " \"receiver_affixes & karabo_da are not the same length\")\n", "\n", "da_to_source = gotthard2lib.map_da_to_source(\n", " karabo_da, receiver_affixes, receiver_template, run_dc)\n", diff --git a/src/cal_tools/gotthard2/gotthard2lib.py b/src/cal_tools/gotthard2/gotthard2lib.py index d6fa4eba6..bf62d9083 100644 --- a/src/cal_tools/gotthard2/gotthard2lib.py +++ b/src/cal_tools/gotthard2/gotthard2lib.py @@ -5,12 +5,7 @@ from typing import List, Union import extra_data -def map_da_to_source( - da, affixes, template, dc): - if len(affixes) != len(da): - raise ValueError( - "receiver_affixes & karabo_da are not the same length") - +def map_da_to_source(da, affixes, template, dc): da_to_source = {} for da, aff in zip(da, affixes): sources = dc.select(f"*{template.format(aff)}:daqOutput").all_sources -- GitLab