Skip to main content

A unified Python API for fusion reactor data — astropy for fusion.

Project description

🔥 fusiondata

A unified Python API for fusion reactor data — astropy for fusion energy.

Python 3.9+ License: MIT


Fusion science produces incredible data — plasma temperatures of 100 million degrees, magnetic confinement diagnostics, neutron yields — but accessing it is a nightmare. Data is scattered across incompatible archives with confusing formats and poor documentation.

fusiondata fixes that. One pip install, one import, and you have access to the world's public fusion data.

🚀 Quick Start

pip install -e .
from fusiondata import IAEA

# Get the D-T fusion cross-section (works offline!)
iaea = IAEA()
dt = iaea.get_cross_section("DT")
dt.plot()
print(f"Peak: {dt.peak_cross_section:.4g} mb at {dt.peak_energy:.1f} keV")

📡 Supported Sources

Source Device Location Data
W7X Wendelstein 7-X Greifswald, DE Stellarator diagnostics, plasma signals
MAST MAST / MAST-U Culham, UK Spherical tokamak shots & diagnostics
IAEA EXFOR Database Vienna, AT Nuclear reaction cross-sections
LHD Large Helical Device Toki, JP Heliotron diagnostics (AWS S3)
D3D DIII-D San Diego, US MDSplus tokamak data (Auth required)
JET Joint European Torus Culham, UK JPF/PPF tokamak data (Auth required)

📖 Usage Examples

W7-X — Stellarator Data

from fusiondata import W7X

w7x = W7X()

# Browse the data hierarchy
streams = w7x.list_streams()

# List experiment programs for a date
programs = w7x.list_programs("2023-03-15")
for p in programs:
    print(p.id, p.description)

# Get a signal and plot it
signal = w7x.get_signal("ArchiveDB/codac/W7X/.../Scaled", program_id="20230315.003")
signal.plot()                    # Fusion-themed matplotlib plot
df = signal.to_dataframe()      # → pandas DataFrame
print(signal.stats)             # min, max, mean, std, samples

MAST — Tokamak Shots

from fusiondata import MAST

mast = MAST()

# Browse shots
shots = mast.list_shots(shot_min=30000, shot_max=30100)
shot = mast.get_shot(30420)
print(shot.summary)

# Get diagnostic signals
ne = mast.get_signal(30420, "electron_density")
ne.plot()

# Direct S3/Zarr access (requires: pip install fusiondata[full])
ne = mast.get_signal(30420, "electron_density", source="s3")

IAEA — Nuclear Cross-Sections

from fusiondata import IAEA

iaea = IAEA()

# D-T fusion (the big one)
dt = iaea.get_cross_section("DT")
dt.plot()
print(f"Peak cross-section: {dt.peak_cross_section:.4g} mb")
print(f"At energy: {dt.peak_energy:.1f} keV")

# Get cross-section at a specific energy
sigma_100 = dt.at_energy(100)   # σ at 100 keV

# Compare multiple reactions
iaea.plot_comparison(["DT", "DD-p", "DD-n", "D3He"])

# All available reactions
reactions = iaea.list_reactions()

LHD — Helical Device

from fusiondata import LHD

lhd = LHD()

# List available diagnostics
diags = lhd.list_diagnostics(shot_id=160000)

# Get signals
wp = lhd.get_signal(160000, "wp")
wp.plot()

DIII-D — MDSplus Access (Restricted)

Requires an active VPN or SSH connection to the DIII-D network (atlas.gat.com).

from fusiondata import D3D

# Will raise AuthError if you are not authorized/connected
d3d = D3D() 

# Get signal from 'efit01' tree
ip = d3d.get_signal(165920, "ip")
ip.plot()

JET — JDC Authentication (Restricted)

Requires a validated EUROfusion JWT token.

from fusiondata import JET

# Must provide token
jet = JET(token="eyJhbGciOiJIUz...") 

# Get Processed Pulse File (PPF)
ne = jet.get_signal(99971, "LIDR", "NE")
ne.plot()

🛠️ Signal Object

