From 0244759301ae2ebff8baf7ed88b6a159dd912ae8 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Mon, 24 Apr 2023 12:54:11 +0200 Subject: [PATCH] use init_jungfrau_geom and extend accepted detectors based on substrings of karabo_id --- ...Jungfrau_Gain_Correct_and_Verify_NBC.ipynb | 28 ++----------------- .../Jungfrau/Jungfrau_darks_Summary_NBC.ipynb | 3 -- src/cal_tools/plotting.py | 8 +++--- 3 files changed, 7 insertions(+), 32 deletions(-) diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb index f2bbe41e8..c85e59e2c 100644 --- a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb @@ -87,13 +87,14 @@ "import tabulate\n", "from IPython.display import Latex, Markdown, display\n", "from extra_data import DataCollection, H5File, RunDirectory, by_id, components\n", - "from extra_geom import JUNGFRAUGeometry\n", "from matplotlib.colors import LogNorm\n", "\n", "import cal_tools.restful_config as rest_cfg\n", "from cal_tools.calcat_interface import JUNGFRAU_CalibrationData\n", "from cal_tools.jungfraulib import JungfrauCtrl\n", "from cal_tools.enums import BadPixels\n", + "from cal_tools.jungfraulib import JungfrauCtrl\n", + "from cal_tools.plotting import init_jungfrau_geom\n", "from cal_tools.files import DataFile\n", "from cal_tools.step_timing import StepTimer\n", "from cal_tools.tools import (\n", @@ -660,30 +661,7 @@ "metadata": {}, "outputs": [], "source": [ - "# Positions are given in pixels\n", - "mod_width = (256 * 4) + (2 * 3) # inc. 2px gaps between tiles\n", - "mod_height = (256 * 2) + 2\n", - "if karabo_id == \"SPB_IRDA_JF4M\":\n", - " # The first 4 modules are rotated 180 degrees relative to the others.\n", - " # We pass the bottom, beam-right corner of the module regardless of its\n", - " # orientation, requiring a subtraction from the symmetric positions we'd\n", - " # otherwise calculate.\n", - " x_start, y_start = 1125, 1078\n", - " module_pos = [\n", - " (x_start - mod_width, y_start - mod_height - (i * (mod_height + 33)))\n", - " for i in range(4)\n", - " ] + [\n", - " (-x_start, -y_start + (i * (mod_height + 33))) for i in range(4)\n", - " ]\n", - " orientations = [(-1, -1) for _ in range(4)] + [(1, 1) for _ in range(4)]\n", - "elif karabo_id == \"FXE_XAD_JF1M\":\n", - " module_pos = ((-mod_width//2, 33),(-mod_width//2, -mod_height -33))\n", - " orientations = [(-1,-1), (1,1)]\n", - "else:\n", - " module_pos = ((-mod_width//2,-mod_height//2),)\n", - " orientations = None\n", - "\n", - "geom = JUNGFRAUGeometry.from_module_positions(module_pos, orientations=orientations, asic_gap=0)" + "_, geom = init_jungfrau_geom(karabo_id=karabo_id, karabo_da=karabo_da)" ] }, { diff --git a/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb index 55269def4..6da1df8b9 100644 --- a/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb @@ -41,7 +41,6 @@ "outputs": [], "source": [ "import warnings\n", - "from collections import OrderedDict\n", "from pathlib import Path\n", "\n", "warnings.filterwarnings('ignore')\n", @@ -57,8 +56,6 @@ "matplotlib.use(\"agg\")\n", "%matplotlib inline\n", "\n", - "from cal_tools.enums import BadPixels, JungfrauSettings\n", - "from cal_tools.ana_tools import get_range\n", "from cal_tools.plotting import init_jungfrau_geom, show_processed_modules_jungfrau\n", "from cal_tools.tools import CalibrationMetadata\n", "from XFELDetAna.plotting.simpleplot import simplePlot" diff --git a/src/cal_tools/plotting.py b/src/cal_tools/plotting.py index 1e49a5482..544b6ce8c 100644 --- a/src/cal_tools/plotting.py +++ b/src/cal_tools/plotting.py @@ -415,7 +415,7 @@ def init_jungfrau_geom( karabo_da: List[str] ) -> Tuple[List[str], JUNGFRAUGeometry]: """ Initiate JUNGFRAUGeometry object based on the selected detector - (SPB_IRDA_JF4M, FXE_XAD_JF1M, or a single module detector). + (JF4M, JF1M, or JF500K detectors). :param karabo_id: the detector identifer of an expected multimodular detector or a single module detector. @@ -429,7 +429,7 @@ def init_jungfrau_geom( mod_width = (256 * 4) + (2 * 3) # inc. 2px gaps between tiles mod_height = (256 * 2) + 2 - if karabo_id == "SPB_IRDA_JF4M": + if "JF4M" in karabo_id: nmods = 8 expected_modules = [f"JNGFR{i:02d}" for i in range(1, nmods+1)] # The first 4 modules are rotated 180 degrees relative to the others. @@ -445,12 +445,12 @@ def init_jungfrau_geom( ] orientations = [ (-1, -1) for _ in range(4)] + [(1, 1) for _ in range(4)] - elif karabo_id == "FXE_XAD_JF1M": + elif "JF1M" in karabo_id: nmods = 2 expected_modules = [f"JNGFR{i:02d}" for i in range(1, nmods+1)] module_pos = ((-mod_width//2, 33), (-mod_width//2, -mod_height-33)) orientations = [(-1,-1), (1,1)] - else: + else: # e.g. HED_IA1_JF500K1, FXE_XAD_JF500K, FXE_XAD_JFHZ nmods = 1 expected_modules = karabo_da module_pos = ((-mod_width//2, -mod_height//2),) -- GitLab