From 014e8a94fef47111fdf49f64d573fce111ff84a4 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Wed, 18 Sep 2024 08:21:23 +0200 Subject: [PATCH] improve comment and use for loop instead --- .../Characterize_Darks_Gotthard2_NBC.ipynb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb index 5ece45ff6..a9f6b0507 100644 --- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb @@ -479,9 +479,12 @@ "\n", " nmap = noise_map[mod].copy()\n", " last_nbpix = 0\n", - " # Calculate NOISE_OUT_OF_THRESHOLD bpix in multiple iterations.\n", - " nitr = -1\n", - " while nitr != bpix_noise_nitrs:\n", + " # Iteratively identify noisy pixels (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", + " for itr in range(bpix_noise_nitrs):\n", " badpixels_map[mod][\n", " eval_bpidx(nmap)\n", " ] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n", @@ -489,13 +492,10 @@ " recent_nbpix = np.count_nonzero(badpixels_map[mod])\n", "\n", " if last_nbpix == recent_nbpix:\n", - " # skip iterations if no more difference.\n", - " nitr = bpix_noise_nitrs\n", - " else:\n", - " nitr += 1\n", - " last_nbpix = recent_nbpix\n", + " # stop iterating if no more badpixels difference\n", + " break\n", "\n", - " if local_output:\n", + " if not local_output:\n", " for cell in [0, 1]:\n", " fig, ax = plt.subplots(figsize=(10, 5))\n", " for g_idx in [0, 1, 2]:\n", -- GitLab