Skip to content

Commit

Permalink
style: pre-commit fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Jul 14, 2023
1 parent 42829cb commit 9ddb2a5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 63 deletions.
51 changes: 19 additions & 32 deletions notebook/L200-plotting-concatenate_runs_periods.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,15 @@
"subsystem = \"geds\" # KEEP 'geds' for the moment\n",
"folder = \"prod-ref-v2\" # you can change me\n",
"version = \"\" # leave an empty string if you're looking at p03 data\n",
"periods = [\"p06\"] # one or more, eg = sorted(os.listdir(f\"/data1/users/calgaro/{folder}/generated/plt/phy/\"))\n",
"periods = [\n",
" \"p06\"\n",
"] # one or more, eg = sorted(os.listdir(f\"/data1/users/calgaro/{folder}/generated/plt/phy/\"))\n",
"\n",
"# ------------------------------------------------------------------------------------------ remove detectors from the plots\n",
"# do you want to remove some detectors? If so, put here their names (or empty list if you want everything included)\n",
"to_be_excluded = [] # [\"V01406A\", \"V01415A\", \"V01387A\", \"P00665C\", \"P00748B\", \"P00748A\", \"B00089D\"]"
"to_be_excluded = (\n",
" []\n",
") # [\"V01406A\", \"V01415A\", \"V01387A\", \"P00665C\", \"P00748B\", \"P00748A\", \"B00089D\"]"
]
},
{
Expand Down Expand Up @@ -77,9 +81,11 @@
"\n",
"%matplotlib widget\n",
"\n",
"# ------------------------------------------------------------------------------------------ select one data file \n",
"# ------------------------------------------------------------------------------------------ select one data file\n",
"# hypothesis: being these files under the same production folder, we expect them to contain the same keys - if not, an error will appear\n",
"run = sorted(os.listdir(f\"/data1/users/calgaro/{folder}/generated/plt/phy/{periods[0]}/\"))[0]\n",
"run = sorted(\n",
" os.listdir(f\"/data1/users/calgaro/{folder}/generated/plt/phy/{periods[0]}/\")\n",
")[0]\n",
"if version == \"\":\n",
" data_file = f\"/data1/users/calgaro/{folder}/generated/plt/phy/{periods[0]}/{run}/l200-{periods[0]}-{run}-phy-{subsystem}.hdf\"\n",
"else:\n",
Expand Down Expand Up @@ -225,7 +231,7 @@
" df_info = pd.DataFrame()\n",
" df_param_orig = pd.DataFrame()\n",
" df_param_var = pd.DataFrame()\n",
" df_param_mean = pd.DataFrame() \n",
" df_param_mean = pd.DataFrame()\n",
"\n",
" for period in periods:\n",
" runs = sorted(\n",
Expand Down Expand Up @@ -294,12 +300,8 @@
"# ---------------------------------------------------------------------------------- remove global spikes (if you are looking at cuspEmax)\n",
"# remove global spikes events by selecting their amplitude\n",
"if \"Cusp\" in param_widget.value:\n",
" new_df_param_orig = new_df_param_orig.loc[\n",
" new_df_param_var[\"value\"] > -10\n",
" ]\n",
" new_df_param_var = new_df_param_var.loc[\n",
" new_df_param_var[\"value\"] > -10\n",
" ]\n",
" new_df_param_orig = new_df_param_orig.loc[new_df_param_var[\"value\"] > -10]\n",
" new_df_param_var = new_df_param_var.loc[new_df_param_var[\"value\"] > -10]\n",
" print(\"--> global spikes were removed from cusp plot (threshold: +-10%)!\")\n",
"\n",
"# ---------------------------------------------------------------------------------- recalculate % variation wrt new mean value for all channels\n",
Expand All @@ -320,8 +322,11 @@
" new_df_param_var.loc[\n",
" new_df_param_var[\"channel\"] == ch, \"value\"\n",
" ] = new_ch_var\n",
"\"\"\" \n",
"print(\"...% variations were calculated again over the larger time window (mute me if you don't want to keep run-oriented % variations)!\")\n",
"\"\"\"\n",
"print(\n",
" \"...% variations were calculated again over the larger time window (mute me if you don't want to keep run-oriented % variations)!\"\n",
")\n",
"\n",
"\n",
"# ---------------------------------------------------------------------------------- change column names (again, needed for legend-data-monitor plots)\n",
"def convert_to_original_format(camel_case_string: str) -> str:\n",
Expand Down Expand Up @@ -558,25 +563,7 @@
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}
56 changes: 25 additions & 31 deletions notebook/L200-plotting-individual-runs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@
"\n",
"# ------------------------------------------------------------------------------------------ remove detectors from the plots\n",
"# do you want to remove some detectors? If so, put here their names (or empty list if you want everything included)\n",
"to_be_excluded = [] # [\"V01406A\", \"V01415A\", \"V01387A\", \"P00665C\", \"P00748B\", \"P00748A\", \"B00089D\"]"
"to_be_excluded = (\n",
" []\n",
") # [\"V01406A\", \"V01415A\", \"V01387A\", \"P00665C\", \"P00748B\", \"P00748A\", \"B00089D\"]"
]
},
{
Expand Down Expand Up @@ -527,8 +529,8 @@
"my_df = pd.DataFrame()\n",
"my_df[\"mean\"] = grouped_df.mean()\n",
"my_df[\"std\"] = grouped_df.std()\n",
"my_df[\"std_2\"] = 2*grouped_df.std()\n",
"my_df[\"std_3\"] = 3*grouped_df.std()\n",
"my_df[\"std_2\"] = 2 * grouped_df.std()\n",
"my_df[\"std_3\"] = 3 * grouped_df.std()\n",
"my_df[\"minimum\"] = grouped_df.min()\n",
"my_df[\"maximum\"] = grouped_df.max()\n",
"\n",
Expand Down Expand Up @@ -565,7 +567,7 @@
" linewidth=0,\n",
" zorder=3,\n",
" )\n",
" \n",
"\n",
" rect2 = Rectangle(\n",
" (current_index - box_width / 2, row[\"mean\"] - row[\"std_2\"]),\n",
" box_width,\n",
Expand All @@ -576,7 +578,7 @@
" linewidth=0,\n",
" zorder=3,\n",
" )\n",
" \n",
"\n",
" rect = Rectangle(\n",
" (current_index - box_width / 2, row[\"mean\"] - row[\"std\"]),\n",
" box_width,\n",
Expand All @@ -587,7 +589,7 @@
" linewidth=0,\n",
" zorder=2,\n",
" )\n",
" \n",
"\n",
" ax.add_patch(rect3)\n",
" ax.add_patch(rect2)\n",
" ax.add_patch(rect)\n",
Expand Down Expand Up @@ -641,48 +643,40 @@
"ax.hlines(-5, 0, len(name_list) - 1, color=\"tab:green\", zorder=3, linewidth=1)\n",
"\n",
"# Plot lines for std value thresholds\n",
"ax.hlines(10, 0, len(name_list) - 1, color=\"tab:orange\", zorder=3, linewidth=1, linestyle='--')\n",
"ax.hlines(-10, 0, len(name_list) - 1, color=\"tab:orange\", zorder=3, linewidth=1, linestyle='--')\n",
"ax.hlines(\n",
" 10, 0, len(name_list) - 1, color=\"tab:orange\", zorder=3, linewidth=1, linestyle=\"--\"\n",
")\n",
"ax.hlines(\n",
" -10,\n",
" 0,\n",
" len(name_list) - 1,\n",
" color=\"tab:orange\",\n",
" zorder=3,\n",
" linewidth=1,\n",
" linestyle=\"--\",\n",
")\n",
"\n",
"# Set labels and title\n",
"ax.set_xticks(np.arange(len(name_list)))\n",
"ax.set_xticklabels(name_list, rotation=90)\n",
"\n",
"# Show plot\n",
"x_min=min_input.value\n",
"x_max=max_input.value\n",
"x_min = min_input.value\n",
"x_max = max_input.value\n",
"if x_min == 0 and x_max == 0:\n",
" x_min = -50\n",
" x_max = 50\n",
"div = 12\n",
"ax.set_ylim([x_min,x_max])\n",
"ax.set_yticks(np.arange(x_min,x_max,div))\n",
"ax.set_ylim([x_min, x_max])\n",
"ax.set_yticks(np.arange(x_min, x_max, div))\n",
"ax.set_ylabel(f\"{param_widget.value} % variation\")\n",
"ax.set_title(f\"{period}-{run}\")\n",
"plt.tight_layout()\n",
"plt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.7"
}
},
"metadata": {},
"nbformat": 4,
"nbformat_minor": 5
}

0 comments on commit 9ddb2a5

Please sign in to comment.