diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb index 5ece45ff6a7f18f0deed55c2164cf6869f5cca59..a9f6b0507633dc4d0012e76d87d55a52f72939ba 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",