From 0910bfd6de647fc4ffb7955af2c8f9f57f5e51ed Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Thu, 8 Feb 2024 15:16:13 +0100 Subject: [PATCH] preserve range boundaries for gain and pulse plots --- .../AGIPD/AGIPD_Correct_and_Verify.ipynb | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index 32f9b4aa7..b9048f088 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -1045,11 +1045,13 @@ "metadata": {}, "outputs": [], "source": [ + "vmin, vmax = np.percentile(corrected, [0, 100])\n", "hist, bins_x, bins_y = calgs.histogram2d(\n", " corrected.flatten().astype(np.float32),\n", " gains.flatten().astype(np.float32), bins=(100, 3),\n", " range=[\n", - " np.percentile(corrected, [0, 100]),\n", + " # The range boundaries and decided by DET expert.\n", + " [max(vmin, -50), min(vmax, 8192)],\n", " [0, 3]\n", " ],\n", " )\n", @@ -1090,20 +1092,22 @@ " pulse_range = [0, pulse_range[1]+int(acq_rate)]\n", "\n", "mean_data = np.nanmean(corrected, axis=(2, 3))\n", + "vmin, vmax = np.percentile(mean_data, [0, 100])\n", "hist, bins_x, bins_y = calgs.histogram2d(\n", " mean_data.flatten().astype(np.float32),\n", " pulseId.flatten().astype(np.float32),\n", " bins=(100, int(pulse_range[1])),\n", - " range=[[-50, 1000], pulse_range],\n", + " range=[[max(vmin, -50), min(vmax, 1000)], pulse_range],\n", ")\n", "do_2d_plot(hist, (bins_x, bins_y), \"Signal (ADU)\", \"Pulse id\")\n", - "hist, bins_x, bins_y = calgs.histogram2d(\n", - " mean_data.flatten().astype(np.float32),\n", - " pulseId.flatten().astype(np.float32),\n", - " bins=(100, int(pulse_range[1])),\n", - " range=[[-50, 200000], pulse_range]\n", - ")\n", - "do_2d_plot(hist, (bins_x, bins_y), \"Signal (ADU)\", \"Pulse id\")" + "if vmax > 1000: # a zoom out plot.\n", + " hist, bins_x, bins_y = calgs.histogram2d(\n", + " mean_data.flatten().astype(np.float32),\n", + " pulseId.flatten().astype(np.float32),\n", + " bins=(100, int(pulse_range[1])),\n", + " range=[[max(vmin, -50), min(vmax, 20000)], pulse_range]\n", + " )\n", + " do_2d_plot(hist, (bins_x, bins_y), \"Signal (ADU)\", \"Pulse id\")" ] }, { -- GitLab