!pip install aiohttp matplotlib pandas pyarrow "xarray[io]"

Hide code cell output

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: aiohttp in /home/runner/.local/lib/python3.12/site-packages (3.14.5)
Requirement already satisfied: matplotlib in /home/runner/.local/lib/python3.12/site-packages (3.11.2)
Requirement already satisfied: pandas in /home/runner/.local/lib/python3.12/site-packages (3.1.0)
Requirement already satisfied: pyarrow in /home/runner/.local/lib/python3.12/site-packages (26.0.0)
Requirement already satisfied: xarray[io] in /home/runner/.local/lib/python3.12/site-packages (2026.9.0)
Requirement already satisfied: aiohappyeyeballs>=2.5.0 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (2.7.1)
Requirement already satisfied: aiosignal>=1.4.0 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (1.4.0)
Requirement already satisfied: attrs>=17.3.0 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (26.1.0)
Requirement already satisfied: frozenlist>=1.1.1 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (1.8.0)
Requirement already satisfied: multidict<8.0,>=4.5 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (7.2.1)
Requirement already satisfied: propcache>=0.2.0 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (0.5.4)
Requirement already satisfied: typing_extensions>=4.4 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (4.16.0)
Requirement already satisfied: yarl<2.0,>=1.25.1 in /home/runner/.local/lib/python3.12/site-packages (from aiohttp) (1.25.1)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.25.1->aiohttp) (3.6)
Requirement already satisfied: contourpy>=1.0.1 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (1.4.0)
Requirement already satisfied: cycler>=0.10 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (0.12.1)
Requirement already satisfied: fonttools>=4.28.2 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (4.67.0)
Requirement already satisfied: kiwisolver>=1.3.1 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (1.5.1)
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)
Requirement already satisfied: pillow>=9 in /home/runner/.local/lib/python3.12/site-packages (from matplotlib) (13.0.0)
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) (2.9.0.post0)
Requirement already satisfied: netCDF4>=1.6.0 in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (1.7.5.1.post1)
Requirement already satisfied: h5netcdf>=1.8.0 in /home/runner/.local/lib/python3.12/site-packages (from h5netcdf[h5py]>=1.8.0; extra == "io"->xarray[io]) (1.8.1)
Requirement already satisfied: pydap in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (3.5.11)
Requirement already satisfied: scipy>=1.15 in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (1.18.1)
Requirement already satisfied: zarr>=3.0 in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (3.4.1)
Requirement already satisfied: fsspec in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (2026.9.0)
Requirement already satisfied: cftime in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (1.6.6.1)
Requirement already satisfied: pooch in /home/runner/.local/lib/python3.12/site-packages (from xarray[io]) (1.9.0)
Requirement already satisfied: h5py in /home/runner/.local/lib/python3.12/site-packages (from h5netcdf[h5py]>=1.8.0; extra == "io"->xarray[io]) (3.16.0)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from netCDF4>=1.6.0->xarray[io]) (2023.11.17)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Requirement already satisfied: donfig>=0.8 in /home/runner/.local/lib/python3.12/site-packages (from zarr>=3.0->xarray[io]) (0.8.1.post1)
Requirement already satisfied: google-crc32c>=1.5 in /home/runner/.local/lib/python3.12/site-packages (from zarr>=3.0->xarray[io]) (1.9.0)
Requirement already satisfied: msgspec>=0.19 in /home/runner/.local/lib/python3.12/site-packages (from zarr>=3.0->xarray[io]) (0.22.0)
Requirement already satisfied: numcodecs>=0.16 in /home/runner/.local/lib/python3.12/site-packages (from zarr>=3.0->xarray[io]) (0.17.1)
Requirement already satisfied: pyyaml in /usr/lib/python3/dist-packages (from donfig>=0.8->zarr>=3.0->xarray[io]) (6.0.1)
Requirement already satisfied: platformdirs>=2.5.0 in /usr/local/lib/python3.12/dist-packages (from pooch->xarray[io]) (4.13.0)
Requirement already satisfied: requests>=2.19.0 in /usr/lib/python3/dist-packages (from pooch->xarray[io]) (2.31.0)
Requirement already satisfied: requests-cache in /home/runner/.local/lib/python3.12/site-packages (from pydap->xarray[io]) (1.3.3)
Requirement already satisfied: webob>=1.8.10 in /home/runner/.local/lib/python3.12/site-packages (from pydap->xarray[io]) (1.8.11)
Requirement already satisfied: beautifulsoup4 in /home/runner/.local/lib/python3.12/site-packages (from pydap->xarray[io]) (4.15.0)
Requirement already satisfied: lxml in /home/runner/.local/lib/python3.12/site-packages (from pydap->xarray[io]) (6.1.3)
Requirement already satisfied: Jinja2 in /usr/lib/python3/dist-packages (from pydap->xarray[io]) (3.1.2)
Requirement already satisfied: soupsieve>=1.6.1 in /home/runner/.local/lib/python3.12/site-packages (from beautifulsoup4->pydap->xarray[io]) (3.0.4)
Requirement already satisfied: cattrs>=22.2 in /home/runner/.local/lib/python3.12/site-packages (from requests-cache->pydap->xarray[io]) (26.2.1)
Requirement already satisfied: url-normalize>=2.0 in /home/runner/.local/lib/python3.12/site-packages (from requests-cache->pydap->xarray[io]) (3.0.1)
Requirement already satisfied: urllib3>=1.25.5 in /usr/lib/python3/dist-packages (from requests-cache->pydap->xarray[io]) (2.0.7)
import pandas as pd
META_URL = "https://s3.echo.stfc.ac.uk/mast/fairmast-meta"

