From db7d2c8397d90a517412fb93d795e5027afb7c1e Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Thu, 22 Sep 2022 12:52:10 +0200
Subject: [PATCH] Limit number of plotted trains to 500 Jungfrau Correct

---
 ...Jungfrau_Gain_Correct_and_Verify_NBC.ipynb | 31 ++++++-------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb
index 16fc887cc..2a4aba690 100644
--- a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb
+++ b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb
@@ -51,7 +51,7 @@
     "\n",
     "# Parameters for plotting\n",
     "skip_plots = False  # exit after writing corrected files\n",
-    "plot_images = -1  # Number of images to plot for RAW and CORRECTED plots.\n",
+    "plot_trains = 500  # Number of trains to plot for RAW and CORRECTED plots. Set to -1 to automatically plot all trains.\n",
     "cell_id_preview = 15  # cell Id used for preview in single-shot plots\n",
     "\n",
     "# Parameters for ROI selection and reduction\n",
@@ -633,7 +633,7 @@
     "    jf_corr = components.JUNGFRAU(\n",
     "        corr_dc,\n",
     "        detector_name=karabo_id,\n",
-    "    ).select_trains(np.s_[:plot_images])\n",
+    "    ).select_trains(np.s_[:plot_trains])\n",
     "    tid, jf_corr_data = next(iter(jf_corr.trains(require_all=True)))\n",
     "\n",
     "# Shape = [modules, trains, cells, x, y]\n",
@@ -649,7 +649,7 @@
     "\n",
     "    # Reading RAW data for plotting.\n",
     "    jf_raw = components.JUNGFRAU(raw_dc, detector_name=karabo_id).select_trains(\n",
-    "        np.s_[:plot_images]\n",
+    "        np.s_[:plot_trains]\n",
     "    )\n",
     "\n",
     "raw = jf_raw.get_array(\"data.adc\")[:, :, cell_idx_preview, ...].values\n",
@@ -665,15 +665,6 @@
     ")"
    ]
   },
-  {
-   "cell_type": "markdown",
-   "metadata": {},
-   "source": [
-    "### Single Train Preview ###\n",
-    "\n",
-    "A single image from the first train"
-   ]
-  },
   {
    "cell_type": "code",
    "execution_count": null,
@@ -694,9 +685,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "### Mean RAW Preview ###\n",
-    "\n",
-    "The per pixel mean of the sequence file of RAW data"
+    "### Mean RAW Preview"
    ]
   },
   {
@@ -705,6 +694,8 @@
    "metadata": {},
    "outputs": [],
    "source": [
+    "print(f\"The per pixel mean of the first {raw.shape[1]} trains of the first sequence file\")\n",
+    "\n",
     "fig, ax = plt.subplots(figsize=(18, 10))\n",
     "raw_mean = np.mean(raw, axis=1)\n",
     "geom.plot_data_fast(\n",
@@ -723,9 +714,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "### Mean CORRECTED Preview ###\n",
-    "\n",
-    "The per pixel mean of the sequence file of CORR data"
+    "### Mean CORRECTED Preview"
    ]
   },
   {
@@ -734,6 +723,8 @@
    "metadata": {},
    "outputs": [],
    "source": [
+    "print(f\"The per pixel mean of the first {corrected.shape[1]} trains of the first sequence file\")\n",
+    "\n",
     "fig, ax = plt.subplots(figsize=(18, 10))\n",
     "corrected_mean = np.mean(corrected, axis=1)\n",
     "_corrected_vmin = min(0.75*np.median(corrected_mean[corrected_mean > 0]), -0.5)\n",
@@ -887,9 +878,7 @@
    "cell_type": "markdown",
    "metadata": {},
    "source": [
-    "### Maximum GAIN Preview ###\n",
-    "\n",
-    "The per pixel maximum of the first train of the GAIN data"
+    "### Maximum GAIN Preview"
    ]
   },
   {
-- 
GitLab