From c573a3477f7a8d9bcb4bf85b2ac3c000e07b9215 Mon Sep 17 00:00:00 2001
From: Philipp Schmidt <philipp.schmidt@xfel.eu>
Date: Tue, 19 Oct 2021 10:34:49 +0200
Subject: [PATCH] Add skip-plots option to AGIPD correction notebook

---
 .../AGIPD/AGIPD_Correct_and_Verify.ipynb      | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
index 613b264ad..1b2e56d83 100644
--- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
+++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb
@@ -48,7 +48,6 @@
     "overwrite = True # set to True if existing data should be overwritten\n",
     "max_pulses = [0, 352, 1] # range list [st, end, step] of memory cell indices to be processed within a train. 3 allowed maximum list input elements.\n",
     "mem_cells_db = 0 # set to a value different than 0 to use this value for DB queries\n",
-    "cell_id_preview = 1 # cell Id used for preview in single-shot plots\n",
     "integration_time = -1 # integration time, negative values for auto-detection.\n",
     "\n",
     "# Correction parameters\n",
@@ -82,6 +81,10 @@
     "mask_zero_std = False # Mask pixels with zero standard deviation across train\n",
     "low_medium_gap = False # 5 sigma separation in thresholding between low and medium gain\n",
     "\n",
+    "# Plotting parameters\n",
+    "skip_plots = False # exit after writing corrected files and metadata\n",
+    "cell_id_preview = 1 # cell Id used for preview in single-shot plots\n",
+    "\n",
     "# Paralellization parameters\n",
     "chunk_size = 1000 # Size of chunk for image-weise correction\n",
     "chunk_size_idim = 1  # chunking size of imaging dimension, adjust if user software is sensitive to this.\n",
@@ -485,6 +488,8 @@
     "    return err, mod, when, k_da\n",
     "\n",
     "\n",
+    "print(f'Preparing constants (FF: {agipd_corr.corr_bools[\"xray_corr\"]}, PC: {any(agipd_corr.pc_bools)}, '\n",
+    "      f'BLC: {any(agipd_corr.blc_bools)})')\n",
     "ts = perf_counter()\n",
     "with multiprocessing.Pool(processes=len(modules)) as pool:\n",
     "    const_out = pool.map(retrieve_constants, modules)\n",
@@ -660,6 +665,18 @@
     "        yaml.safe_dump({\"time-summary\": {f\"S{seq}\": timestamps}}, fd)"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "if skip_plots:\n",
+    "    print('Skipping plots')\n",
+    "    import sys\n",
+    "    sys.exit(0)"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
-- 
GitLab