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

Hide code cell output

Requirement already satisfied: aiohttp in /home/deploy/.local/lib/python3.8/site-packages (3.10.11)
Requirement already satisfied: matplotlib in /usr/lib/python3/dist-packages (3.1.2)
Requirement already satisfied: pandas in /home/deploy/.local/lib/python3.8/site-packages (2.0.3)
Requirement already satisfied: pyarrow in /home/deploy/.local/lib/python3.8/site-packages (17.0.0)
Requirement already satisfied: requests in /usr/lib/python3/dist-packages (2.22.0)
Requirement already satisfied: xarray[io] in /home/deploy/.local/lib/python3.8/site-packages (2023.1.0)
Requirement already satisfied: aiosignal>=1.1.2 in /home/deploy/.local/lib/python3.8/site-packages (from aiohttp) (1.3.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /home/deploy/.local/lib/python3.8/site-packages (from aiohttp) (6.1.0)
Requirement already satisfied: async-timeout<6.0,>=4.0; python_version < "3.11" in /home/deploy/.local/lib/python3.8/site-packages (from aiohttp) (5.0.1)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp) (19.3.0)
Requirement already satisfied: aiohappyeyeballs>=2.3.0 in /home/deploy/.local/lib/python3.8/site-packages (from aiohttp) (2.4.4)
Requirement already satisfied: frozenlist>=1.1.1 in /home/deploy/.local/lib/python3.8/site-packages (from aiohttp) (1.5.0)
Requirement already satisfied: yarl<2.0,>=1.12.0 in /home/deploy/.local/lib/python3.8/site-packages (from aiohttp) (1.15.2)
Requirement already satisfied: tzdata>=2022.1 in /home/deploy/.local/lib/python3.8/site-packages (from pandas) (2025.2)
Requirement already satisfied: numpy>=1.20.3; python_version < "3.10" in /home/deploy/.local/lib/python3.8/site-packages (from pandas) (1.24.4)
Requirement already satisfied: python-dateutil>=2.8.2 in /home/deploy/.local/lib/python3.8/site-packages (from pandas) (2.9.0.post0)
Requirement already satisfied: pytz>=2020.1 in /home/deploy/.local/lib/python3.8/site-packages (from pandas) (2025.2)
Requirement already satisfied: packaging>=21.3 in /usr/local/lib/python3.8/dist-packages (from xarray[io]) (24.1)
Requirement already satisfied: cfgrib; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (0.9.15.0)
Requirement already satisfied: pooch; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (1.8.2)
Requirement already satisfied: h5netcdf; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (1.1.0)
Requirement already satisfied: pydap; python_version < "3.10" and extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (3.4.1)
Requirement already satisfied: rasterio; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (1.3.11)
Requirement already satisfied: netCDF4; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (1.7.2)
Requirement already satisfied: zarr; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (2.16.1)
Requirement already satisfied: fsspec; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (2024.10.0)
Requirement already satisfied: scipy; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (1.10.1)
Requirement already satisfied: cftime; extra == "io" in /home/deploy/.local/lib/python3.8/site-packages (from xarray[io]) (1.6.4.post1)
Requirement already satisfied: typing-extensions>=4.1.0; python_version < "3.11" in /home/deploy/.local/lib/python3.8/site-packages (from multidict<7.0,>=4.5->aiohttp) (4.13.2)
Requirement already satisfied: propcache>=0.2.0 in /home/deploy/.local/lib/python3.8/site-packages (from yarl<2.0,>=1.12.0->aiohttp) (0.2.0)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.12.0->aiohttp) (2.8)
Requirement already satisfied: six>=1.5 in /usr/lib/python3/dist-packages (from python-dateutil>=2.8.2->pandas) (1.14.0)
Requirement already satisfied: eccodes>=0.9.8 in /home/deploy/.local/lib/python3.8/site-packages (from cfgrib; extra == "io"->xarray[io]) (2.42.0)
Requirement already satisfied: click in /usr/lib/python3/dist-packages (from cfgrib; extra == "io"->xarray[io]) (7.0)
Requirement already satisfied: platformdirs>=2.5.0 in /home/deploy/.local/lib/python3.8/site-packages (from pooch; extra == "io"->xarray[io]) (4.3.6)
Requirement already satisfied: h5py in /home/deploy/.local/lib/python3.8/site-packages (from h5netcdf; extra == "io"->xarray[io]) (3.11.0)
Requirement already satisfied: Jinja2 in /usr/local/lib/python3.8/dist-packages (from pydap; python_version < "3.10" and extra == "io"->xarray[io]) (3.1.4)
Requirement already satisfied: Webob in /home/deploy/.local/lib/python3.8/site-packages (from pydap; python_version < "3.10" and extra == "io"->xarray[io]) (1.8.9)
Requirement already satisfied: docopt in /usr/lib/python3/dist-packages (from pydap; python_version < "3.10" and extra == "io"->xarray[io]) (0.6.2)
Requirement already satisfied: beautifulsoup4 in /home/deploy/.local/lib/python3.8/site-packages (from pydap; python_version < "3.10" and extra == "io"->xarray[io]) (4.13.4)
Requirement already satisfied: certifi in /usr/lib/python3/dist-packages (from rasterio; extra == "io"->xarray[io]) (2019.11.28)
Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from rasterio; extra == "io"->xarray[io]) (45.2.0)
Requirement already satisfied: cligj>=0.5 in /home/deploy/.local/lib/python3.8/site-packages (from rasterio; extra == "io"->xarray[io]) (0.7.2)
Requirement already satisfied: click-plugins in /home/deploy/.local/lib/python3.8/site-packages (from rasterio; extra == "io"->xarray[io]) (1.1.1.2)
Requirement already satisfied: importlib-metadata; python_version < "3.10" in /usr/lib/python3/dist-packages (from rasterio; extra == "io"->xarray[io]) (1.5.0)
Requirement already satisfied: affine in /home/deploy/.local/lib/python3.8/site-packages (from rasterio; extra == "io"->xarray[io]) (2.4.0)
Requirement already satisfied: snuggs>=1.4.1 in /home/deploy/.local/lib/python3.8/site-packages (from rasterio; extra == "io"->xarray[io]) (1.4.7)
Requirement already satisfied: asciitree in /home/deploy/.local/lib/python3.8/site-packages (from zarr; extra == "io"->xarray[io]) (0.3.3)
Requirement already satisfied: fasteners in /home/deploy/.local/lib/python3.8/site-packages (from zarr; extra == "io"->xarray[io]) (0.19)
Requirement already satisfied: numcodecs>=0.10.0 in /home/deploy/.local/lib/python3.8/site-packages (from zarr; extra == "io"->xarray[io]) (0.12.1)
Requirement already satisfied: cffi in /home/deploy/.local/lib/python3.8/site-packages (from eccodes>=0.9.8->cfgrib; extra == "io"->xarray[io]) (1.17.1)
Requirement already satisfied: findlibs in /home/deploy/.local/lib/python3.8/site-packages (from eccodes>=0.9.8->cfgrib; extra == "io"->xarray[io]) (0.1.1)
Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.8/dist-packages (from Jinja2->pydap; python_version < "3.10" and extra == "io"->xarray[io]) (2.1.5)
Requirement already satisfied: soupsieve>1.2 in /home/deploy/.local/lib/python3.8/site-packages (from beautifulsoup4->pydap; python_version < "3.10" and extra == "io"->xarray[io]) (2.7)
Requirement already satisfied: pyparsing>=2.1.6 in /usr/lib/python3/dist-packages (from snuggs>=1.4.1->rasterio; extra == "io"->xarray[io]) (2.4.6)
Requirement already satisfied: pycparser in /home/deploy/.local/lib/python3.8/site-packages (from cffi->eccodes>=0.9.8->cfgrib; extra == "io"->xarray[io]) (2.22)
import pandas as pd
URL = 'https://mastapp.site'

