diff --git a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb index b0e2702009ff264d08a1e9375ff23ed3b67372b6..031dbce99f766e589710e9deb077c0c877cda2e0 100644 --- a/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Characterize_Darks_Gotthard2_NBC.ipynb @@ -285,7 +285,6 @@ " print_once=False,\n", " )\n", "\n", - "\n", " # Path to pixels ADC values\n", " instr_mod_src = instrument_src.format(int(mod[-2:]))\n", "\n", @@ -358,8 +357,11 @@ "def eval_bpidx(d):\n", " mdn = np.nanmedian(d, axis=(0))[None, :, :]\n", " std = np.nanstd(d, axis=(0))[None, :, :] \n", - " idx = (d > badpixel_threshold_sigma*std+mdn) | (d < (-badpixel_threshold_sigma)*std+mdn)\n", - "\n", + " idx = (\n", + " d > badpixel_threshold_sigma * std + mdn\n", + " ) | (\n", + " d < (-badpixel_threshold_sigma) * std + mdn\n", + " )\n", " return idx" ] }, @@ -383,13 +385,13 @@ "step_timer.start()\n", "g_name = ['G0', 'G1', 'G2']\n", "\n", - "for mod in karabo_da:\n", + "for mod, pdu in zip(karabo_da, db_modules):\n", " display(Markdown(f\"### Badpixels for module {mod}:\"))\n", "\n", - " badpixels_map[mod][~np.isfinite(offset_map[mod])] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n", + " badpixels_map[mod][~np.isfinite(offset_map[mod])] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value # npqa\n", " badpixels_map[mod][eval_bpidx(noise_map[mod])] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n", "\n", - " badpixels_map[mod][~np.isfinite(noise_map[mod])] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n", + " badpixels_map[mod][~np.isfinite(noise_map[mod])] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value # noqa\n", "\n", "\n", " for cell in [0, 1]:\n", @@ -399,7 +401,7 @@ " ax.set_xticks(np.arange(0, 1281, 80))\n", " ax.set_xlabel(\"Stripes #\")\n", " ax.set_xlabel(\"BadPixels\")\n", - " ax.set_title(f'Cell {cell} - Module {mod}')\n", + " ax.set_title(f'Cell {cell} - Module {mod} ({pdu})')\n", " ax.set_ylim([0, BadPixels.WRONG_GAIN_VALUE.value])\n", " ax.set_yticks([0,\n", " BadPixels.NOISE_OUT_OF_THRESHOLD.value,\n", @@ -420,13 +422,9 @@ "step_timer.start()\n", "g_name = ['G0', 'G1', 'G2']\n", "\n", - "for mod in karabo_da:\n", + "for mod, pdu in zip(karabo_da, db_modules):\n", " display(Markdown(f\"### Badpixels for module {mod}:\"))\n", "\n", - " badpixels_map[mod][~np.isfinite(offset_map[mod])] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n", - " badpixels_map[mod][eval_bpidx(noise_map[mod])] |= BadPixels.NOISE_OUT_OF_THRESHOLD.value\n", - " badpixels_map[mod][~np.isfinite(noise_map[mod])] |= BadPixels.OFFSET_NOISE_EVAL_ERROR.value\n", - "\n", " for g_idx in [0, 1, 2]:\n", " # for cell in [0, 1]:\n", " heatmapPlot(\n", @@ -434,9 +432,8 @@ " y_label=\"Stripes\",\n", " x_label=\"Cells\",\n", "# lut_label=unit,\n", - " \n", " vmin=0, vmax=5,\n", - " title=f\"Even / Odd Offset map G{g_idx} - Module {mod}\", # TODO: add PDU name({pdu})',\n", + " title=f\"Even / Odd Offset map G{g_idx} - Module {mod} ({pdu})\",\n", " )\n", " pass\n", "step_timer.done_step(f'Creating bad pixels constant and plotting it.')" @@ -449,10 +446,9 @@ "metadata": {}, "outputs": [], "source": [ - "from XFELDetAna.plotting.heatmap import heatmapPlot\n", "unit = '[ADCu]'\n", "\n", - "for mod in karabo_da:\n", + "for mod, pdu in zip(karabo_da, db_modules):\n", " for _, [gain, _] in run_dcs_dict.items():\n", " heatmapPlot(\n", " offset_map[mod][:, :, gain],\n", @@ -462,7 +458,7 @@ " x_ticks=[0.5, 1.5],\n", " x_ticklabels=[\"EVEN\", \"ODD\"],\n", " x_tick_rotation=0,\n", - " title=f\"Even / Odd Offset map G{gain} - Module {mod}\", # TODO: add PDU name({pdu})',\n", + " title=f\"Even / Odd Offset map G{gain} - Module {mod} ({pdu})\",\n", " )\n", " heatmapPlot(\n", " noise_map[mod][:, :, gain],\n", @@ -472,7 +468,7 @@ " x_ticks=[0.5, 1.5],\n", " x_ticklabels=[\"EVEN\", \"ODD\"],\n", " x_tick_rotation=0,\n", - " title=f\"Even / Odd noise map G{gain} - Module {mod}\", # TODO: add PDU name({pdu})',\n", + " title=f\"Even / Odd noise map G{gain} - Module {mod} ({pdu})\",\n", " )\n", " pass" ] @@ -484,7 +480,7 @@ "metadata": {}, "outputs": [], "source": [ - "for mod in karabo_da:\n", + "for mod, pdu in zip(karabo_da, db_modules):\n", " for cons, cname in zip([offset_map, noise_map], [\"Offset\", \"Noise\"]):\n", " for cell in [0, 1]:\n", " fig, ax = plt.subplots(figsize=(10, 5))\n", @@ -493,7 +489,7 @@ "\n", " ax.set_xlabel(\"Stripes #\")\n", " ax.set_xlabel(cname)\n", - " ax.set_title(f\"{cname} map - Cell {cell} - Module {mod}\"), # TODO: add PDU name({pdu})'\n", + " ax.set_title(f\"{cname} map - Cell {cell} - Module {mod} ({pdu})\"),\n", " ax.legend()\n", " pass" ] @@ -508,8 +504,9 @@ "step_timer.start()\n", "for mod, db_mod in zip(karabo_da, db_modules):\n", " constants = {\n", - " 'Offset': offset_map[mod],\n", - " 'Noise': noise_map[mod],\n", + " \"Offset\": offset_map[mod],\n", + " \"Noise\": noise_map[mod],\n", + " \"BadPixelsDark\": badpixels_map[mod]\n", " }\n", "\n", " md = None\n",