From 617f34ea6c0480f3f6115569036d016c1f276b37 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Thu, 30 Nov 2023 16:01:39 +0100 Subject: [PATCH] small refactors --- .../Gotthard2/Correction_Gotthard2_NBC.ipynb | 28 ++++++++----------- src/xfel_calibrate/calibrate.py | 2 +- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb index d28fe59b6..4f8f4901c 100644 --- a/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb +++ b/notebooks/Gotthard2/Correction_Gotthard2_NBC.ipynb @@ -145,8 +145,6 @@ "\n", "ctrl_src = ctrl_source_template.format(karabo_id_control, control_template)\n", "\n", - "print(f\"Process modules: {karabo_da} for run {run}\")\n", - "\n", "# Run's creation time:\n", "creation_time = calcat_creation_time(in_folder, run, creation_time)\n", "print(f\"Creation time: {creation_time}\")" @@ -202,6 +200,7 @@ "metadata": {}, "outputs": [], "source": [ + "# GH2 calibration data object.\n", "g2_cal = GOTTHARD2_CalibrationData(\n", " detector_name=karabo_id,\n", " sensor_bias_voltage=bias_voltage,\n", @@ -211,16 +210,8 @@ " single_photon=single_photon,\n", " event_at=creation_time,\n", " client=rest_cfg.calibration_client(),\n", - ")" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "id": "9609a142-99a4-42e5-94f0-abe9cc99cc21", - "metadata": {}, - "outputs": [], - "source": [ + ")\n", + "\n", "da_to_pdu = None\n", "# Keep as long as it is essential to correct\n", "# RAW data (FXE p003225) before the data mapping was added to CALCAT.\n", @@ -231,7 +222,6 @@ " db_modules = [None] * len(karabo_da)\n", "\n", "if da_to_pdu:\n", - "\n", " if karabo_da == [\"\"]:\n", " karabo_da = sorted(da_to_pdu.keys())\n", " else:\n", @@ -240,6 +230,8 @@ "\n", " db_modules = [da_to_pdu[da] for da in karabo_da]\n", "\n", + "print(f\"Process modules: {db_modules} for run {run}\")\n", + "\n", "# Create the correction receiver name.\n", "receivers = sorted(list(run_dc.select(f'{karabo_id}/DET/{receiver_template}*').all_sources))\n", "if gh2_detector == \"25um\": # For 25um use virtual karabo_das for CALCAT data mapping.\n", @@ -347,17 +339,19 @@ { "cell_type": "code", "execution_count": null, - "id": "b41f3720-2abd-43ed-b948-8d2f0815b6a3", + "id": "2c7dd0bb", "metadata": {}, "outputs": [], "source": [ - "raw_da = karabo_da if gh2_detector == \"50um\" else [karabo_da[0].split(\"/\")[0]]\n", + "file_da = list({kda.split('/')[0] for kda in karabo_da})\n", "mapped_files, total_files = map_seq_files(\n", " run_folder,\n", - " raw_da,\n", + " file_da,\n", " sequences,\n", ")\n", - "seq_files = mapped_files[raw_da[0]]\n", + "# This notebook doesn't account for processing more\n", + "# than one file data aggregator.\n", + "seq_files = mapped_files[file_da[0]]\n", "\n", "if not len(seq_files):\n", " raise IndexError(\n", diff --git a/src/xfel_calibrate/calibrate.py b/src/xfel_calibrate/calibrate.py index 1aca55b86..8ffcc29aa 100755 --- a/src/xfel_calibrate/calibrate.py +++ b/src/xfel_calibrate/calibrate.py @@ -115,7 +115,7 @@ def balance_sequences(in_folder: str, run: int, sequences: List[int], # data-mapping for LPD mini and GH2 25um uses karabo-da names like # LPDMINI00/2 or DA01/2 to identify individual modules. The /2 is not # part of the file name - karabo_da = [kda.split('/')[0] for kda in karabo_da] + karabo_da = list({kda.split('/')[0] for kda in karabo_da}) in_path = Path(in_folder, f"r{run:04d}") -- GitLab