From 365625242f510692dbb9831a8810082c599ff295 Mon Sep 17 00:00:00 2001 From: Cyril Danilevski <cydanil@gmail.com> Date: Sun, 20 Sep 2020 11:02:47 +0200 Subject: [PATCH] Update agipd get_acq_rate signature The acquisition rate will be found in fast data files by default (which are now passed as a tuple), and will look into slow data if provided --- cal_tools/cal_tools/agipdlib.py | 5 +++-- notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb | 2 +- .../AGIPD/AGIPD_Retrieve_Constants_Precorrection.ipynb | 2 +- notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb | 6 +++--- .../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 +- 7 files changed, 11 insertions(+), 10 deletions(-) diff --git a/cal_tools/cal_tools/agipdlib.py b/cal_tools/cal_tools/agipdlib.py index 5622e9e65..e2eda82b3 100644 --- a/cal_tools/cal_tools/agipdlib.py +++ b/cal_tools/cal_tools/agipdlib.py @@ -25,8 +25,9 @@ def get_num_cells(fname, loc, module): return options[np.argmin(dists)] -def get_acq_rate(slow_paths: Tuple[str, str], - fast_paths: Tuple[str, str, int]) -> Optional[float]: +def get_acq_rate(fast_paths: Tuple[str, str, int], + slow_paths: Optional[Tuple[str, str]] = ('', '') + ) -> Optional[float]: """Get the acquisition rate from said detector module. If the data is available from the middlelayer FPGA_COMP device, then it is diff --git a/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb b/notebooks/AGIPD/AGIPD_Correct_and_Verify.ipynb index 5296ecc33..e906d9921 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 99ec430f2..8a2ded984 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_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index 8f377fe52..49ec24e1d 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -51,8 +51,8 @@ "\n", "mem_cells = 0 # number of memory cells used, set to 0 to automatically infer\n", "bias_voltage = 300 # detector bias voltage\n", - "gain_setting = 0.0 # the gain setting, use 0.1 to try to auto-determine\n", - "acq_rate = 1.1 # the detector acquisition rate, use 0 to try to auto-determine\n", + "gain_setting = 0.1 # the gain setting, use 0.1 to try to auto-determine\n", + "acq_rate = 0. # the detector acquisition rate, use 0 to try to auto-determine\n", "interlaced = False # assume interlaced data format, for data prior to Dec. 2017\n", "rawversion = 2 # RAW file format version\n", "\n", @@ -462,7 +462,7 @@ "max_cells = np.max(all_cells)\n", "print(f\"Using {max_cells} memory cells\")\n", "acq_rate = np.max(all_acq_rate)\n", - "print(f\"Using {acq_rate:0.1f} MHz acquisition rate\")" + "print(f\"Using {acq_rate} MHz acquisition rate\")" ] }, { diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_FlatFields_NBC.ipynb index 9775a0772..6c7a36b8f 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 69ca41eb4..e137d6ac8 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 93b63f2cf..f727a1a94 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