diff --git a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb index b5d136c2735473ec0cef8107082bc346f45d3601..eaae915a6a8f7562452b0b4dd4f116b9f44be484 100644 --- a/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb +++ b/notebooks/AGIPD/Characterize_AGIPD_Gain_Darks_NBC.ipynb @@ -161,9 +161,9 @@ "metadata": {}, "outputs": [], "source": [ - "control_fname = '{}/r{:04d}/RAW-R{:04d}-{}-S00000.h5'.format(in_folder, run_high, \n", - " run_high, karabo_da_control)\n", "gain_names = ['High', 'Medium', 'Low']\n", + "runs = [run_high, run_med, run_low]\n", + "\n", "if \"{\" in h5path_ctrl:\n", " h5path_ctrl = h5path_ctrl.format(karabo_id_control)\n", "\n", @@ -173,11 +173,20 @@ " gain_setting = None\n", " else:\n", " try:\n", - " gain_setting = get_gain_setting(control_fname, h5path_ctrl)\n", + " # extract gain setting and validate that all runs have the same setting\n", + " gsettings = []\n", + " for r in runs:\n", + " control_fname = '{}/r{:04d}/RAW-R{:04d}-{}-S00000.h5'.format(in_folder, r, r,\n", + " karabo_da_control)\n", + " gsettings.append(get_gain_setting(control_fname, h5path_ctrl))\n", + " if not all(g == gsettings[0] for g in gsettings):\n", + " raise ValueError(f\"Different gain settings for the 3 input runs {gsettings}\")\n", + " gain_setting = gsettings[0] \n", " except Exception as e:\n", " print(f'Error while reading gain setting from: \\n{control_fname}')\n", - " print(e)\n", - " print(\"Gain setting is not found in the control information\")\n", + " print(f'Error: {e}')\n", + " if \"component not found\" in str(e):\n", + " print(\"Gain setting is not found in the control information\")\n", " print(\"Data will not be processed\")\n", " sequences = []" ] @@ -510,7 +519,9 @@ { "cell_type": "code", "execution_count": null, - "metadata": {}, + "metadata": { + "scrolled": false + }, "outputs": [], "source": [ "# Retrieve existing constants for comparison\n", @@ -852,8 +863,9 @@ " l_data_name = ['All bad pixels', 'NOISE_OUT_OF_THRESHOLD', \n", " 'OFFSET_OUT_OF_THRESHOLD', 'OFFSET_NOISE_EVAL_ERROR', 'GAIN_THRESHOLDING_ERROR']\n", "\n", - " l_threshold = ['', f'{thresholds_noise_sigma}', f'{thresholds_offset_sigma}',\n", - " f'{thresholds_offset_hard[gain]}/{thresholds_noise_hard[gain]}', '']\n", + " l_threshold = ['', f'{thresholds_noise_sigma}' f'{thresholds_noise_hard[gain]}', \n", + " f'{thresholds_offset_sigma}' f'{thresholds_offset_hard[gain]}',\n", + " '', f'{thresholds_gain_sigma}']\n", "\n", " for i in range(len(l_data)):\n", " line = [f'{l_data_name[i]}, {gain_names[gain]} gain', l_threshold[i], l_data[i]]\n", @@ -885,7 +897,6 @@ "metadata": {}, "outputs": [], "source": [ - "\n", "header = ['Parameter', \n", " \"New constant\", \"Old constant \", \n", " \"New constant\", \"Old constant \", \n", @@ -935,13 +946,6 @@ " md = display(Latex(tabulate.tabulate(table, tablefmt='latex', headers=header))) " ] }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, { "cell_type": "code", "execution_count": null, diff --git a/notebooks/generic/overallmodules_Darks_Summary_NBC.ipynb b/notebooks/generic/overallmodules_Darks_Summary_NBC.ipynb index c0727777f64309511e2dbb16f684adcb09e1d7a4..0cec5017a78fa113f6c79e7ffbabd555b1cb55d2 100644 --- a/notebooks/generic/overallmodules_Darks_Summary_NBC.ipynb +++ b/notebooks/generic/overallmodules_Darks_Summary_NBC.ipynb @@ -355,9 +355,9 @@ " fig = plt.figure(figsize=(24, 32))\n", "\n", " axis = OrderedDict()\n", - " axis = {\"ax0\": {\"cname\": \"{}\" ,\"gs\": gs[0, :], \"shrink\": 0.9, \"pad\": 0.05, \"label\": \"ADUs\"},\n", - " \"ax1\": {\"cname\": \"d-{}\",\"gs\": gs[1, 0], \"shrink\": 0.6, \"pad\": 0.1, \"label\": \"ADUs\"},\n", - " \"ax2\": {\"cname\": \"dpct-{}\", \"gs\": gs[1, 1], \"shrink\": 0.6, \"pad\": 0.1, \"label\": \"%\"}}\n", + " axis = {\"ax0\": {\"cname\": \"{}\" ,\"gs\": gs[0, :], \"shrink\": 0.9, \"pad\": 0.05, \"label\": \"ADUs\", \"title\": '{}'},\n", + " \"ax1\": {\"cname\": \"d-{}\",\"gs\": gs[1, 0], \"shrink\": 0.6, \"pad\": 0.1, \"label\": \"ADUs\", \"title\": 'Difference with previous {}'},\n", + " \"ax2\": {\"cname\": \"dpct-{}\", \"gs\": gs[1, 1], \"shrink\": 0.6, \"pad\": 0.1, \"label\": \"%\", \"title\": 'Difference with previous {} %'}}\n", "\n", " for ax, axv in axis.items():\n", " # Add the min and max plot values for each axis.\n", @@ -373,7 +373,7 @@ " colorbar = ax.images[0].colorbar\n", " colorbar.set_label(axv[\"label\"])\n", "\n", - " ax.set_title(f'{const_name} {glabel[gain]}', fontsize=15)\n", + " ax.set_title(axv[\"title\"].format(f\"{const_name} {glabel[gain]}\"), fontsize=15)\n", " ax.set_xlabel('Columns', fontsize=15)\n", " ax.set_ylabel('Rows', fontsize=15)\n", "\n", @@ -546,20 +546,6 @@ " md = display(Latex(tabulate.tabulate(\n", " table, tablefmt='latex', headers=header)))" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] } ], "metadata": {