From 5c06f05338f3c3248f1135436c32c2ced5d933b2 Mon Sep 17 00:00:00 2001 From: Cyril Danilevski <cyril.danilevski@xfel.eu> Date: Wed, 16 Sep 2020 17:18:04 +0200 Subject: [PATCH] Update get_acq_rate calls in AGIPD notebooks Acquisition rate is now accessible from either fast or slow data. The function signature changed --- cal_tools/cal_tools/agipdlib.py | 4 ++-- notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb | 2 +- notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb | 2 +- notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb | 2 +- notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb | 2 +- notebooks/AGIPD/playground/AGIPD_SingleM_test_Dark.ipynb | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py index bafdbe3ae..6268fcfe6 100644 --- a/cal_tools/cal_tools/agipdlib.py +++ b/cal_tools/cal_tools/agipdlib.py @@ -51,7 +51,7 @@ def get_acq_rate(slow_paths: Tuple[str, str], # Attempt to look for acquisition rate in slow data slow_data_file, karabo_id_control = slow_paths slow_data_file = Path(slow_data_file) - if slow_data_file.exists(): + if slow_data_file.is_file(): slow_data_path = f'CONTROL/{karabo_id_control}/MDL/FPGA_COMP/bunchStructure/repetitionRate/value' # noqa with h5py.File(slow_data_file, "r") as fin: if slow_data_path in fin: @@ -60,7 +60,7 @@ def get_acq_rate(slow_paths: Tuple[str, str], # Compute acquisition rate from fast data fast_data_file, karabo_id, module = fast_paths fast_data_file = Path(fast_data_file) - if fast_data_file.exists(): + if fast_data_file.is_file(): fast_data_path = f'INSTRUMENT/{karabo_id}/DET/{module}CH0:xtdf/image/pulseId' # noqa with h5py.File(fast_data_file) as fin: if fast_data_path in fin: diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index d7803821c..5296ecc33 100644 --- a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb +++ b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb @@ -313,7 +313,7 @@ "\n", "# Evaluate aquisition rate\n", "if acq_rate == 0:\n", - " acq_rate = get_acq_rate(filename, karabo_id, channel)\n", + " acq_rate = get_acq_rate(('', '') (filename, karabo_id, channel))\n", "else:\n", " acq_rate = None\n", "\n", diff --git a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb index 8f3df25d2..99ec430f2 100644 --- a/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb +++ b/notebooks/AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb @@ -271,7 +271,7 @@ " break\n", "\n", " if acq_rate == 0.:\n", - " acq_rate = get_acq_rate(f, karabo_id, idx)\n", + " acq_rate = get_acq_rate(('', ''), (f, karabo_id, idx))\n", " else:\n", " acq_rate = None\n", "\n", diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb index 9f4a3351b..9775a0772 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb @@ -189,7 +189,7 @@ "channel = 0\n", "fname = fbase.format(runs[0], runs[0].upper(), channel, sequences[0])\n", "if acqrate == 0.:\n", - " acqrate = get_acq_rate(fname, loc, channel)\n", + " acqrate = get_acq_rate(('', ''), (fname, loc, channel))\n", " \n", "\n", "if mem_cells == 0:\n", diff --git a/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb b/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb index 2542e9d50..69ca41eb4 100644 --- a/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb +++ b/notebooks/AGIPD/Chracterize_AGIPD_Gain_PC_NBC.ipynb @@ -159,7 +159,7 @@ " print('Reading ',fname)\n", " \n", " if acq_rate == 0.:\n", - " acq_rate = get_acq_rate(fname, loc, channel)\n", + " acq_rate = get_acq_rate(('', ''), (fname, loc, channel))\n", " print(\"Acquisition rate set from file: {} MHz\".format(acq_rate))\n", "\n", " if mem_cells == 0:\n", diff --git a/notebooks/AGIPD/playground/AGIPD_SingleM_test_Dark.ipynb b/notebooks/AGIPD/playground/AGIPD_SingleM_test_Dark.ipynb index 551f5f98a..93b63f2cf 100644 --- a/notebooks/AGIPD/playground/AGIPD_SingleM_test_Dark.ipynb +++ b/notebooks/AGIPD/playground/AGIPD_SingleM_test_Dark.ipynb @@ -260,7 +260,7 @@ " cells = get_num_cells(filename, loc, channel)\n", " \n", " if acq_rate == 0.:\n", - " acq_rate = get_acq_rate(filename, loc, channel)\n", + " acq_rate = get_acq_rate(('', ''), (filename, loc, channel))\n", " \n", " thresholds_offset, thresholds_offset_sigma, thresholds_noise, thresholds_noise_sigma = bp_thresh \n", " thresholds_offset_hard = thresholds_offset[gg]\n", -- GitLab