From 2fd2a40ea48b28a739022d17b4765eb1f4f82e33 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Thu, 9 Feb 2023 14:03:00 +0100
Subject: [PATCH] MR comments on prenotebook

---
 .../Jungfrau_Gain_Correct_and_Verify_NBC.ipynb     |  6 ++----
 ...frau_retrieve_constants_precorrection_NBC.ipynb | 14 +++++++-------
 2 files changed, 9 insertions(+), 11 deletions(-)

diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb
index af0804c88..3badeac3f 100644
--- a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb
+++ b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb
@@ -229,10 +229,8 @@
     "for mod in karabo_da[:]:\n",
     "    calibrations = const_data.get(mod, {})\n",
     "\n",
-    "    missing_dark_constants = set(\n",
-    "        c for c in [\"Offset10Hz\", \"BadPixelsDark10Hz\"] if c not in calibrations.keys())\n",
-    "    missing_gain_constants = set(\n",
-    "        c for c in [\"BadPixelsFF10Hz\", \"RelativeGain10Hz\"] if relative_gain and c not in calibrations.keys())  # noqa\n",
+    "    missing_dark_constants = {\"Offset10Hz\", \"BadPixelsDark10Hz\"} - set(calibrations)\n",
+    "    missing_gain_constants = {\"BadPixelsFF10Hz\", \"RelativeGain10Hz\"} - set(calibrations)\n",
     "\n",
     "    if missing_dark_constants:\n",
     "        warning(\n",
diff --git a/notebooks/Jungfrau/Jungfrau_retrieve_constants_precorrection_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_retrieve_constants_precorrection_NBC.ipynb
index a6cb53139..00a94be57 100644
--- a/notebooks/Jungfrau/Jungfrau_retrieve_constants_precorrection_NBC.ipynb
+++ b/notebooks/Jungfrau/Jungfrau_retrieve_constants_precorrection_NBC.ipynb
@@ -166,24 +166,26 @@
     "                \"path\": str(jf_cal.caldb_root / ccv_metadata[\"path\"]),\n",
     "                \"dataset\": ccv_metadata[\"dataset\"],\n",
     "                \"creation-time\": ccv_metadata[\"begin_validity_at\"],\n",
+    "                \"ccv_id\": ccv_metadata[\"ccv_id\"],\n",
+    "                \"ccv_name\": ccv_metadata[\"ccv_name\"],\n",
     "            }\n",
     "    mod_dict[\"physical-name\"] = ccv_metadata[\"physical_name\"]\n",
     "\n",
     "# Validate the constants availability and raise/warn correspondingly. \n",
     "missing_dark_modules = set()\n",
     "for mod, calibrations in jf_metadata.items():\n",
-    "    missing_dark_constants = set(\n",
-    "        c for c in [\"Offset10Hz\", \"BadPixelsDark10Hz\"] if c not in calibrations.keys())\n",
-    "    missing_gain_constants = set(\n",
-    "        c for c in [\"BadPixelsFF10Hz\", \"RelativeGain10Hz\"] if relative_gain and c not in calibrations.keys())  # noqa\n",
+    "    missing_dark_constants = {\"Offset10Hz\", \"BadPixelsDark10Hz\"} - set(calibrations)\n",
+    "    missing_gain_constants = {\"BadPixelsFF10Hz\", \"RelativeGain10Hz\"} - set(calibrations)\n",
     "    if missing_dark_constants:\n",
     "        warning(\n",
     "            f\"Dark constants {missing_dark_constants} are not available to correct {mod}\")\n",
+    "        missing_dark_modules.add(mod)\n",
     "    if missing_gain_constants:\n",
     "        warning(\n",
     "            f\"Gain constants {missing_gain_constants} were not retrieved. Module: {mod}\")\n",
     "if missing_dark_modules == set(karabo_da):\n",
-    "    raise ValueError(f\"Dark constants are missing for all modules {karabo_da}.\")"
+    "    raise ValueError(f\"Dark constants are missing for all modules {karabo_da}.\")\n",
+    "step_timer.done_step(f'Retrieving calibration constants.')"
    ]
   },
   {
@@ -200,8 +202,6 @@
     "\n",
     "    print(f\"Module: {mod}:\")\n",
     "    for cname, mdata in module_constants[\"constants\"].items():\n",
-    "        if hasattr(mdata[\"creation-time\"], \"strftime\"):\n",
-    "            mdata[\"creation-time\"] = mdata[\"creation-time\"].strftime(\"%y-%m-%d %H:%M\")\n",
     "        print(f\"\\t{cname:.<12s}\", mdata[\"creation-time\"])\n",
     "\n",
     "    for cname in constant_names:\n",
-- 
GitLab