diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb index f12b51ac321ef43cbf1e53a3438db8fd109b1841..2669038ee61ded85e5319eb28f96421e954e04ad 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 71d4054047de83d30c638da505f89aa5efa740a1..1f83b622b0740ac85a2f1421629fed1064cfa6c9 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",