{ "cells": [ { "cell_type": "code", "execution_count": null, "metadata": { "tags": [ "hide-output" ] }, "outputs": [], "source": [ "!pip install matplotlib pandas pyarrow seaborn" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import seaborn as sns\n", "import matplotlib.pyplot as plt\n", "\n", "plt.rcParams[\"font.family\"] = \"sans\"\n", "plt.rcParams[\"font.size\"] = 8\n", "sns.set_palette('muted')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Shot Metadata\n", "\n", "This notebook contains a demonstration of plotting several of the summary statistics that accompany the shot metadata. \n", "\n", "Firstly, we're going to load all the shot data into a pandas dataframe:" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "summary = pd.read_parquet('https://mastapp.site/parquet/level2/shots')\n", "summary" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Summary Statistics About Shots\n", "\n", "Let's look at a summary of simple counts of different shot metadata." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "\n", "fig, axes = plt.subplots(2, 2, figsize=(10, 5))\n", "ax1, ax2, ax3, ax4 = axes.flatten()\n", "\n", "sns.histplot(summary, y='heating', hue='campaign', multiple=\"stack\", ax=ax1)\n", "sns.histplot(summary, y='plasma_shape', hue='campaign', multiple=\"stack\", ax=ax2)\n", "sns.histplot(summary, y='current_range', hue='campaign', multiple=\"stack\", ax=ax3)\n", "sns.histplot(summary, y=summary.pellets.astype(str), hue='campaign', multiple=\"stack\", ax=ax4)\n", "\n", "for ax in axes.flatten():\n", " ax.set_xlabel('No. Shots')\n", "\n", "plt.tight_layout()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plasma Beta ($\\beta$) v.s Confinement Time ($\\tau_E$)\n", "\n", "This plot can show how the efficiency of energy confinement varies with plasma pressure." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure()\n", "sns.scatterplot(summary, y='cpf_tautot_max', x='cpf_betmhd_max', hue='heating')\n", "plt.xlim(0, 18)\n", "plt.ylim(0, 1)\n", "plt.ylabel('Confinement time $\\\\tau_E$ (s)')\n", "plt.xlabel('Plasma Beta $\\\\beta$ (%)')\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plasma Temperature ($T_e$) vs. Plasma Density ($n_e$)\n", "This can reveal the relationship between temperature and density, which is critical for achieving the conditions necessary for fusion." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure()\n", "sns.scatterplot(summary, y='cpf_te0_ipmax', x='cpf_ne0_ipmax', hue='current_range', alpha=0.8)\n", "plt.xlim(0, .8e20)\n", "plt.ylim(0, 1750)\n", "plt.ylabel('Temperature $T_e$ (eV)')\n", "plt.xlabel('Density $n_e$ ($m^{-3}$)')\n", "plt.show()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Plasma Current ($I_p$) vs. Confinement Time ($\\tau_E$)\n", "\n", "This can indicate how the plasma current affects the confinement time, providing insights into stability and performance." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "plt.figure()\n", "sns.scatterplot(summary, y='cpf_ip_av', x='cpf_tautot_max', hue='current_range', alpha=0.8)\n", "plt.xlim(0, 1)\n", "plt.xlabel('Confinement Time $\\\\tau_E$ (s)')\n", "plt.ylabel('Average Plasma Current $I_p$ (kA)')\n", "plt.show()" ] } ], "metadata": { "kernelspec": { "display_name": ".venv", "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.13.3" } }, "nbformat": 4, "nbformat_minor": 2 }