diff --git a/src/cal_tools/calcat_interface2.py b/src/cal_tools/calcat_interface2.py index a9e4ef32512196ab1b7e7cc52e7cab98f3ad040c..f566b72b66028be19a507df5f7db3fd83c6a3f1f 100644 --- a/src/cal_tools/calcat_interface2.py +++ b/src/cal_tools/calcat_interface2.py @@ -725,7 +725,7 @@ class CalibrationData(Mapping): return type(self)(constant_groups, module_details, det_name) - def markdown_table(self, ccvs_url=None) -> str: + def markdown_table(self, ccvs_url=None, module_naming="modnum") -> str: """Make a markdown table overview of the constants found. Columns are calibration types, rows are modules. @@ -736,9 +736,22 @@ class CalibrationData(Mapping): ccvs_url (str, optional): URL for calibration constant versions. Defaults to "https://in.xfel.eu/calibration/calibration_constant_versions/". + module_naming (str): modnum, aggregator or qm, to change how the + modules are labelled in the table. Defaults to modnum. """ from tabulate import tabulate + if module_naming == "aggregator": + modules = self.aggregator_names + elif module_naming == "modnum": + modules = self.module_nums + elif module_naming == "qm": + modules = self.qm_names + else: + raise ValueError( + f"{module_naming=} (must be 'aggregator', 'modnum' or 'qm'" + ) + if ccvs_url is None: ccvs_url = "https://in.xfel.eu/calibration/calibration_constant_versions/" @@ -752,7 +765,7 @@ class CalibrationData(Mapping): table = [["Modules"] + cal_group] # Loop over calibrations and modules to form the next rows. - for mod in self.module_nums: + for mod in modules: mod_consts = [] for cname in cal_group: @@ -776,7 +789,7 @@ class CalibrationData(Mapping): return '\n\n'.join(md_tables) - def display_markdown_table(self, ccvs_url=None): + def display_markdown_table(self, ccvs_url=None, module_naming="modnum"): """Make a markdown table overview of the constants found. Columns are calibration types, rows are modules. @@ -787,9 +800,11 @@ class CalibrationData(Mapping): ccvs_url (str, optional): URL for calibration constant versions. Defaults to "https://in.xfel.eu/calibration/calibration_constant_versions/". + module_naming (str): modnum, aggregator or qm, to change how the + modules are labelled in the table. Defaults to modnum. """ from IPython.display import display, Markdown - display(Markdown(self.markdown_table(ccvs_url=ccvs_url))) + display(Markdown(self.markdown_table(ccvs_url, module_naming=module_naming))) class ConditionsBase: