diff --git a/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb index 1db8e59f99a8317858a99e2f5966bc88f24a849f..55be915015324c3668b9e5f2d32590ee4d0ae485 100644 --- a/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb @@ -196,7 +196,7 @@ "gs = gridspec.GridSpec(2, 4)\n", "\n", "axes = {\n", - " \"ax0\": {\n", + " \"map\": {\n", " \"gs\": gs[0, 1:3],\n", " \"shrink\": 0.7,\n", " \"pad\": 0.05,\n", @@ -204,7 +204,7 @@ " \"title\": \"{}\",\n", " \"location\": \"right\",\n", " },\n", - " \"ax1\": {\n", + " \"diff\": {\n", " \"gs\": gs[1, :2],\n", " \"shrink\": 0.7,\n", " \"pad\": 0.02,\n", @@ -212,7 +212,7 @@ " \"location\": \"left\",\n", " \"title\": \"Difference with previous {}\",\n", " },\n", - " \"ax2\": {\n", + " \"diff_frac\": {\n", " \"gs\": gs[1, 2:],\n", " \"shrink\": 0.7,\n", " \"pad\": 0.02,\n", @@ -275,15 +275,25 @@ " # Prepare the stacked mean of constant,\n", " # the difference with the previous constant\n", " # and the fraction of that difference.\n", + "\n", " mean_const = np.nanmean(const, axis=3)\n", - " mean_diff = np.abs(np.nanmean(const, axis=3) - np.nanmean(prev_constants[cname], axis=3)) # noqa\n", - " mean_frac = np.abs(mean_diff / mean_const) * 100\n", - " \n", + " mean_diff = np.abs(\n", + " np.nanmean(const, axis=3) - np.nanmean(\n", + " prev_constants[cname],\n", + " axis=3)\n", + " )\n", + " mean_frac = np.divide(\n", + " mean_diff,\n", + " mean_const,\n", + " out=np.zeros_like(mean_const),\n", + " where=(mean_const != 0)\n", + " ) * 100\n", + "\n", " for gain in range(gainstages):\n", " data_to_plot = {\n", - " f'ax0': mean_const[..., gain],\n", - " f'ax1': mean_diff[..., gain],\n", - " f'ax2': mean_frac[..., gain],\n", + " f'map': mean_const[..., gain],\n", + " f'diff': mean_diff[..., gain],\n", + " f'diff_frac': mean_frac[..., gain],\n", " }\n", "\n", " # Plotting constant overall modules.\n", @@ -297,13 +307,11 @@ "\n", " # Avoid difference plots if previous constants\n", " # are missing for the detector.\n", - " if cname in exculded_constants and axname != \"ax0\":\n", + " if cname in exculded_constants and axname != \"map\":\n", " break\n", " ax = fig.add_subplot(axv[\"gs\"])\n", "\n", - " if axname == \"ax2\": # Difference in percentage\n", - " vmin, vmax = (0, 100)\n", - " elif badpx(cname):\n", + " if badpx(cname):\n", " vmin, vmax = (0, sorted([bp.value for bp in badpixels])[-2])\n", " else:\n", " vmin, vmax = np.percentile(data_to_plot[axname], [5, 95])\n", @@ -327,7 +335,7 @@ " ax.set_title(axv[\"title\"].format(\n", " f\"{cname} {gain_names[gain]}\"), fontsize=15)\n", " \n", - " if axname == \"ax0\":\n", + " if axname == \"map\":\n", " ax.set_xlabel('Columns', fontsize=15)\n", " ax.set_ylabel('Rows', fontsize=15)\n", " ax.tick_params(labelsize=15)\n",