Quickstart#

This notebook shows some very simple example of getting started.

List All Shots#

shots_df = pd.read_parquet(f'{URL}/parquet/level2/shots')
shots_df
shot_id campaign ohmnic_energy_total radii_s_area_max_current equi_max_li3_time generic_dt_energy_max_current generic_s_area_max divertor_config generic_dt_total_energy generic_plasma_elongation_max_current ... nbi_energy_ss_max_current nbi_total_injected_energy_ss nbi_injected_energy_ss_ruby_time nbi_power_ss_max_current nbi_power_truby_ss shot_scenario scenario rad_o2ratio radii_c2ratio shot_flat_top_duration
0 11766 M5 0.114530 22.644779 0.270 -192676.851518 23.362010 Conventional 430281.62 1.601573 ... NaN NaN NaN NaN NaN None NaN NaN NaN NaN
1 11767 M5 0.134566 22.002382 0.150 -82970.042801 23.469263 Conventional 254662.14 1.594044 ... NaN NaN NaN NaN NaN None NaN NaN NaN NaN
2 11768 M5 0.129432 23.027416 0.270 -113603.034418 23.507900 Conventional 401462.44 1.612653 ... NaN NaN NaN NaN NaN None NaN NaN NaN NaN
3 11769 M5 0.156508 22.759919 0.290 -127591.593586 23.938997 Conventional 283884.00 1.673236 ... NaN NaN NaN NaN NaN None NaN NaN NaN NaN
4 11771 M5 0.131940 22.525058 0.290 -164363.251971 23.959898 Conventional 309404.78 1.655904 ... NaN NaN NaN NaN NaN None NaN NaN NaN NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
11568 30467 M9 0.094553 25.402852 0.030 31972.688440 25.416924 Conventional 2307703.20 1.930563 ... 0.137379 0.340425 0.000195 2.180491 NaN S6 3.0 NaN NaN NaN
11569 30468 M9 0.095056 25.509430 0.030 -146041.829662 25.541964 Conventional 2943505.20 1.938207 ... 0.155259 0.288250 0.000208 1.985447 NaN S8 2.0 NaN NaN NaN
11570 30469 M9 0.074943 25.318623 0.035 133309.409983 25.418210 Conventional 840205.30 1.933172 ... 0.293718 0.328446 0.000189 2.288206 NaN S6 3.0 NaN NaN NaN
11571 30470 M9 0.236737 27.009387 0.035 -501857.330985 28.405008 Conventional 4641571.50 1.924374 ... 0.274879 0.294526 0.000207 2.107413 NaN S8 2.0 NaN NaN NaN
11572 30471 M9 0.372848 24.728233 0.035 -506018.886237 25.858627 Conventional 25309066.00 1.882437 ... 0.136419 0.171676 0.000202 NaN NaN S8 2.0 NaN NaN NaN

