From a432e1f65df7795214cc47ce4604a0c9994cb123 Mon Sep 17 00:00:00 2001
From: Vratko Rovensky <vratko.rovensky@xfel.eu>
Date: Tue, 9 Jan 2024 15:19:21 +0100
Subject: [PATCH] Adding possibility to autocomplete run numbers if ITESTC
 configs were taken in descending order.

---
 notebooks/AGIPD/CS_parallelMerging_NBC.ipynb | 37 +++++++++++---------
 1 file changed, 20 insertions(+), 17 deletions(-)

diff --git a/notebooks/AGIPD/CS_parallelMerging_NBC.ipynb b/notebooks/AGIPD/CS_parallelMerging_NBC.ipynb
index 180b509ad..c4e27e2f1 100644
--- a/notebooks/AGIPD/CS_parallelMerging_NBC.ipynb
+++ b/notebooks/AGIPD/CS_parallelMerging_NBC.ipynb
@@ -17,17 +17,19 @@
    "outputs": [],
    "source": [
     "# cluster_profile = \"noDB\" # The ipcluster profile to use\n",
-    "in_folder = \"/gpfs/exfel/exp/SPB/202330/p900340/raw/\" # path to input data, required\n",
-    "out_folder = \"/gpfs/exfel/exp/SPB/202330/p900340/scratch/CSmergedFiles/test/\" # path to output to, required\n",
+    "in_folder = \"/gpfs/exfel/exp/SPB/202331/p900376/raw/\" # path to input data, required\n",
+    "out_folder = \"/gpfs/exfel/exp/SPB/202331/p900376/scratch/CSmergedFiles/\" # path to output to, required\n",
     "metadata_folder = \"\"\n",
-    "first_run = 6 # first taken run, it has to be run with the smallest ITESTC, otherwise define runs manually\n",
     "\n",
+    "first_run = 269 # first taken run, it has to be a run with the smallest ITESTC, otherwise define runs manually\n",
     "runs1 = [-1] # list of runs to use, range allowed ITESTC 65, use -1 for auto-completion\n",
     "runs2 = [-1] # list of runs to use, ITESTC 80, use -1 for auto-completion\n",
     "runs3 = [-1] # list of runs to use, ITESTC 120, use -1 for auto-completion\n",
     "runs4 = [-1] # list of runs to use, ITESTC 170, use -1 for auto-completion\n",
-    "modules = [8] # modules to work on, required, range allowed\n",
+    "itestc_order = \"descending\" # order in which ITESTC values were configured, e.g. first run taken with the highest ITESTC value --> \"descending\"\n",
+    "n_itestc = 5 # number of different ITESTC configurations taken. IMPORTANT, if you use ITESTC configurations which do not have consecutive run numbers, do not use runs auto-completion! Provide run numbers manually!\n",
     "\n",
+    "modules = [8] # modules to work on, required, range allowed\n",
     "karabo_da = [\"all\"]\n",
     "karabo_id_control = \"SPB_IRU_AGIPD1M1\"  # karabo-id for the control device e.g. \"MID_EXP_AGIPD1M1\", or \"SPB_IRU_AGIPD1M1\"\n",
     "karabo_id = \"SPB_DET_AGIPD1M-1\"\n",
@@ -56,11 +58,19 @@
    "outputs": [],
    "source": [
     "# Determine the run numbers\n",
-    "if runs1[0] == -1:\n",
-    "    runs1 = range(first_run, first_run+4*4, 4)\n",
-    "    runs2 = range(first_run+1, first_run+1+4*4, 4)\n",
-    "    runs3 = range(first_run+2, first_run+2+4*4, 4)\n",
-    "    runs4 = range(first_run+3, first_run+3+4*4, 4)"
+    "if (runs1[0] == -1) & (itestc_order == \"ascending\"):\n",
+    "    runs1 = range(first_run, first_run+4*4, n_itestc)\n",
+    "    runs2 = range(first_run+1, first_run+1+4*4, n_itestc)\n",
+    "    runs3 = range(first_run+2, first_run+2+4*4, n_itestc)\n",
+    "    runs4 = range(first_run+3, first_run+3+4*4, n_itestc)\n",
+    "    \n",
+    "if (runs1[0] == -1) & (itestc_order == \"descending\"):\n",
+    "    runs1 = range(first_run, first_run+4*4, n_itestc)\n",
+    "    runs2 = range(first_run-1, first_run-1+4*4, n_itestc)\n",
+    "    runs3 = range(first_run-2, first_run-2+4*4, n_itestc)\n",
+    "    runs4 = range(first_run-3, first_run-3+4*4, n_itestc)\n",
+    "    \n",
+    "print('Runs to be evaluated: ', list(runs1), list(runs2), list(runs3), list(runs4))"
    ]
   },
   {
@@ -101,12 +111,6 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "print(\"Parameters are:\")\n",
-    "if mem_cells == -1.:\n",
-    "    print(\"Memory cells: auto-detection on\")\n",
-    "else:\n",
-    "    print(\"Memory cells set by user: {}\".format(mem_cells))\n",
-    "print(\"Runs: {} / {} / {}\".format(runs1, runs2, runs3))\n",
     "print(\"Modules: {}\".format(modules))\n",
     "\n",
     "instrument = karabo_id.split(\"_\")[0]\n",
@@ -176,7 +180,6 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "print(f\"Using {creation_time} as creation time of constant.\")\n",
     "print(\"Operating conditions are:\")\n",
     "print(f\"Bias voltage: {bias_voltage} V\")\n",
     "print(f\"Memory cells: {mem_cells}\")\n",
@@ -540,7 +543,7 @@
  ],
  "metadata": {
   "kernelspec": {
-   "display_name": "Python 3",
+   "display_name": "pycalibration",
    "language": "python",
    "name": "python3"
   },
-- 
GitLab