From 4842e7d1700ea228044133444e0b42ed0c9683f2 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Wed, 19 Apr 2023 11:42:35 +0200 Subject: [PATCH] display creation time for retrieved constants --- notebooks/ePix100/Correction_ePix100_NBC.ipynb | 6 ++++++ notebooks/pnCCD/Correct_pnCCD_NBC.ipynb | 7 +++++++ src/cal_tools/calcat_interface.py | 12 ++++++++++++ 3 files changed, 25 insertions(+) diff --git a/notebooks/ePix100/Correction_ePix100_NBC.ipynb b/notebooks/ePix100/Correction_ePix100_NBC.ipynb index baa4bc08c..f71f2ee4b 100644 --- a/notebooks/ePix100/Correction_ePix100_NBC.ipynb +++ b/notebooks/ePix100/Correction_ePix100_NBC.ipynb @@ -280,6 +280,12 @@ ")\n", "const_metadata = epix_cal.metadata(calibrations=constant_names)\n", "\n", + "mod_to_pdu = epix_cal.mod_to_pdu\n", + "for mod, mod_md in const_metadata.items():\n", + " print(f\"{mod}({mod_to_pdu[mod]}):\")\n", + " for cname, c_mdata in mod_md.items():\n", + " print(f\"{cname}: {c_mdata['begin_validity_at']}\")\n", + "\n", "# Load the constant data from files\n", "const_data = epix_cal.ndarray_map(metadata=const_metadata)[karabo_da]\n", "\n", diff --git a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb index fe6db973a..4b18fd8e3 100644 --- a/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb +++ b/notebooks/pnCCD/Correct_pnCCD_NBC.ipynb @@ -323,6 +323,13 @@ ")\n", "\n", "pnccd_metadata = pnccd_cal.metadata(calibrations=constant_names)\n", + "\n", + "mod_to_pdu = pnccd_cal.mod_to_pdu\n", + "for mod, mod_md in pnccd_metadata.items():\n", + " print(f\"{mod}({mod_to_pdu[mod]}):\")\n", + " for cname, c_mdata in mod_md.items():\n", + " print(f\"{cname}: {c_mdata['begin_validity_at']}\")\n", + "\n", "constants = pnccd_cal.ndarray_map(metadata=pnccd_metadata)[karabo_da]\n", "\n", "# Validate the constants availability and raise/warn correspondingly. \n", diff --git a/src/cal_tools/calcat_interface.py b/src/cal_tools/calcat_interface.py index a7c8cf158..500f089e6 100644 --- a/src/cal_tools/calcat_interface.py +++ b/src/cal_tools/calcat_interface.py @@ -524,6 +524,18 @@ class CalibrationData: self.detector["id"], self.pdu_snapshot_at, self.module_naming ) + @property + def mod_to_pdu(self): + """Get the physical detector units and create a dictionary + mapping each module name to physical name (physical detector unit). + + Returns: + DICT: mapping module to physical detector unit name. + """ + return {mod: pdu_md["physical_name"] for mod, pdu_md in self._api.physical_detector_units( + self.detector["id"], self.pdu_snapshot_at, self.module_naming + ).items()} + @property def condition(self): return self._build_condition(self.parameters) -- GitLab