From 48229114275b99f355ac433eab29066443daceb7 Mon Sep 17 00:00:00 2001 From: ahmedk <karim.ahmed@xfel.eu> Date: Mon, 24 Oct 2022 22:53:18 +0200 Subject: [PATCH] update extra-geom, cfelpyutils, update plot, and dont remove module YAML files --- ...rk_analysis_all_gains_burst_mode_NBC.ipynb | 2 +- .../Jungfrau/Jungfrau_darks_Summary_NBC.ipynb | 59 +++++++++++-------- setup.py | 4 +- 3 files changed, 39 insertions(+), 26 deletions(-) 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 a98cb8230..c394e0c86 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 @@ -693,7 +693,7 @@ " for const in consts:\n", " display(Markdown(f\" - {const} at {consts[const]['timestamp']}\"))\n", " # saving locations of old constants for summary notebook\n", - " with open(f\"{out_folder}/module_metadata_{mod}.yml\", \"w\") as fd:\n", + " with open(f\"{metadata_folder}/module_metadata_{mod}.yml\", \"w\") as fd:\n", " yaml.safe_dump(\n", " {\n", " \"module\": mod,\n", diff --git a/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb b/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb index 05b5b2033..0e3818a73 100644 --- a/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb +++ b/notebooks/Jungfrau/Jungfrau_darks_Summary_NBC.ipynb @@ -4,9 +4,9 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "# Jungfrau Dark Summary #\n", + "# Jungfrau Dark Summary\n", "\n", - "Author: European XFEL Detector Group, Version: 1.0\n", + "Author: European XFEL Detector Department, Version: 1.0\n", "\n", "Summary for process dark constants and a comparison with previously injected constants with the same conditions." ] @@ -77,13 +77,12 @@ "dark_constants = [\"Offset\", \"Noise\", \"BadPixelsDark\"]\n", "\n", "prev_const_metadata = {}\n", - "for fn in out_folder.glob(\"module_metadata_*.yml\"):\n", + "for fn in Path(metadata_folder or out_folder).glob(\"module_metadata_*.yml\"):\n", " with fn.open(\"r\") as fd:\n", " fdict = yaml.safe_load(fd)\n", " module = fdict[\"module\"]\n", " mod_mapping[module] = fdict[\"pdu\"]\n", " prev_const_metadata[module] = fdict[\"old-constants\"]\n", - " fn.unlink()\n", "\n", "metadata.save()" ] @@ -180,6 +179,12 @@ " \"BadPixelsDark\": [(0., 5.), (0., 5.), (0., 5.)],\n", "}\n", "\n", + "diff_const_range = {\n", + " \"Offset\": [(0, 500), (0, 500), (0, 500)],\n", + " \"Noise\": [(0., 5.), (0., 5.), (0., 5.)],\n", + " \"BadPixelsDark\": [(0., 5.), (0., 5.), (0., 5.)],\n", + "}\n", + "\n", "gs = gridspec.GridSpec(2, 4)\n", "\n", "axis = OrderedDict({\n", @@ -187,14 +192,16 @@ " \"gs\": gs[0, 1:3],\n", " \"shrink\": 0.9,\n", " \"pad\": 0.05,\n", - " \"label\": \"ADUs\",\n", + " \"label\": \"ADCu\",\n", " \"title\": '{}',\n", + " 'location': 'right',\n", " },\n", " \"ax1\": {\n", " \"gs\": gs[1, :2],\n", " \"shrink\": 0.6,\n", " \"pad\": 0.05,\n", - " \"label\": \"ADUs\",\n", + " \"label\": \"ADCu\",\n", + " 'location': 'left',\n", " \"title\": 'Difference with previous {}',\n", " },\n", " \"ax2\": {\n", @@ -202,6 +209,7 @@ " \"shrink\": 0.6,\n", " \"pad\": 0.05,\n", " \"label\": \"%\",\n", + " 'location': 'right',\n", " \"title\": 'Difference with previous {} %'},\n", " })" ] @@ -227,8 +235,8 @@ " # the difference with the previous constant\n", " # and the fraction of that difference.\n", " mean_const = np.nanmean(const, axis=3)\n", - " mean_diff = np.nanmean(const, axis=3) - np.nanmean(prev_constants[cname], axis=3)\n", - " mean_frac = (mean_diff / mean_const) * 100\n", + " mean_diff = np.abs(np.nanmean(const, axis=3) - np.nanmean(prev_constants[cname], axis=3)) # noqa\n", + " mean_frac = np.abs(mean_diff / mean_const) * 100\n", " \n", " for gain in range(gainstages):\n", " plot_data = {\n", @@ -247,37 +255,40 @@ " # Add the min and max plot values for each axis.\n", " if axname == \"ax0\":\n", " vmin, vmax = const_range[cname][gain]\n", + " elif axname == \"ax2\":\n", + " vmin, vmax = 0, 100\n", " else:\n", - " vmin, vmax = get_range(plot_data[axname], 2)\n", + " vmin, vmax = diff_const_range[cname][gain]\n", " ax = fig.add_subplot(axv[\"gs\"])\n", "\n", " geom.plot_data_fast(\n", " plot_data[axname],\n", " vmin=vmin, vmax=vmax, ax=ax, \n", " colorbar={\n", - " 'shrink': axv[\"shrink\"],\n", - " 'pad': axv[\"pad\"],\n", - " },\n", + " \"shrink\": axv[\"shrink\"],\n", + " \"pad\": axv[\"pad\"],\n", + " \"location\": axv[\"location\"]},\n", " )\n", "\n", " colorbar = ax.images[0].colorbar\n", - " colorbar.set_label(axv[\"label\"])\n", + " colorbar.set_label(axv[\"label\"], fontsize=15)\n", " colorbar.ax.tick_params(labelsize=15)\n", - " ax.tick_params(labelsize=15)\n", + " ax.tick_params(labelsize=1)\n", " ax.set_title(axv[\"title\"].format(\n", " f\"{cname} {gain_names[gain]}\"), fontsize=15)\n", - " ax.set_xlabel('Columns', fontsize=15)\n", - " ax.set_ylabel('Rows', fontsize=15)\n", + " \n", + " if axname == \"ax0\":\n", + " ax.set_xlabel('Columns', fontsize=15)\n", + " ax.set_ylabel('Rows', fontsize=15)\n", + " ax.tick_params(labelsize=15)\n", + " else:\n", + " ax.tick_params(labelsize=0)\n", + " # Remove axes labels for comparison plots.\n", + " ax.set_xlabel('')\n", + " ax.set_ylabel('')\n", " plt.show()" ] }, - { - "cell_type": "markdown", - "metadata": {}, - "source": [ - "## Summary across pixels per memory cells" - ] - }, { "cell_type": "code", "execution_count": null, @@ -285,6 +296,8 @@ "outputs": [], "source": [ "if curr_constants[\"Offset\"].shape[-2] > 1:\n", + " display(Markdown(\"## ## Summary across pixels per memory cells\"))\n", + "\n", " # Loop over modules and constants\n", " for const_name, const in curr_constants.items():\n", " display(Markdown(f'### {const_name}'))\n", diff --git a/setup.py b/setup.py index aae7823b4..d7324fd81 100644 --- a/setup.py +++ b/setup.py @@ -58,14 +58,14 @@ install_requires = [ "markupsafe==2.0.1", "astcheck==0.2.5", "astsearch==0.2.0", - "cfelpyutils==1.0.1", + "cfelpyutils==2.0.6", "calibration_client==10.0.0", "dill==0.3.0", "docutils==0.17.1", "dynaconf==3.1.4", "env_cache==0.1", "extra_data==1.12.0", - "extra_geom==1.6.0", + "extra_geom==1.8.0", "gitpython==3.1.0", "h5py==3.5.0", "iminuit==1.3.8", -- GitLab