From 9ddb2a5e5c68cfcbe93b7811ed240fb1634eaf85 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 14 Jul 2023 14:32:25 +0000 Subject: [PATCH] style: pre-commit fixes --- ...00-plotting-concatenate_runs_periods.ipynb | 51 +++++++---------- notebook/L200-plotting-individual-runs.ipynb | 56 +++++++++---------- 2 files changed, 44 insertions(+), 63 deletions(-) diff --git a/notebook/L200-plotting-concatenate_runs_periods.ipynb b/notebook/L200-plotting-concatenate_runs_periods.ipynb index 71efc7a..dca5c67 100644 --- a/notebook/L200-plotting-concatenate_runs_periods.ipynb +++ b/notebook/L200-plotting-concatenate_runs_periods.ipynb @@ -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\"]" ] }, { @@ -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", @@ -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", @@ -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", @@ -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", @@ -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 } diff --git a/notebook/L200-plotting-individual-runs.ipynb b/notebook/L200-plotting-individual-runs.ipynb index 35d7235..6a8cdfa 100644 --- a/notebook/L200-plotting-individual-runs.ipynb +++ b/notebook/L200-plotting-individual-runs.ipynb @@ -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\"]" ] }, { @@ -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", @@ -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", @@ -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", @@ -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", @@ -641,22 +643,32 @@ "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", @@ -664,25 +676,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 }