Quickstart#

This notebook shows some very simple examples of getting started.

Metadata for every shot, source and signal is stored as Parquet files in the public S3 bucket under s3://mast/fairmast-meta/, which can be read over HTTPS at https://s3.echo.stfc.ac.uk/mast/fairmast-meta/:

File

Contents

l1_shots.parquet, l2_shots.parquet

One row per shot: shot metadata and CPF summary statistics

l1_sources.parquet, l2_sources.parquet

One row per source (group of signals) per shot

l1_signals/signals_<shot_id>.parquet, l2_signals/signals_<shot_id>.parquet

One row per signal for a single shot

The l1_ files describe the level 1 data and the l2_ files describe the level 2 data.

List All Shots#

shots_df = pd.read_parquet(f"{META_URL}/l2_shots.parquet")
shots_df
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

Filter Shots#

The metadata are ordinary pandas DataFrames, so you can filter them and select columns with pandas. For example, to get a few columns for every shot in the M9 campaign:

m9_shots = shots_df[shots_df.campaign == "M9"]
m9_shots[["shot_id", "timestamp", "preshot_description", "divertor_config"]]
shot_id timestamp preshot_description divertor_config
9164 28752 2013-05-20 13:30:00 \nChange ZREF to +1cm.\n Conventional
9173 28647 2013-04-18 12:37:00 \nRepeat after abort.\n Conventional
10154 28750 2013-05-20 12:57:00 \nChange zref to -1 cm\n Conventional
10475 28631 2013-04-17 14:54:00 \nRepeat, with loop volts tweak and +-25kA P1P... Conventional
10476 28632 2013-04-17 15:19:00 \nRepeat, with -ve P1PS current limit 45kA. Tw... Conventional
... ... ... ... ...
11568 30467 2013-09-27 14:03:00 \nRepeat with new neutron camera position.\ncH... Conventional
11569 30468 2013-09-27 14:21:00 \nRepeat with new neutron camera position.\ncH... Conventional
11570 30469 2013-09-27 14:39:00 \nRepeat with increased beam power (74 kV)\ncH... Conventional
11571 30470 2013-09-27 15:03:00 \nRepeat last using hydrogen in outboard and c... Conventional
11572 30471 2013-09-27 15:20:00 \nThe last plasma:\nConvert to i/b Helios 1724... Conventional

1101 rows × 4 columns

List All Sources#

