From 4fa14537c9f229486734c2552ade57b6d4f9fac7 Mon Sep 17 00:00:00 2001
From: ahmedk <karim.ahmed@xfel.eu>
Date: Tue, 2 May 2023 16:35:04 +0200
Subject: [PATCH] refactor: load constants after validating and writing
 fragment

---
 notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb
index 8c84f0b3a..7672bf8ab 100644
--- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb
+++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb
@@ -243,11 +243,9 @@
     "        constant_names += [\"RelativeGainGotthard2\", \"BadPixelsFFGotthard2\"]\n",
     "\n",
     "    g2_metadata = g2_cal.metadata(calibrations=constant_names)\n",
-    "    # Retrieve metadata for all pnccd constants.\n",
-    "    const_data = g2_cal.ndarray_map(metadata=g2_metadata)\n",
     "\n",
     "    # Validate the constants availability and raise/warn correspondingly.\n",
-    "    for mod, calibrations in const_data.items():\n",
+    "    for mod, calibrations in g2_metadata.items():\n",
     "\n",
     "        dark_constants = {\"LUTGotthard2\"}\n",
     "        if offset_correction:\n",
@@ -280,6 +278,9 @@
     "    det_metadata=g2_metadata,\n",
     "    caldb_root=g2_cal.caldb_root)\n",
     "\n",
+    "# Load constants data for all constants.\n",
+    "const_data = g2_cal.ndarray_map(metadata=g2_metadata)\n",
+    "\n",
     "# Prepare constant arrays.\n",
     "if not constants_file:\n",
     "    # Create the mask array.\n",
-- 
GitLab