From cc6a2e3b34978e1745ab5a739f5acb6b4e9d49b0 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Mon, 19 Jun 2023 12:40:28 +0200 Subject: [PATCH] refactors, add/remove TODOs --- notebooks/LPD/LPD_Correct_Fast.ipynb | 13 +++++++------ .../LPD/LPD_retrieve_constants_precorrection.ipynb | 7 ++++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/notebooks/LPD/LPD_Correct_Fast.ipynb b/notebooks/LPD/LPD_Correct_Fast.ipynb index b5bf48c1d..7ee0acd4e 100644 --- a/notebooks/LPD/LPD_Correct_Fast.ipynb +++ b/notebooks/LPD/LPD_Correct_Fast.ipynb @@ -259,7 +259,7 @@ " for mod, constants in const_yaml.items():\n", " const_data[mod] = {} # An empty dictionary stays for a module with no constants.\n", " for cname, cmdata in constants[\"constants\"].items():\n", - " const_data[mod][cname] = const_load_mp.alloc( # TODO: MAKE SURE WE ERROR OUT FOR MISSING OFFSET\n", + " const_data[mod][cname] = const_load_mp.alloc(\n", " shape=(256, 256, mem_cells, 3), # All LPD constants have the same shape.\n", " dtype=np.uint32 if cname.startswith('BadPixels') else np.float32\n", " )\n", @@ -300,8 +300,8 @@ " \"FFMap\", \"RelativeGain\",\n", " ]\n", " )\n", - " except CalCatError as e:\n", - " warning(e)\n", + " except CalCatError as e: # TODO: remove when API errors are improved.\n", + " warning(f\"CaLCaTError: {e}\")\n", "total_time = perf_counter() - start\n", "print(f'Loading constants {total_time:.1f}s')" ] @@ -316,12 +316,13 @@ "for mod, calibrations in const_data.items():\n", " missing_offset = {\"Offset\"} - set(calibrations)\n", " warn_missing_constants = {\n", - " \"BadPixelsDark\", \"BadPixelsFF\", \"GainAmpMap\", \"FFMap\", \"RelativeGain\"} - set(calibrations)\n", + " \"BadPixelsDark\", \"BadPixelsFF\", \"GainAmpMap\",\n", + " \"FFMap\", \"RelativeGain\"} - set(calibrations)\n", " if missing_offset:\n", - " warning(f\"Offset constant is not available to correct {mod}\") # noqa\n", + " warning(f\"Offset constant is not available to correct {mod}.\")\n", " karabo_da.remove(mod)\n", " if warn_missing_constants:\n", - " warning(f\"Gain constants {warn_missing_constants} were not retrieved for {mod}\")\n", + " warning(f\"Constants {warn_missing_constants} were not retrieved for {mod}.\")\n", "if not karabo_da: # Offsets are missing for all modules.\n", " raise Exception(\"Could not find offset constants for all modules, will not correct data.\")\n", "\n", diff --git a/notebooks/LPD/LPD_retrieve_constants_precorrection.ipynb b/notebooks/LPD/LPD_retrieve_constants_precorrection.ipynb index d39629b66..584be0a91 100644 --- a/notebooks/LPD/LPD_retrieve_constants_precorrection.ipynb +++ b/notebooks/LPD/LPD_retrieve_constants_precorrection.ipynb @@ -144,17 +144,18 @@ "try:\n", " lpd_cal_metadata = lpd_cal.metadata(constant_names)\n", "except CalCatError as e:\n", - " warning(e)\n", + " warning(f\"CaLCaTError: {e}\")\n", + "\n", "# Validate the constants availability and raise/warn correspondingly. \n", "for mod, ccv_dict in lpd_cal_metadata.items():\n", " missing_offset = {\"Offset\"} - set(ccv_dict)\n", " warn_missing_constants = {\n", " \"BadPixelsDark\", \"BadPixelsFF\", \"GainAmpMap\", \"FFMap\", \"RelativeGain\"} - set(ccv_dict)\n", " if missing_offset:\n", - " warning(f\"Offset constant is not available to correct {mod}\") # noqa\n", + " warning(f\"Offset constant is not available to correct {mod}\")\n", " karabo_da.remove(mod)\n", " if warn_missing_constants:\n", - " warning(f\"Gain constants {warn_missing_constants} were not retrieved for {mod}\")\n", + " warning(f\"Constants {warn_missing_constants} were not retrieved for {mod}.\")\n", "if not karabo_da: # Offsets are missing for all modules.\n", " raise Exception(\"Could not find offset constants for all modules, will not correct data.\")\n", "\n", -- GitLab