From 522997c29efa440e2203c0f099c5ea1a0518c48f Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Mon, 1 Nov 2021 09:12:43 +0100
Subject: [PATCH] [AGIPD][HED][PRE-CORRECT][PC] get_acq_rate from slowpaths

---
 .../AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb     | 7 ++++---
 notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb        | 7 ++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb
index afe6f3082..53ecb323c 100644
--- a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb
+++ b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb
@@ -146,7 +146,7 @@
    "source": [
     "control_fn = in_folder / f'r{run:04d}' / f'RAW-R{run:04d}-{karabo_da_control}-S00000.h5'\n",
     "h5path_ctrl = h5path_ctrl.format(karabo_id_control)\n",
-    "\n",
+    "slow_paths = (control_fn, karabo_id_control)\n",
     "if gain_setting == 0.1:\n",
     "    if creation_time.replace(tzinfo=None) < parser.parse('2020-01-31'):\n",
     "        print(\"Set gain-setting to None for runs taken before 2020-01-31\")\n",
@@ -237,7 +237,8 @@
     "        raise ValueError(f\"No raw images found for {qm} for all sequences\")\n",
     "\n",
     "    if acq_rate == 0:\n",
-    "        local_acq_rate = agipdlib.get_acq_rate(fast_paths=(f, karabo_id, idx))\n",
+    "        local_acq_rate = agipdlib.get_acq_rate(\n",
+    "            fast_paths=(f, karabo_id, idx), slow_paths=slow_paths)\n",
     "    else:\n",
     "        local_acq_rate = acq_rate\n",
     "\n",
@@ -308,7 +309,7 @@
     "            const_mdata[\"file-path\"] = const_dict[const_name][:2]\n",
     "            const_mdata[\"creation-time\"] = None\n",
     "\n",
-    "    return qm, mdata_dict, karabo_da, acq_rate, local_max_cells"
+    "    return qm, mdata_dict, karabo_da, local_acq_rate, local_max_cells"
    ]
   },
   {
diff --git a/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb b/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb
index a00965686..37df92a7c 100644
--- a/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb
+++ b/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb
@@ -178,6 +178,8 @@
     "run = runs[0]\n",
     "bursts_per_file = []\n",
     "channel = 0\n",
+    "control_fname = f'{in_folder}/r{run:04d}/RAW-R{run:04d}-{karabo_da_control}-S00000.h5'\n",
+    "slow_paths = (control_fname, karabo_id_control)\n",
     "\n",
     "for seq in range(seqs):\n",
     "    fname = os.path.join(path_temp.format(run),\n",
@@ -185,7 +187,8 @@
     "    print('Reading ',fname)\n",
     "    \n",
     "    if acq_rate == 0.:\n",
-    "        acq_rate = get_acq_rate((fname, karabo_id, channel))\n",
+    "        acq_rate = get_acq_rate(\n",
+    "            fast_paths=(fname, karabo_id, channel), slow_paths=slow_paths)\n",
     "        print(\"Acquisition rate set from file: {} MHz\".format(acq_rate))\n",
     "\n",
     "    if mem_cells == 0:\n",
@@ -225,8 +228,6 @@
    "metadata": {},
    "outputs": [],
    "source": [
-    "control_fname = f'{in_folder}/r{runs[0]:04d}/RAW-R{runs[0]:04d}-{karabo_da_control}-S00000.h5'\n",
-    "\n",
     "if \"{\" in h5path_ctrl:\n",
     "    h5path_ctrl = h5path_ctrl.format(karabo_id_control)\n",
     "\n",
-- 
GitLab