Edge Plasma profiles¶
This notebook demonstrates how to load and visualize edge plasma profiles using the cherab.imas interface. Here, we propose how to visualize edge plasmas with grid meshes defined in the IMAS data structure.
The example test data was calculated by JINTRAC for an ITER 15 MA H-mode scenario.
Prerequisites: Pooch must be installed to download the example data.
[1]:
import numpy as np
import ultraplot as uplt
from imas import DBEntry
from matplotlib.colors import SymLogNorm
from rich import print as rprint
from cherab.imas.datasets import iter_jintrac
from cherab.imas.ggd import GGDGrid
from cherab.imas.ids.common import get_ids_time_slice
from cherab.imas.ids.common.ggd import load_grid
from cherab.imas.ids.edge_profiles import load_edge_species
# Set dark background for plots
uplt.rc.style = "dark_background"
13:46:35 CRITICAL Could not import 'imas_core': No module named 'imas_core'. Some functionality is not available. @imas_interface.py:34
Define a function to plot edge plasma profiles¶
[2]:
def plot_grid_quantity(
ax: uplt.axes.Axes,
grid: GGDGrid,
quantity: np.ndarray,
title: str = "",
title_center: str = "",
clabel: str = "",
logscale: bool = False,
symmetric: bool = False,
cbar_kwargs: dict = None,
) -> uplt.axes.Axes:
"""Plot a quantity defined on a grid."""
ax = grid.plot_mesh(data=quantity, ax=ax)
if logscale:
# Plot lowest values (mainly 0's) on linear map, as log(0) = -inf.
linthresh = np.percentile(np.unique(quantity), 1)
norm = SymLogNorm(
linthresh=float(max(linthresh, 1.0e-10 * quantity.max())),
base=10,
)
ax.collections[0].set_norm(norm)
if symmetric:
vmax = np.abs(quantity.max())
ax.collections[0].set_clim(-vmax, vmax)
ax.collections[0].set_cmap("berlin")
else:
ax.collections[0].set_cmap("gnuplot")
ax.colorbar(
ax.collections[0],
formatter="log" if logscale else None,
tickminor=True,
**(cbar_kwargs or {}),
)
if title_center:
ax.text(
0.5,
0.55,
title_center,
transform=ax.transAxes,
ha="center",
va="center",
fontsize=14,
)
ax.format(
aspect="equal",
xlabel="$R$ [m]",
ylabel="$Z$ [m]",
xlocator=1,
ylocator=1,
title=title,
)
return ax
Retrieve ITER JINTRAC sample data¶
[3]:
path = iter_jintrac()
Downloading file 'iter_scenario_53298_seq1_DD4.nc' from 'doi:10.5281/zenodo.17062699/iter_scenario_53298_seq1_DD4.nc' to '/home/runner/.cache/cherab/imas'.
13:46:53 INFO Parsing data dictionary version 4.1.1 @dd_zip.py:89
=== Apply patch to fix ===
13:46:53 INFO Parsing data dictionary version 4.0.0 @dd_zip.py:89
/home/runner/work/imas/imas/src/cherab/imas/datasets/_patch.py:46: RuntimeWarning: The 'get_slice' method is not implemented for the URI '/home/runner/.cache/cherab/imas/iter_scenario_53298_seq1_DD4.nc'. Falling back to 'get' method to retrieve the entire IDS.
ids_core = get_ids_time_slice(entry, "core_profiles", 0.0)
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:57 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
13:46:58 INFO Multiple alternative coordinates are set, using the first @ids_coordinates.py:238
Load grid and species data¶
Select grid subset¶
In “edge_profiles” IDS, there are multiple grid subsets defined. Here, we choose the "cells" subset to visualize the edge plasma profiles.
[4]:
# Load edge_profiles IDs
with DBEntry(path, "r") as entry:
ids = get_ids_time_slice(
entry,
"edge_profiles",
time=0,
)
# Load grid object
grid, subsets, subset_id = load_grid(
ids.grid_ggd[0],
with_subsets=True,
)
# Print available grid subsets
rprint("Available grid subsets:", subset_id)
# Extract only "cells" subset
grid = grid.subset(subsets["cells"])
/tmp/ipykernel_3219/3942360383.py:3: RuntimeWarning: The 'get_slice' method is not implemented for the URI '/home/runner/.cache/cherab/imas/iter_scenario_53298_seq1_DD4_mod.nc'. Falling back to 'get' method to retrieve the entire IDS.
ids = get_ids_time_slice(
Warning! Unable to verify that the cell nodes are in the winding order.
Available grid subsets: { 'cells': np.int32(5), 'core': np.int32(22), 'sol': np.int32(23), 'inner_divertor': np.int32(25), 'outer_divertor': np.int32(24) }
Load edge species data¶
[5]:
composition = load_edge_species(
ids.ggd[0],
grid_subset_index=subset_id["cells"],
split_ion_bundles=False,
)
Warning! Using average ion temperature for the D ion (z=+1).
Warning! Using average ion temperature for the He ion (z=+1).
Warning! Using average ion temperature for the He ion (z=+2).
Warning! Using average ion temperature for the Ne ion (z=+1).
Warning! Using average ion temperature for the Ne ion (z=+10).
Warning! Using average ion temperature for the W ion (z=+1).
Warning! Using average ion temperature for the W ion (z=+74).
Warning! Using average ion temperature for the Ne ion_bundle (z=2-3).
Warning! Using average ion temperature for the Ne ion_bundle (z=4-6).
Warning! Using average ion temperature for the Ne ion_bundle (z=7-9).
Warning! Using average ion temperature for the W ion_bundle (z=2-6).
Warning! Using average ion temperature for the W ion_bundle (z=7-12).
Warning! Using average ion temperature for the W ion_bundle (z=13-22).
Warning! Using average ion temperature for the W ion_bundle (z=23-73).
Plot edge plasma profiles¶
Grid mesh¶
[6]:
fig, ax = uplt.subplots()
ax = grid.plot_mesh(ax=ax)
Electron profiles¶
[7]:
# Electron density
fig, ax = uplt.subplots()
ax = plot_grid_quantity(
ax,
grid,
composition.electron.density,
title_center="Electron density\n$n_\\mathrm{e}$ [m$^{-3}$]",
logscale=True,
)
# Electron temperature
fig, ax = uplt.subplots()
ax = plot_grid_quantity(
ax,
grid,
composition.electron.temperature,
title_center="Electron temperature\n$T_\\mathrm{e}$ [eV]",
logscale=True,
)
Species profiles¶
[8]:
# Store all data to plot in a list
data: list[tuple[np.ndarray, dict]] = []
for profile in composition.ion + composition.neutral + composition.molecule:
charge = profile.species.z_min
element = profile.species.element or profile.species.elements[0]
if charge == 0:
name = element.symbol
elif charge == 1:
name = f"{element.symbol}$^+$"
else:
name = f"{element.symbol}$^{{{charge}+}}$"
# Density
data.append(
(
profile.density,
dict(
title_center=f"{name} density [m$^{{-3}}$]",
logscale=True,
),
)
)
if element.atomic_number == 1:
# Temperature
if profile.temperature is not None and np.any(profile.temperature):
data.append(
(
profile.temperature,
dict(
title_center=f"{name} temperature [eV]",
logscale=True,
),
)
)
if charge:
# Velocity profiles
vpar = profile.velocity.parallel
if vpar is not None and np.any(vpar):
data.append(
(
vpar,
dict(
title_center=f"{name} parallel velocity [m/s]",
symmetric=True,
),
)
)
else:
for vtype in {"radial", "poloidal", "phi"}:
velocity = getattr(profile.velocity, vtype)
if velocity is not None and np.any(velocity):
data.append(
(
velocity,
dict(
title_center=f"{name} {vtype} velocity [m/s]",
symmetric=True,
),
)
)
# Plot all data
fig, axes = uplt.subplots(
ncols=3,
nrows=int(np.ceil(len(data) / 3)),
)
for i_ax, (quantity, kwargs) in enumerate(data):
ax = plot_grid_quantity(
axes[i_ax],
grid,
quantity,
**kwargs,
cbar_kwargs=dict(
loc="lr",
orientation="vertical",
ticklabelsize="small",
length=5,
frame=False,
),
)
axes.format(
xlabel="",
ylabel="",
xtickloc="neither",
ytickloc="neither",
linestyle="none",
)
Split the bundled species profiles¶
Some code suites (e.g., JINTRAC) bundle multiple charges of a species, where the total density of the specific range of charge states is stored and each density of the charge states within its range satisfies the coronal equilibrium condition.
Here, we demonstrate how to split the bundled species profiles into each charge state using the solve_coronal_equilibrium function.
[9]:
from cherab.core.atomic.elements import neon
from cherab.imas.ids.common import solve_coronal_equilibrium
# Select one neon ion bundle
bundle = composition.ion_bundle[2]
# Solve coronal equilibrium
densities = solve_coronal_equilibrium(
neon,
bundle.density,
composition.electron.density,
composition.electron.temperature,
z_min=bundle.species.z_min,
z_max=bundle.species.z_max,
)
# Plot the split charge states
fig, axes = uplt.subplots(
ncols=3,
nrows=int(np.ceil(densities.shape[0] / 3)),
)
for i_ax, charge in enumerate(
np.arange(bundle.species.z_min, bundle.species.z_max + 1, dtype=int),
):
ax = plot_grid_quantity(
axes[i_ax],
grid,
densities[i_ax, :],
title_center=f"{neon.symbol}$^{{{charge}+}}$ density [m$^{{-3}}$]",
logscale=True,
cbar_kwargs=dict(
loc="lr",
orientation="vertical",
ticklabelsize="small",
length=5,
frame=False,
),
)
axes.format(
xlabel="",
ylabel="",
xtickloc="neither",
ytickloc="neither",
linestyle="none",
)