!pip install matplotlib pandas pyarrow seaborn

Hide code cell output

Defaulting to user installation because normal site-packages is not writeable
Collecting matplotlib
  Downloading matplotlib-3.11.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (80 kB)
Requirement already satisfied: pandas in /home/runner/.local/lib/python3.12/site-packages (3.1.0)
Collecting pyarrow
  Downloading pyarrow-26.0.0-cp312-cp312-manylinux_2_28_x86_64.whl.metadata (3.0 kB)
Collecting seaborn
  Downloading seaborn-0.13.2-py3-none-any.whl.metadata (5.4 kB)
Collecting contourpy>=1.0.1 (from matplotlib)
  Downloading contourpy-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (3.8 kB)
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler-0.12.1-py3-none-any.whl.metadata (3.8 kB)
Collecting fonttools>=4.28.2 (from matplotlib)
  Downloading fonttools-4.67.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (137 kB)
Collecting kiwisolver>=1.3.1 (from matplotlib)
  Downloading kiwisolver-1.5.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl.metadata (5.2 kB)
Requirement already satisfied: numpy>=1.25 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (2.5.4)
Requirement already satisfied: packaging>=20.0 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (26.3)
Collecting pillow>=9 (from matplotlib)
  Downloading pillow-13.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.metadata (9.1 kB)
Requirement already satisfied: pyparsing>=3 in /usr/lib/python3/dist-packages (from matplotlib) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (3.0.0)
Requirement already satisfied: six>=1.6 in /usr/lib/python3/dist-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Requirement already satisfied: tzdata in /home/runner/.local/lib/python3.12/site-packages (from python-dateutil>=2.7->matplotlib) (2026.5)
Downloading matplotlib-3.11.2-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (9.9 MB)
?25l   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/9.9 MB ? eta -:--:--
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 9.9/9.9 MB 56.4 MB/s  0:00:00
?25h
Downloading pyarrow-26.0.0-cp312-cp312-manylinux_2_28_x86_64.whl (53.9 MB)
?25l   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/53.9 MB ? eta -:--:--
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╸ 53.7/53.9 MB 514.0 MB/s eta 0:00:01
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 53.9/53.9 MB 140.5 MB/s  0:00:00
?25hDownloading seaborn-0.13.2-py3-none-any.whl (294 kB)
Downloading contourpy-1.4.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (383 kB)
Downloading cycler-0.12.1-py3-none-any.whl (8.3 kB)
Downloading fonttools-4.67.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (5.4 MB)
?25l   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/5.4 MB ? eta -:--:--
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 5.4/5.4 MB 198.2 MB/s  0:00:00
?25h
Downloading kiwisolver-1.5.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl (1.5 MB)
?25l   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/1.5 MB ? eta -:--:--
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.5/1.5 MB 298.1 MB/s  0:00:00
?25hDownloading pillow-13.0.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (7.1 MB)
?25l   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 0.0/7.1 MB ? eta -:--:--
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.1/7.1 MB 177.6 MB/s  0:00:00
?25h
Installing collected packages: pyarrow, pillow, kiwisolver, fonttools, cycler, contourpy, matplotlib, seaborn
?25l
?25h
Successfully installed contourpy-1.4.0 cycler-0.12.1 fonttools-4.67.0 kiwisolver-1.5.1 matplotlib-3.11.2 pillow-13.0.0 pyarrow-26.0.0 seaborn-0.13.2
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt

plt.rcParams["font.family"] = "sans"
plt.rcParams["font.size"] = 8
sns.set_palette('muted')

Shot Metadata#

This notebook contains a demonstration of plotting several of the summary statistics that accompany the shot metadata.

Firstly, we’re going to load all the shot data into a pandas dataframe:

