From 840be17a03ddf0c861d9e65ee95eee78eb96ba86 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Mon, 12 Sep 2022 10:19:27 +0200
Subject: [PATCH] use empty constant if constant was not found to be retrieved

---
 notebooks/ePix100/Correction_ePix100_NBC.ipynb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/notebooks/ePix100/Correction_ePix100_NBC.ipynb b/notebooks/ePix100/Correction_ePix100_NBC.ipynb
index 35f8c78a4..b904c5782 100644
--- a/notebooks/ePix100/Correction_ePix100_NBC.ipynb
+++ b/notebooks/ePix100/Correction_ePix100_NBC.ipynb
@@ -296,9 +296,13 @@
    "metadata": {},
    "outputs": [],
    "source": [
+    "empty_constant = np.zeros((708, 768, 1), dtype=np.float32)\n",
     "if const_yaml:  #  Used while reproducing corrected data.\n",
     "    print(f\"Using stored constants in {metadata.filename}\")\n",
     "    const_data, _ = load_specified_constants(const_yaml[karabo_da][\"constants\"])\n",
+    "    for cname, cval in const_data.items():\n",
+    "        if cval is None and cname != \"RelativeGain\":\n",
+    "            const_data[cname] = empty_constant\n",
     "else:  # First correction attempt.\n",
     "    const_data = dict()\n",
     "    for cname, condition in const_cond.items():\n",
@@ -311,7 +315,7 @@
     "                karabo_da=karabo_da,\n",
     "                constant=getattr(Constants.ePix100, cname)(),\n",
     "                condition=condition,\n",
-    "                empty_constant=None,\n",
+    "                empty_constant=None if cname == \"RelativeGain\" else empty_constant,\n",
     "                cal_db_interface=cal_db_interface,\n",
     "                creation_time=creation_time,\n",
     "                print_once=2,\n",
-- 
GitLab