From d2b72d5508fceeacb545c3509fdeff9572da361d Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Mon, 19 Feb 2024 11:50:06 +0100 Subject: [PATCH] remove dinstance and use karabo_id to decide the correct plot --- .../Characterize_AGIPD_Gain_Darks_NBC.ipynb | 16 +++------ src/cal_tools/plotting.py | 34 +++++++++++-------- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index e741e80c9..7c650b582 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -153,17 +153,11 @@ "\n", "instrument = karabo_id.split(\"_\")[0]\n", "\n", - "if instrument == \"SPB\":\n", - " dinstance = \"AGIPD1M1\"\n", + "if \"AGIPD1M1\" in karabo_id:\n", " nmods = 16\n", - "elif instrument == \"MID\":\n", - " dinstance = \"AGIPD1M2\"\n", - " nmods = 16\n", - "elif instrument == \"HED\":\n", - " dinstance = \"AGIPD500K\"\n", + "elif \"AGIPD500K\" in karabo_id:\n", " nmods = 8\n", "else:\n", - " dinstance = None\n", " nmods = 1\n", "\n", "instrument_src = instrument_source_template.format(karabo_id, receiver_template)\n", @@ -180,7 +174,6 @@ "\n", "print(f\"Detector in use is {karabo_id}\")\n", "print(f\"Instrument {instrument}\")\n", - "print(f\"Detector instance {dinstance}\")\n", "\n", "step_timer = step_timing.StepTimer()" ] @@ -743,13 +736,14 @@ "metadata": {}, "outputs": [], "source": [ - "if dinstance:\n", + "# This is a temporary workaround to enable dark processing for the first SM AGIPD detector\n", + "if \"AGIPD1M\" in karabo_id or \"AGIPD500K\" in karabo_id:\n", " mnames=[]\n", " for i in modules:\n", " qm = module_index_to_qm(i)\n", " mnames.append(qm)\n", " display(Markdown(f'## Position of the module {qm} and its ASICs'))\n", - " show_processed_modules(dinstance, constants=None, mnames=mnames, mode=\"position\")" + " show_processed_modules(karabo_id, constants=None, mnames=mnames, mode=\"position\")" ] }, { diff --git a/src/cal_tools/plotting.py b/src/cal_tools/plotting.py index 8638d957d..f084d9fe0 100644 --- a/src/cal_tools/plotting.py +++ b/src/cal_tools/plotting.py @@ -231,44 +231,48 @@ def create_constant_overview(constant, name, cells, vmin=None, vmax=None, ax.set_ylim(vmin, vmax) -def show_processed_modules(dinstance: str, constants: Optional[Dict[str, Any]], - mnames: str, mode: str): +def show_processed_modules( + detector: str, + constants: Optional[Dict[str, Any]], + mnames: str, + mode: str +): """ Show the status of the processed modules. Green: Processed. Gray: Not Processed. Red: No data available. - :param dinstance: The detector instance (e.g. AGIPD1M1 or LPD1M1) - :param constants: A dict of the plotted constants data. - {"const_name":constant_data}. Can be None in case of position mode. - :param mnames: A list of available module names. - :param mode: String selecting on of the two modes of operation. - "position": To just show the position of the processed modules. - "processed": To show the modules successfully processed. - :return + Args: + detector: The detector name (karabo_id) (e.g. MID_DET_AGIPD1M-1 or FXE_DET_LPD1M-1) + constants: A dict of the plotted constants data. + {"const_name":constant_data}. Can be None in case of position mode. + mnames: A list of available module names. + mode: String selecting on of the two modes of operation. + "position": To just show the position of the processed modules. + "processed": To show the modules successfully processed. """ # Create the geometry figure for each detector - if dinstance in ('AGIPD1M1', 'AGIPD1M2'): + if "AGIPD1M" in detector: quadrants = 4 modules = 4 tiles = 8 quad_pos = [(-525, 625), (-550, -10), (520, -160), (542.5, 475)] geom = AGIPD_1MGeometry.from_quad_positions(quad_pos) - elif dinstance == 'AGIPD500K': + elif "AGIPD500K" in detector: quadrants = 2 modules = 4 tiles = 8 geom = AGIPD_500K2GGeometry.from_origin() - elif 'LPD' in dinstance: + elif 'LPD' in detector: quadrants = 4 modules = 4 tiles = 16 quad_pos = [(11.4, 299), (-11.5, 8), (254.5, -16), (278.5, 275)] geom = LPD_1MGeometry.from_quad_positions(quad_pos) - elif 'DSSC' in dinstance: + elif 'DSSC' in detector: quadrants = 4 modules = 4 tiles = 2 @@ -279,7 +283,7 @@ def show_processed_modules(dinstance: str, constants: Optional[Dict[str, Any]], quad_pos) else: - raise ValueError(f'{dinstance} is not a real detector') + raise ValueError(f'{detector} detector is not available for plotting.') # Create a dict that contains the range of tiles, in the figure, # that belong to a module. -- GitLab