summary = pd.read_parquet('https://s3.echo.stfc.ac.uk/mast/fairmast-meta/l2_shots.parquet')
summary
shot_id facility equi_li2_max_current shot_summary type_ equi_max_li2 generic_min_radius_max_plasma title shot_experiment_number generic_max_poloidal_area ... nbi_total_injected_energy_ss nbi_injected_energy_ss_ruby_time nbi_power_max_ss nbi_power_truby_ss nbi_power_ss_max_current shot_scenario scenario rad_o2ratio radii_c2ratio shot_flat_top_duration
0 11766 MAST 0.902606 COMMISSIONED ENGINEERING PLASMA WITH MOST PLAN... dcat:Dataset 1.890299 0.080 Shot Dataset 11766 1.824400 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
1 11767 MAST 0.897837 COMMISSIONED ENGINEERING PLASMA WITH MOST PLAN... dcat:Dataset 1.444762 0.080 Shot Dataset 11767 1.846246 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
2 11768 MAST 0.901121 COMMISSIONED ENGINEERING PLASMA WITH MOST PLAN... dcat:Dataset 1.603340 0.080 Shot Dataset 11768 1.842971 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
3 11769 MAST 0.798088 COMMISSIONED ENGINEERING PLASMA WITH MOST PLAN... dcat:Dataset 1.902339 0.070 Shot Dataset 11769 1.899469 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
4 11771 MAST 0.809877 COMMISSIONED ENGINEERING PLASMA WITH MOST PLAN... dcat:Dataset 2.214325 0.070 Shot Dataset 11771 1.903582 ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
11568 30467 MAST 0.807955 'Data from neutron camera and magnetics obtain... dcat:Dataset 6.996288 0.110 Shot Dataset 30467 1.972266 ... 0.340425 0.000195 2.080261 NaN 2.180491 S6 3.0 NaN NaN NaN
11569 30468 MAST 0.799021 'Data from neutron camera and magnetics obtain... dcat:Dataset 8.578611 0.155 Shot Dataset 30468 1.973768 ... 0.288250 0.000208 2.083544 NaN 1.985447 S8 2.0 NaN NaN NaN
11570 30469 MAST 0.814006 'Data from neutron camera and magnetics obtain... dcat:Dataset 2.681262 0.140 Shot Dataset 30469 1.943575 ... 0.328446 0.000189 2.163367 NaN 2.288206 S6 3.0 NaN NaN NaN
11571 30470 MAST 0.802867 'Data from neutron camera and magnetics obtain... dcat:Dataset 12.264058 0.135 Shot Dataset 30470 1.972500 ... 0.294526 0.000207 2.204641 NaN 2.107413 S8 2.0 NaN NaN NaN
11572 30471 MAST 0.963086 'Data from neutron camera and magnetics obtain... dcat:Dataset 62.251090 0.135 Shot Dataset 30471 1.965805 ... 0.171676 0.000202 2.062899 NaN NaN S8 2.0 NaN NaN NaN

11573 rows × 189 columns

Summary Statistics About Shots#

Let’s look at a summary of simple counts of different shot metadata.

fig, axes = plt.subplots(2, 2, figsize=(10, 5))
ax1, ax2, ax3, ax4 = axes.flatten()

sns.histplot(summary, y='heating', hue='campaign', multiple="stack", ax=ax1)
sns.histplot(summary, y='plasma_shape', hue='campaign', multiple="stack", ax=ax2)
sns.histplot(summary, y='current_range', hue='campaign', multiple="stack", ax=ax3)
sns.histplot(summary, y=summary.pellets.astype(str), hue='campaign', multiple="stack", ax=ax4)

for ax in axes.flatten():
    ax.set_xlabel('No. Shots')

plt.tight_layout()
_images/15371a436e1dcadc40ff8b4c98911a00cecd970115c8f8efc3749533303f3174.png

Plasma Beta (\(\beta\)) v.s Confinement Time (\(\tau_E\))#

This plot can show how the efficiency of energy confinement varies with plasma pressure.

plt.figure()
sns.scatterplot(summary, y='generic_max_energy_time', x='generic_max_beta_max_current', hue='heating')
plt.xlim(0, 18)
plt.ylim(0, 1)
plt.ylabel('Confinement time $\\tau_E$ (s)')
plt.xlabel('Plasma Beta $\\beta$ (%)')
plt.show()
_images/3ed0c5626bcc8b64e873996995c49f842e3b84b4414ba170f8381ebad0d76c08.png

Plasma Temperature (\(T_e\)) vs. Plasma Density (\(n_e\))#

This can reveal the relationship between temperature and density, which is critical for achieving the conditions necessary for fusion.

plt.figure()
sns.scatterplot(summary, y='thomson_temp_max_current', x='thomson_density_max_current', hue='current_range', alpha=0.8)
plt.xlim(0, .8e20)
plt.ylim(0, 1750)
plt.ylabel('Temperature $T_e$ (eV)')
plt.xlabel('Density $n_e$ ($m^{-3}$)')
plt.show()
_images/902dece1d7bd7e0d8c6c520c46c18f85af3f720cd66971b1fed863fa4e487a03.png

Plasma Current (\(I_p\)) vs. Confinement Time (\(\tau_E\))#

This can indicate how the plasma current affects the confinement time, providing insights into stability and performance.

plt.figure()
sns.scatterplot(summary, y='plasma_time_avg_current', x='generic_max_energy_time', hue='current_range', alpha=0.8)
plt.xlim(0, 1)
plt.xlabel('Confinement Time $\\tau_E$ (s)')
plt.ylabel('Average Plasma Current  $I_p$ (kA)')
plt.show()
_images/970232176b429a52ff7b8b633a45fa2994cecebcdc59134023c7d586a336aad7.png