From 1fafed6b797b785e8184656ad7406854e635e4d4 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Wed, 18 Sep 2024 09:09:35 +0200
Subject: [PATCH] move OFFSET_NOISE_EVAL_ERROR into the loop as well as it is
 calculated from noise map also

---
 .../Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
index a9f6b0507..32a4f221c 100644
--- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
+++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
@@ -473,19 +473,19 @@
     "    badpixels_map[mod][\n",
     "        ~np.isfinite(offset_map[mod])\n",
     "    ] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n",
-    "    badpixels_map[mod][\n",
-    "        ~np.isfinite(noise_map[mod])\n",
-    "    ] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n",
     "\n",
-    "    nmap = noise_map[mod].copy()\n",
-    "    last_nbpix = 0\n",
-    "    # Iteratively identify noisy pixels (NOISE_OUT_OF_THRESHOLD)\n",
+    "    # Iteratively identify noisy pixels (OFFSET_NOISE_EVAL_ERROR & NOISE_OUT_OF_THRESHOLD)\n",
     "    # Due to the low number of strips (1280), outliers can significantly impact\n",
     "    # the badpixel calculation. We use multiple iterations to gradually refine\n",
     "    # the sigma threshold, as a single fixed threshold may not be suitable for\n",
     "    # different Gotthard2 detectors.\n",
+    "    last_nbpix = 0\n",
+    "    nmap = noise_map[mod].copy()\n",
     "    for itr in range(bpix_noise_nitrs):\n",
     "        badpixels_map[mod][\n",
+    "            ~np.isfinite(nmap)\n",
+    "        ] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n",
+    "        badpixels_map[mod][\n",
     "            eval_bpidx(nmap)\n",
     "        ] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n",
     "        nmap[badpixels_map[mod] > 0] = np.nan\n",
-- 
GitLab