From 5c85745474f7dfd2654d28a606a482566714f29f Mon Sep 17 00:00:00 2001 From: Cyril Danilevski <cyril.danilevski@xfel.eu> Date: Thu, 16 Sep 2021 11:46:46 +0200 Subject: [PATCH] Add Gain setting to Jungfrau notebooks --- .../Jungfrau_Gain_Correct_and_Verify_NBC.ipynb | 10 +++++++--- ..._dark_analysis_all_gains_burst_mode_NBC.ipynb | 16 ++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb index cd968ed1f..f12b51ac3 100644 --- a/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_Gain_Correct_and_Verify_NBC.ipynb @@ -44,6 +44,7 @@ "photon_energy = 9.2 # photon energy in keV\n", "chunk_size_idim = 1 # chunking size of imaging dimension, adjust if user software is sensitive to this.\n", "integration_time = 4.96 # integration time in us, will be overwritten by value in file\n", + "gain_setting = 0 # 0 for dynamic gain, 1 for dynamic HG0, will be overwritten by value in file\n", "mem_cells = 0 # leave memory cells equal 0, as it is saved in control information starting 2019.\n", "db_module = [\"Jungfrau_M275\"] # ID of module in calibration database\n", "manual_slow_data = False # if true, use manually entered bias_voltage and integration_time values\n", @@ -184,7 +185,9 @@ " 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", + " \n", + " gain_s = f[f'/RUN/{karabo_id_control}/DET/CONTROL/settings/value'][0].decode()\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", "try:\n", @@ -206,6 +209,7 @@ " print(f\"Error trying to access memory cell from contol information: {e}\")\n", "\n", "print(f\"Integration time is {integration_time} us\")\n", + "print(f\"Gain setting is {gain_setting}\")\n", "print(f\"Bias voltage is {bias_voltage} V\")\n", "print(f\"Number of memory cells is {memory_cells}\")" ] @@ -220,6 +224,7 @@ " memory_cells=memory_cells,\n", " bias_voltage=bias_voltage,\n", " integration_time=integration_time,\n", + " gain_setting=gain_setting,\n", ")\n", "\n", "def get_constants_for_module(karabo_da: str):\n", @@ -304,8 +309,7 @@ "outputs": [], "source": [ "def copy_and_sanitize_non_cal_data(infile, outfile, h5base):\n", - " \"\"\" Copy and sanitize data in `infile` that is not touched by `correctLPD`\n", - " \"\"\"\n", + " \"\"\"Copy and sanitize data from `infile` that is not calibrated.\"\"\"\n", "\n", " h5base = h5base.lstrip(\"/\")\n", " dont_copy = [\"adc\", ]\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 9c2c7086b..71d405404 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 @@ -42,6 +42,7 @@ "db_output = False # output constants to database\n", "\n", "integration_time = 1000 # integration time in us, will be overwritten by value in file\n", + "gain_setting = 0 # 0 for dynamic, forceswitchg1, forceswitchg2, 1 for dynamichg0, fixedgain1, fixgain2. Will be overwritten by value in file\n", "bias_voltage = 90 # sensor bias voltage in V, will be overwritten by value in file\n", "badpixel_threshold_sigma = 5. # bad pixels defined by values outside n times this std from median\n", "offset_abs_threshold_low = [1000, 10000, 10000] # absolute bad pixel threshold in terms of offset, lower values\n", @@ -217,6 +218,13 @@ " 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", + " if r_n == run_high:\n", + " gain_s = f[f'/RUN/{karabo_id_control}/DET/CONTROL/settings/value'][0].decode()\n", + " gain_setting = 1 if gain_s == \"dynamichg0\" else 0\n", + " print(f\"Constants Gain setting is {gain_setting} ({gain_s})\")\n", + "\n", + "\n", " print(\"Integration time is {} us\".format(integration_time))\n", " print(\"Bias voltage is {} V\".format(bias_voltage))\n", " if this_run_mcells == 1:\n", @@ -381,9 +389,7 @@ " ax_n0.set_xlabel(f'RMS noise {g_name[g_idx]} ' + unit, fontsize=15)\n", " #ax_n0.set_yscale('log')\n", " \n", - " plt.show()\n", - " \n", - " " + " plt.show() " ] }, { @@ -474,7 +480,8 @@ "\n", " # set the operating condition\n", " condition = Conditions.Dark.jungfrau(memory_cells=memoryCells, bias_voltage=bias_voltage,\n", - " integration_time=integration_time)\n", + " integration_time=integration_time,\n", + " gain_setting=gain_setting)\n", " \n", " for parm in condition.parameters:\n", " if parm.name == \"Integration Time\":\n", @@ -504,6 +511,7 @@ "print(\"Constants parameter conditions are:\\n\")\n", "print(f\"• Bias voltage: {bias_voltage}\\n• Memory cells: {memoryCells}\\n\"\n", " f\"• Integration time: {integration_time}\\n\"\n", + " f\"• Gain setting: {gain_setting}\\n\"\n", " f\"• Creation time: {md.calibration_constant_version.begin_at if md is not None else creation_time}\\n\")" ] }, -- GitLab