Skip to content

Commit

Permalink
Highlight experiments chosen for comparison in the dissertation
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Nov 7, 2024
1 parent 61ebf0c commit 830f800
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 1 deletion.
70 changes: 69 additions & 1 deletion docs/notebooks/get_thermal_data.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
"from boilercv_pipeline.units import U\n",
"from dev.docs.nbs import get_mode, init\n",
"from devtools import pprint\n",
"from matplotlib.figure import Figure\n",
"from matplotlib.pyplot import subplots\n",
"from pandas import DataFrame, Series, concat, read_csv, read_hdf\n",
"from seaborn import lineplot, scatterplot\n",
Expand Down Expand Up @@ -73,6 +74,19 @@
"\n",
"contours = FindObjects(context=context).contours\n",
"\n",
"HIGHLIGHTS = [\"2024-07-18T17-07-13\", \"2024-07-18T18-04-05\", \"2024-07-18T18-49-55\"]\n",
"\"\"\"Chosen datasets to higlight in the dissertation.\"\"\"\n",
"WIDTH_SCALE = 1.257\n",
"\"\"\"Width to scale plots by.\"\"\"\n",
"HEIGHT_SCALE = 1.000\n",
"\"\"\"Width to scale plots by.\"\"\"\n",
"\n",
"\n",
"def scale_figure(fig: Figure, width: float = WIDTH_SCALE, height: float = HEIGHT_SCALE):\n",
" \"\"\"Scale up figure size.\"\"\"\n",
" fig.set_figwidth(width * fig.get_figwidth())\n",
" fig.set_figheight(height * fig.get_figheight())\n",
"\n",
"\n",
"def fit(df: DataFrame, flux: Col, sample_temps: Iterable[Col]) -> DataFrame:\n",
" \"\"\"Fit model function across sample temperatures.\"\"\"\n",
Expand Down Expand Up @@ -158,6 +172,20 @@
" ]\n",
" )\n",
" })\n",
" .assign(**{\n",
" C.highlight(): lambda df: df.index.isin(\n",
" df.index[\n",
" df.index.get_indexer(\n",
" [\n",
" dt_fromisolike(match)\n",
" for highlight in HIGHLIGHTS\n",
" if (match := ISOLIKE.search(highlight))\n",
" ],\n",
" method=\"nearest\",\n",
" )\n",
" ]\n",
" )\n",
" })\n",
" .reset_index()\n",
" .ffill()\n",
" .assign(**{\n",
Expand Down Expand Up @@ -193,6 +221,7 @@
" .agg({\n",
" **dict.fromkeys([c() for c in C.dests if c != C.index], \"median\"),\n",
" C.video(): \"max\",\n",
" C.highlight(): \"max\",\n",
" })\n",
" .reset_index()\n",
" ),\n",
Expand Down Expand Up @@ -238,8 +267,29 @@
" }).set_index(C.time_elapsed_min())[[C.video()]],\n",
" legend=False,\n",
")\n",
"scatterplot(\n",
" ax=ax,\n",
" s=9 * params.marker_scale,\n",
" markers={C.highlight(): \"d\"},\n",
" palette={C.highlight(): \"green\"},\n",
" data=data.dfs.resampled.assign(**{\n",
" C.highlight(): lambda df: df[df[C.highlight()]][C.superheat()]\n",
" }).set_index(C.time_elapsed_min())[[C.highlight()]],\n",
")\n",
"scatterplot(\n",
" ax=ax,\n",
" s=9 * params.marker_scale,\n",
" markers={C.highlight(): \"d\"},\n",
" palette={C.highlight(): \"green\"},\n",
" data=data.dfs.resampled.assign(**{\n",
" C.highlight(): lambda df: df[df[C.highlight()]][C.subcool()]\n",
" }).set_index(C.time_elapsed_min())[[C.highlight()]],\n",
" legend=False,\n",
")\n",
"\n",
"ax.set_ylabel(C.subcool.no_sub())\n",
"params.move_legend(ax)"
"params.move_legend(ax, ncol=4)\n",
"scale_figure(ax.get_figure())"
]
},
{
Expand All @@ -265,6 +315,15 @@
" C.video(): lambda df: df[df[C.video()]][C.flux()]\n",
" }).set_index(C.subcool())[[C.video()]],\n",
")\n",
"scatterplot(\n",
" ax=ax,\n",
" s=9 * params.marker_scale,\n",
" markers={C.highlight(): \"d\"},\n",
" palette={C.highlight(): \"green\"},\n",
" data=data.dfs.resampled.assign(**{\n",
" C.highlight(): lambda df: df[df[C.highlight()]][C.flux()]\n",
" }).set_index(C.subcool())[[C.highlight()]],\n",
")\n",
"ax.get_legend().set_title(C.time_elapsed_min()) # pyright: ignore[reportOptionalMemberAccess]\n",
"params.move_legend(ax, ncol=4)"
]
Expand Down Expand Up @@ -296,6 +355,15 @@
" C.video(): lambda df: df[df[C.video()]][C.flux()]\n",
" }).set_index(C.superheat())[[C.video()]],\n",
")\n",
"scatterplot(\n",
" ax=ax,\n",
" s=9 * params.marker_scale,\n",
" markers={C.highlight(): \"d\"},\n",
" palette={C.highlight(): \"green\"},\n",
" data=data.dfs.resampled.assign(**{\n",
" C.highlight(): lambda df: df[df[C.highlight()]][C.flux()]\n",
" }).set_index(C.superheat())[[C.highlight()]],\n",
")\n",
"ax.get_legend().set_title(C.time_elapsed_min()) # pyright: ignore[reportOptionalMemberAccess]\n",
"params.move_legend(ax, ncol=4)"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class Cols(columns.Cols):
flux: Ann[LinkedCol, D.dst] = LinkedCol("q''", "W/cm^2", source=Col("q''", "W/m^2"))
boiling: Ann[Col, D.dst] = Col("T_sat (C)")
video: Ann[Col, D.dst] = Col("Video")
highlight: Ann[Col, D.dst] = Col("Highlight")


@command(
Expand Down

0 comments on commit 830f800

Please sign in to comment.