From c92872fd5b10fec6b041a422397c8f226c771fec Mon Sep 17 00:00:00 2001 From: Karim Ahmed <karim.ahmed@xfel.eu> Date: Fri, 17 Sep 2021 13:37:07 +0200 Subject: [PATCH] Set gain_setting to 0 for old JF runs --- .../Jungfrau_Gain_Correct_and_Verify_NBC.ipynb | 11 +++++++++-- ...gfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb | 9 ++++++++- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb index f12b51ac3..2669038ee 100644 --- a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb @@ -185,8 +185,15 @@ " run_path = h5path_run.format(karabo_id_control, receiver_control_id)\n", " integration_time = float(f[f'{run_path}/exposureTime/value'][()]*1e6)\n", " bias_voltage = int(np.squeeze(f[f'{run_path}/vHighVoltage/value'])[0])\n", - " \n", - " gain_s = f[f'/RUN/{karabo_id_control}/DET/CONTROL/settings/value'][0].decode()\n", + " try:\n", + " gain_s = f[f'/RUN/{karabo_id_control}/DET/CONTROL/settings/value'][0].decode()\n", + " except KeyError:\n", + " print(\n", + " \"ERROR: gain_setting is not available for h5 ctrl path \"\n", + " f\"/RUN/{karabo_id_control}/DET/CONTROL/settings/value,\\nfor file: {fp_path_contr}. \\n\"\n", + " \"WARNING: Setting gain_setting to 0, assuming that this is an old run.\\n\"\n", + " )\n", + " gain_s = \"KeyError\"\n", " gain_setting = 1 if gain_s == 'dynamichg0' else 0 # gain_s == 'dynamicgain'\n", "\n", "control_path = h5path_cntrl.format(karabo_id_control, receiver_control_id)\n", diff --git a/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb index 71d405404..1f83b622b 100644 --- a/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_dark_analysis_all_gains_burst_mode_NBC.ipynb @@ -220,7 +220,14 @@ " bias_voltage = int(np.squeeze(f[f'{run_path}/vHighVoltage/value'])[0])\n", " \n", " if r_n == run_high:\n", - " gain_s = f[f'/RUN/{karabo_id_control}/DET/CONTROL/settings/value'][0].decode()\n", + " try:\n", + " gain_s = f[f'/RUN/{karabo_id_control}/DET/CONTROL/settings/value'][0].decode()\n", + " except KeyError:\n", + " print(\n", + " \"ERROR: gain_setting is not available for h5 ctrl path \"\n", + " f\"/RUN/{karabo_id_control}/DET/CONTROL/settings/value,\\nfor file: {fp_path}. \\n\"\n", + " \"WARNING: Setting gain_setting to 0, assuming that this is an old run.\\n\")\n", + " gain_s = \"KeyError\"\n", " gain_setting = 1 if gain_s == \"dynamichg0\" else 0\n", " print(f\"Constants Gain setting is {gain_setting} ({gain_s})\")\n", "\n", -- GitLab