From 0a2927865d7ac7b25b02b6697a65ea4e9ecaaec6 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Tue, 19 Nov 2024 14:45:47 +0100
Subject: [PATCH] fix: add gh2_detector in the first notebook cell

---
 .../Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb      | 5 ++++-
 notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb     | 8 +++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
index 9319d4fff..e7dbfc9cd 100644
--- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
+++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
@@ -51,6 +51,8 @@
     "exposure_period = -1.  # Detector exposure period, set to -1 to use value in raw file.\n",
     "acquisition_rate = -1.  # Detector acquisition rate (1.1/4.5), set to -1 to use value in raw file.\n",
     "single_photon = -1  # Detector single photon mode (High/Low CDS), set to -1 to use value in raw file.\n",
+    "# This is used for the summary notebook\n",
+    "gh2_detector = \"\"  # Specifies the GH2 detector type ('50um' or '25um'). This parameter can be used to manually set the detector type if the code cannot automatically determine it from the control data.\n",
     "\n",
     "# Parameters used for calculating calibration constants\n",
     "bpix_noise_nitrs = 5  # number of maximum iterations to actively try to reach correct number of badpixels of NOISE_OUT_OF_THRESHOLD type. Leave -1 to keep iterating until finding maximum number of badpixels.\n",
@@ -206,7 +208,8 @@
     "print(\"Single photon: \", single_photon)\n",
     "acquisition_rate = conditions[\"acquisition_rate\"].pop()\n",
     "print(\"Acquisition rate: \", acquisition_rate)\n",
-    "gh2_detector = g2ctrl.get_det_type()\n",
+    "if not gh2_detector:\n",
+    "    gh2_detector = g2ctrl.get_det_type()\n",
     "print(f\"Processing {gh2_detector} Gotthard2.\")"
    ]
   },
diff --git a/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb
index 3780f9266..b4f6df31e 100644
--- a/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb
+++ b/notebooks/Gotthard2/Summary_Darks_Gotthard2_NBC.ipynb
@@ -31,6 +31,8 @@
     "ctrl_source_template = '{karabo_id}/DET/{control_template}'  # template for control source name (filled with karabo_id_control)\n",
     "karabo_id_control = \"\"  # Control karabo ID. Set to empty string to use the karabo-id\n",
     "\n",
+    "gh2_detector = \"\"  # Specifies the GH2 detector type ('50um' or '25um'). This parameter can be used to manually set the detector type if the code cannot automatically determine it from the control data.\n",
+    "\n",
     "# Parameters to be used for injecting dark calibration constants.\n",
     "local_output = True  # Boolean indicating that local constants were stored in the out_folder\n",
     "\n",
@@ -91,7 +93,11 @@
     "        karabo_id_control=karabo_id_control,\n",
     "        control_template=control_template\n",
     "    ))\n",
-    "gh2_detector = g2ctrl.get_det_type()\n",
+    "if not gh2_detector:\n",
+    "    # Unfortunately we can't check if we can't validate this value\n",
+    "    # as the notebook will have only one karabo_da anyway.\n",
+    "    # Dark processing split nodes over each karabo_da\n",
+    "    gh2_detector = g2ctrl.get_det_type()\n",
     "print(f\"Processing {gh2_detector} Gotthard2.\")"
    ]
   },
-- 
GitLab