From 0e535a23456dc79f4e993e28b8ea5caca2125bcc Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Tue, 20 Feb 2024 15:22:19 +0100 Subject: [PATCH] final changes related by differentiating between module index and module numbers. This should all be replaced with CALCAT metadata --- .../AGIPD/AGIPD_Correct_and_Verify.ipynb | 5 ++-- .../Characterize_AGIPD_Gain_Darks_NBC.ipynb | 28 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index 888cf41a2..2ac606a4e 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -289,10 +289,11 @@ " if modules[0] == -1:\n", " modules = list(range(nmods))\n", " karabo_da = [\"AGIPD{:02d}\".format(i) for i in modules]\n", - "else:\n", + "else: # TODO: fix this with the new CALCAT metadata for module indices.\n", " modules = [int(x[-2:]) for x in karabo_da]\n", + " mod_indices = modules if nmods > 1 else [0]\n", "\n", - "print(\"Process modules:\", ', '.join(module_index_to_qm(x) for x in modules))\n", + "print(\"Process modules:\", ', '.join(module_index_to_qm(x) for x in mod_indices))\n", "print(f\"Detector in use is {karabo_id}\")\n", "print(f\"Instrument {instrument}\")" ] diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index b89a5bccb..3218edf61 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -19,21 +19,21 @@ "metadata": {}, "outputs": [], "source": [ - "in_folder = \"/gpfs/exfel/d/raw/CALLAB/202031/p900113\" # path to input data, required\n", - "out_folder = \"\" # path to output to, required\n", + "in_folder = \"/gpfs/exfel/exp/HED/202430/p900438/raw\" # path to input data, required\n", + "out_folder = \"/gpfs/exfel/data/scratch/ahmedk/test/remove/agipd_sm/dark\" # path to output to, required\n", "metadata_folder = \"\" # Directory containing calibration_metadata.yml when run by xfel-calibrate\n", "modules = [-1] # list of modules to evaluate, RANGE ALLOWED\n", - "run_high = 9985 # run number in which high gain data was recorded, required\n", - "run_med = 9984 # run number in which medium gain data was recorded, required\n", - "run_low = 9983 # run number in which low gain data was recorded, required\n", + "run_high = 1 # run number in which high gain data was recorded, required\n", + "run_med = 2 # run number in which medium gain data was recorded, required\n", + "run_low = 3 # run number in which low gain data was recorded, required\n", "operation_mode = \"ADAPTIVE_GAIN\" # Detector operation mode, optional (defaults to \"ADAPTIVE_GAIN\")\n", "\n", - "karabo_id = \"HED_DET_AGIPD500K2G\" # karabo karabo_id\n", - "karabo_da = ['-1'] # a list of data aggregators names, Default [-1] for selecting all data aggregators\n", + "karabo_id = \"HED_DET_AGIPD65K1\" # karabo karabo_id\n", + "karabo_da = ['AGIPD08'] # a list of data aggregators names, Default [-1] for selecting all data aggregators\n", "receiver_template = \"{}CH0\" # inset for receiver devices\n", "instrument_source_template = '{}/DET/{}:xtdf' # path in the HDF5 file to images\n", "ctrl_source_template = '{}/MDL/FPGA_COMP' # path to control information\n", - "karabo_id_control = \"HED_EXP_AGIPD500K2G\" # karabo-id for control device '\n", + "karabo_id_control = \"HED_DET_AGIPD65K1\" # karabo-id for control device '\n", "\n", "use_dir_creation_date = True # use dir creation date as data production reference date\n", "cal_db_interface = \"tcp://max-exfl-cal001:8020\" # the database interface to use\n", @@ -170,7 +170,9 @@ " modules = list(range(nmods))\n", " karabo_da = create_karabo_da_list(modules)\n", "else:\n", + " # TODO: use CALCAT metadata for detector's modules indices.\n", " modules = [int(x[-2:]) for x in karabo_da]\n", + " mod_indices = modules if nmods > 1 else [0]\n", "\n", "print(f\"Detector in use is {karabo_id}\")\n", "print(f\"Instrument {instrument}\")\n", @@ -383,7 +385,7 @@ "print(f\"Will use {parallel_num_procs} processes with {parallel_num_threads} threads each\")\n", "\n", "def characterize_module(\n", - " channel: int, gain_run: Tuple[int, int],\n", + " mod_index: int, channel: int, gain_run: Tuple[int, int],\n", ") -> Tuple[int, int, np.array, np.array, np.array, np.array, np.array]:\n", "\n", " gain_index, run = gain_run\n", @@ -464,7 +466,7 @@ " bp[(noise < local_thresholds_noise_hard[0]) | (noise > local_thresholds_noise_hard[1])] |= BadPixels.NOISE_OUT_OF_THRESHOLD\n", " bp[~np.isfinite(noise)] |= BadPixels.OFFSET_NOISE_EVAL_ERROR\n", "\n", - " return channel, gain_index, offset, noise, gains, gains_std, bp" + " return mod_index, gain_index, offset, noise, gains, gains_std, bp" ] }, { @@ -477,7 +479,7 @@ "\n", "with multiprocessing.Pool(processes=parallel_num_procs) as pool:\n", " results = pool.starmap(\n", - " characterize_module, itertools.product(modules, list(enumerate(run_numbers))))\n", + " characterize_module, itertools.product(mod_indices, modules, list(enumerate(run_numbers))))\n", "\n", "step_timer.done_step(\"Processing dark from the 3 runs.\")\n", "\n", @@ -572,7 +574,7 @@ "outputs": [], "source": [ "res = OrderedDict()\n", - "for i in modules:\n", + "for i in mod_indices:\n", " qm = module_index_to_qm(i)\n", " res[qm] = {\n", " 'Offset': offset_g[qm],\n", @@ -618,7 +620,7 @@ " snapshot_at=creation_time.isoformat() if creation_time else None,\n", " timeout=cal_db_timeout\n", ")\n", - "for module_index, module_da, module_pdu in zip(modules, karabo_da, all_pdus):\n", + "for module_index, module_da, module_pdu in zip(mod_indices, karabo_da, all_pdus):\n", " qm = module_index_to_qm(module_index)\n", " qm_dict[qm] = {\n", " \"karabo_da\": module_da,\n", -- GitLab