From 45405f4a6bca1ebeeecbb0673ecbb8afb28e0a5e Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Mon, 16 Jan 2023 17:00:21 +0100 Subject: [PATCH] skip characterize_module and skip plots for module with no data --- notebooks/LPD/LPDChar_Darks_NBC.ipynb | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/notebooks/LPD/LPDChar_Darks_NBC.ipynb b/notebooks/LPD/LPDChar_Darks_NBC.ipynb index 5f5749ee5..c9508aa5c 100644 --- a/notebooks/LPD/LPDChar_Darks_NBC.ipynb +++ b/notebooks/LPD/LPDChar_Darks_NBC.ipynb @@ -53,6 +53,9 @@ "thresholds_noise_hard = [1, 35] # bad pixel hard threshold\n", "skip_first_ntrains = 10 # Number of first trains to skip\n", "\n", + "# Parameters for plotting\n", + "skip_plots = False # exit after writing corrected files\n", + "\n", "instrument = \"FXE\" # instrument name\n", "ntrains = 100 # number of trains to use\n", "high_res_badpix_3d = False # plot bad-pixel summary in high resolution\n", @@ -74,6 +77,7 @@ "from collections import OrderedDict\n", "from datetime import datetime\n", "from functools import partial\n", + "from logging import warning\n", "\n", "warnings.filterwarnings('ignore')\n", "\n", @@ -228,7 +232,9 @@ " im = np.array(infile[\"{}/data\".format(instrument_src, channel)][first_image:last_image, ...])\n", " cellid = np.squeeze(np.array(infile[\"{}/cellId\".format(instrument_src, channel)][first_image:last_image, ...]))\n", " infile.close()\n", - " \n", + " if im.shape[0] == 0: # No data\n", + " return None, None, channel, gg, cap, None, None, None, None\n", + "\n", " cellid_pattern = cellid[:count[0]]\n", "\n", " im, g = splitOffGainLPD(im[:, 0, ...])\n", @@ -323,6 +329,10 @@ "\n", "for ir, r in enumerate(results):\n", " offset, noise, i, gg, cap, bp, data, normal, cellid_pattern = r\n", + " if data is None:\n", + " warning(f\"No data for module {i} of gain {gg}\")\n", + " skip_plots = True\n", + " continue\n", " qm = module_index_to_qm(i)\n", " if qm not in offset_g[cap]:\n", " offset_g[cap][qm] = np.zeros(\n", @@ -348,6 +358,18 @@ " f\"Number of processed trains per cell: {data.shape[0]}.\")" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "if skip_plots:\n", + " import sys\n", + " print('Skipping plots')\n", + " sys.exit(0)" + ] + }, { "cell_type": "code", "execution_count": null, -- GitLab