sources_df = pd.read_parquet(f"{META_URL}/l2_sources.parquet")
sources_df
shot_id type_ description title name endpoint_url context_ quality uuid url imas
0 14399 dcat:Dataset Source Dataset gas_injection https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked f39ee009-4405-59ea-9672-443de2c051bd s3://mast/level2/shots/14399.zarr gas_injection
1 14399 dcat:Dataset Source Dataset magnetics https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked 6eeee9b5-9803-57c7-9c8d-8d6f249b5983 s3://mast/level2/shots/14399.zarr magnetics
2 14399 dcat:Dataset Source Dataset pf_active https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked c8fdcd7b-f882-5ac5-8dee-e5736f9abdec s3://mast/level2/shots/14399.zarr pf_active
3 14399 dcat:Dataset Source Dataset pulse_schedule https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked bbd4f35f-bdf7-549d-93d0-7063b029a2e1 s3://mast/level2/shots/14399.zarr pulse_schedule
4 14399 dcat:Dataset Source Dataset soft_x_rays https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked 82f89e7e-1eb6-516c-a8fb-39aee47fd2bf s3://mast/level2/shots/14399.zarr NaN
... ... ... ... ... ... ... ... ... ... ... ...
105993 14398 dcat:Dataset Source Dataset soft_x_rays https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked 5af5a37d-d8fa-5a3c-a2a9-d32d4ac55538 s3://mast/level2/shots/14398.zarr NaN
105994 14398 dcat:Dataset Source Dataset spectrometer_visible https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked 7aa3b4b0-33e6-5bdf-9e1b-a43dd8587152 s3://mast/level2/shots/14398.zarr NaN
105995 14398 dcat:Dataset Source Dataset summary https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked a86b4d7d-55dd-528b-aa19-f77ddb8e06f3 s3://mast/level2/shots/14398.zarr summary
105996 14398 dcat:Dataset Source Dataset thomson_scattering https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked 8cf090c4-6c4b-59bd-a8cb-8e09a06992f4 s3://mast/level2/shots/14398.zarr thomson_scattering
105997 14399 dcat:Dataset Source Dataset equilibrium https://s3.echo.stfc.ac.uk {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... Not Checked 1031f2e4-8fbe-5e6e-863c-7b5bfd72c424 s3://mast/level2/shots/14399.zarr equilibrium

105998 rows × 11 columns

List all signals Given a Shot Number#

signals_df = pd.read_parquet(f"{META_URL}/l2_signals/signals_30421.parquet")
signals_df
shot_id description rank dimensions url quality endpoint_url type_ source title units shape uuid imas context_ name version
0 30421 2 [time, major_radius] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset charge_exchange Signal Dataset eV [73, 160] 75756c34-c5b1-5e75-a53e-82bd90635d75 charge_exchange {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... t_i 0
1 30421 2 [time, major_radius] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset charge_exchange Signal Dataset eV [73, 160] dcb14130-bf6a-5cc3-90ff-3985dad388a7 charge_exchange {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... v_i 0
2 30421 1 [time] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset equilibrium Signal Dataset [146] eb848f08-2f4e-54a6-8bd5-98a98823aa2e equilibrium {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... beta_normal 0
3 30421 1 [time] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset equilibrium Signal Dataset [146] cb95202b-279e-524a-b6af-899729ca9298 equilibrium {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... beta_pol 0
4 30421 1 [time] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset equilibrium Signal Dataset [146] fd1ec81b-5eb9-5a59-b507-8b2df648e0ad equilibrium {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... beta_tor 0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
68 30421 2 [time, major_radius] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset thomson_scattering Signal Dataset eV [146, 120] f0b586cd-11ea-5208-927b-4e4f057a6c44 thomson_scattering {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... n_e 0
69 30421 1 [time] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset thomson_scattering Signal Dataset eV [146] 097cfe72-4d53-5a04-a7dc-97b1898e6e98 thomson_scattering {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... n_e_core 0
70 30421 2 [time, major_radius] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset thomson_scattering Signal Dataset eV [146, 120] 23c0ad57-6ff8-5222-9a7a-c897b661b9ad thomson_scattering {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... p_e 0
71 30421 2 [time, major_radius] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset thomson_scattering Signal Dataset eV [146, 120] 6e2f4faf-7eb6-5f9e-a8a3-f0869af4abbf thomson_scattering {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... t_e 0
72 30421 1 [time] s3://mast/level2/shots/30421.zarr Not Checked https://s3.echo.stfc.ac.uk dcat:Dataset thomson_scattering Signal Dataset eV [146] c83667d9-fd83-5808-90b9-bb6750e98b77 thomson_scattering {'dct': 'http://purl.org/dc/terms/', 'dqv': 'h... t_e_core 0

73 rows × 17 columns

Open and plot shot data.#

Here we are visualising some plasma current data.

import xarray as xr
import matplotlib.pyplot as plt


dataset = xr.open_zarr(
    "https://s3.echo.stfc.ac.uk/mast/level2/shots/30421.zarr",
    group='summary'
)

dataset['ip'].plot()
plt.show()
_images/d0dc76e6733a7a6f306e731ec8113ccd43df6b94f4369c5006f99997e2a20847.png