From edea3987466fd5bdd50ec00e83031f481db5ea38 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Wed, 20 Nov 2024 18:00:18 +0100
Subject: [PATCH] feat: add new parameter to exclude first ntrains from dark
 processing

---
 .../Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb   | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb
index c4ffa097a..0d63bf4ec 100644
--- a/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb
+++ b/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb
@@ -44,6 +44,7 @@
     "offset_abs_threshold_high = [8000, 15000, 15000]  # absolute bad pixel threshold in terms of offset, upper values\n",
     "max_trains = 1000  # Maximum trains to process darks. Set to 0 to process all available train images. 1000 trains is enough resolution to create the dark constants\n",
     "min_trains = 100  # Minimum number of trains to process dark constants. Raise a warning if the run has fewer trains.\n",
+    "exclude_ntrains = 0  # Number of first number of trains to exclude from dark processing.\n",
     "manual_slow_data = False  # if true, use manually entered bias_voltage and integration_time values\n",
     "time_limits = 0.025  # to find calibration constants later on, the integration time is allowed to vary by 0.5 us\n",
     "creation_time = \"\"  # To overwrite the measured creation_time. Required Format: YYYY-MM-DD HR:MN:SC e.g. \"2022-06-28 13:00:00\"\n",
@@ -378,8 +379,11 @@
     "        if n_trains < min_trains:\n",
     "            warning(f\"Less than {min_trains} trains are available in RAW data.\")\n",
     "\n",
+    "        if exclude_ntrains:\n",
+    "            print(f\"Excluding first {exclude_ntrains} from processing as configured.\")\n",
+    "\n",
     "        # Select only requested number of images to process darks.\n",
-    "        instr_dc = instr_dc.select_trains(np.s_[:n_trains])\n",
+    "        instr_dc = instr_dc.select_trains(np.s_[exclude_ntrains:n_trains])\n",
     "        images = np.transpose(\n",
     "            instr_dc[instrument_src, \"data.adc\"].ndarray(), (3, 2, 1, 0))\n",
     "        acelltable = np.transpose(instr_dc[instrument_src, \"data.memoryCell\"].ndarray())\n",
-- 
GitLab