diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
index f79bf83d40ecb0946c9e0447539b55fa67cd23d6..cac1795f6cc225e00fa599d763ea5a4a4e58d174 100644
--- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
+++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb
@@ -52,6 +52,8 @@
     "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",
     "\n",
+    "# Parameters used for calculating calibration constants\n",
+    "bpix_noise_nitrs = 2  # 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",
     "# Parameters used during selecting raw data trains.\n",
     "min_trains = 1  # Minimum number of trains that should be available to process dark constants. Default 1.\n",
     "max_trains = 1000  # Maximum number of trains to use for processing dark constants. Set to 0 to use all available trains.\n",
@@ -472,13 +474,26 @@
     "        ~np.isfinite(offset_map[mod])\n",
     "    ] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n",
     "    badpixels_map[mod][\n",
-    "        eval_bpidx(noise_map[mod])\n",
-    "    ] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n",
-    "\n",
-    "    badpixels_map[mod][\n",
     "        ~np.isfinite(noise_map[mod])\n",
     "    ] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n",
-    "    if not local_output:\n",
+    "\n",
+    "    nmap = noise_map[mod].copy()\n",
+    "    last_nbpix = 0\n",
+    "    # Calculate NOISE_OUT_OF_THRESHOLD bpix in multiple iterations.\n",
+    "    while bpix_noise_nitrs > 0:\n",
+    "        badpixels_map[mod][\n",
+    "            eval_bpidx(nmap)\n",
+    "        ] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n",
+    "        nmap[badpixels_map[mod] > 0] = np.nan\n",
+    "        recent_nbpix = np.count_nonzero(badpixels_map[mod])\n",
+    "\n",
+    "        if last_nbpix == recent_nbpix:\n",
+    "            bpix_noise_nitrs = 0\n",
+    "        else:\n",
+    "            bpix_noise_nitrs = bpix_noise_nitrs - 1\n",
+    "        last_nbpix = recent_nbpix\n",
+    "\n",
+    "    if 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",