11573 rows × 189 columns

List All Sources#

sources_df = pd.read_parquet(f"{URL}/parquet/level2/sources")
sources_df
shot_id context_ quality title name endpoint_url type_ description uuid url imas
0 11766 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset equilibrium https://s3.echo.stfc.ac.uk dcat:Dataset 0f3fbb3a-8915-593b-8a5e-bb2801bd5b6d s3://mast/level2/shots/11766.zarr equilibrium
1 11766 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset gas_injection https://s3.echo.stfc.ac.uk dcat:Dataset 21df071f-d08f-540c-8f39-a799dc34535c s3://mast/level2/shots/11766.zarr gas_injection
2 11766 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset magnetics https://s3.echo.stfc.ac.uk dcat:Dataset c97c0e5c-c26c-52af-9b37-f6660d08726d s3://mast/level2/shots/11766.zarr magnetics
3 11766 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset pf_active https://s3.echo.stfc.ac.uk dcat:Dataset ba47b2a2-a6da-5d8e-b6c2-e093fbfc3553 s3://mast/level2/shots/11766.zarr pf_active
4 11766 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset pulse_schedule https://s3.echo.stfc.ac.uk dcat:Dataset 46662499-0e12-5e7a-a8b8-ec44cdfca24d s3://mast/level2/shots/11766.zarr pulse_schedule
... ... ... ... ... ... ... ... ... ... ... ...
105993 30471 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset gas_injection https://s3.echo.stfc.ac.uk dcat:Dataset 9d2c7bbd-8592-5e3b-a358-921879f34bd4 s3://mast/level2/shots/30471.zarr gas_injection
105994 30471 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset magnetics https://s3.echo.stfc.ac.uk dcat:Dataset 7118a52b-91bc-5575-ae9d-388552642b72 s3://mast/level2/shots/30471.zarr magnetics
105995 30471 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset pf_active https://s3.echo.stfc.ac.uk dcat:Dataset 8a94267d-3c38-516b-83ee-27ba71348716 s3://mast/level2/shots/30471.zarr pf_active
105996 30471 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset spectrometer_visible https://s3.echo.stfc.ac.uk dcat:Dataset 7d455235-58fb-5918-9d04-0653d4972b89 s3://mast/level2/shots/30471.zarr None
105997 30471 {'dcat': 'http://www.w3.org/ns/dcat#', 'dct': ... Not Checked Source Dataset summary https://s3.echo.stfc.ac.uk dcat:Dataset 5da1f1a6-c70f-5ad6-97c4-8e3b1f91da04 s3://mast/level2/shots/30471.zarr summary

105998 rows × 11 columns

List all signals Given a Shot Number#

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

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/ac8260d392885693b3cc46ec6563cfb639e07d167644a44616bc163e592fe79d.png