Every signal comes back as a rich Signal object:

signal.values            # numpy array of measurements
signal.timestamps        # numpy array of times
signal.units             # physical units ("eV", "m^-3", etc.)
signal.to_dataframe()    # → pandas DataFrame
signal.plot()            # instant matplotlib plot
signal.stats             # {"min": ..., "max": ..., "mean": ..., "std": ..., "samples": ...}
signal.slice(t0, t1)     # time-slice
signal.resample(1000)    # downsample to N points
signal.duration          # time span
signal.sampling_rate     # Hz

🧪 CrossSection Object

cs.energies              # energy array (keV)
cs.values                # σ array (mb or b)
cs.peak_cross_section    # max σ
cs.peak_energy           # energy at peak
cs.at_energy(100)        # interpolate σ at 100 keV
cs.to_dataframe()        # → pandas DataFrame
cs.plot()                # log-log plot with peak annotation

📦 Installation

# Core (requests, numpy, pandas, matplotlib)
pip install -e .

# Full (adds xarray, s3fs, zarr for direct S3/Zarr access)
pip install -e ".[full]"

# Development
pip install -e ".[dev]"

🎨 Plotting

All .plot() calls use a custom fusion-themed dark style with:

  • Deep navy background
  • Plasma-colored signal traces
  • Auto-scaled axes with physical units
  • Peak annotations for cross-sections
  • Multi-panel experiment overviews
from fusiondata.plotting import plot_experiment_overview

# Multi-panel overview
signals = [signal1, signal2, signal3]
fig = plot_experiment_overview(signals, experiment=shot)

💾 Caching

Responses are cached locally to avoid repeated API calls:

w7x = W7X(cache_enabled=True, cache_ttl=3600)  # 1-hour cache

# Clear cache
w7x.clear_cache()

🌡️ Utilities

from fusiondata.utils import ev_to_kelvin, parse_reaction_string

# Unit conversions
ev_to_kelvin(1.0)           # → 11604.5 K
kev_to_ev(10.0)             # → 10000.0 eV

# Parse reaction strings
parse_reaction_string("D(T,n)4He")
# → {"target": "D", "projectile": "T", "ejectile": "n", "residual": "4He"}

🤝 Contributing

This is an open-source project. Contributions welcome:

  • Add new data sources (DIII-D, EAST, ITER, ...)
  • Improve data format parsers
  • Add more built-in cross-section parametrizations
  • Write tutorials and examples

📄 License

MIT License — use it, fork it, build on it.


Because fusion data should be as easy to access as star catalogs.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fusiondata-0.1.1.tar.gz (33.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fusiondata-0.1.1-py3-none-any.whl (38.2 kB view details)

Uploaded Python 3

File details

Details for the file fusiondata-0.1.1.tar.gz.

File metadata

  • Download URL: fusiondata-0.1.1.tar.gz
  • Upload date:
  • Size: 33.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fusiondata-0.1.1.tar.gz
Algorithm Hash digest
SHA256 5f029cce74fdb5e49af80ed4eba0115e843b9cc1526763d1bd1e72bb43340684
MD5 026f165e246ed673981650237b677e27
BLAKE2b-256 495f384babd19be33d9caa4d73d2fbfae855c35d4fd63204e53ef556023ca0dd

See more details on using hashes here.

Provenance

The following attestation bundles were made for fusiondata-0.1.1.tar.gz:

Publisher: publish.yml on KhalidFaisal/fusiondata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fusiondata-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: fusiondata-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 38.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for fusiondata-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 581771f1334dc4b30a539d2a545cccbd3da66f91e7511b9f3b550864b850d6b9
MD5 91fd3e6497bd4f0b685b59cf0dda318c
BLAKE2b-256 446461f5229c849a11c737a374c6e0f61083b7ef40dc27d458e7b79539bab5a7

See more details on using hashes here.

Provenance

The following attestation bundles were made for fusiondata-0.1.1-py3-none-any.whl:

Publisher: publish.yml on KhalidFaisal/fusiondata

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page