IMAS Module#

Core Profiles IDS#

class cherab.imas.core_profiles.CoreProfilesIDS(shot, run, user='public', database='iterdb')#

Read and process core_profiles IDS.

Parameters:
  • shot (int) – IMAS database shot ID.

  • run (int) – IMAS database run ID.

  • user (str, optional) – IMAS user ID, by default “public”

  • database (str, optional) – IMAS database ID, by default “iterdb”

create_plasma(equilibrium, psi_1d=None, parent=None, transform=None, name='Core Plasma')#

Make a CHERAB plasma object from this core_profiles IDS.

Parameters:
  • equilibrium (EFITEquilibrium) – Equilibrium object.

  • psi_1d (numpy.ndarray, optional) – 1D Psi profile, by default None

  • parent (Node, optional) – The plasma’s parent node in the scenegraph, e.g. a World object, by default None

  • transform (AffineMatrix3D, optional) – Affine matrix describing the location and orientation of the plasma in the world, by default None

  • name (str, optional) – User friendly name for this plasma, by default “Core Plasma”

Returns:

Plasma instance with requested properties

Return type:

Plasma

Raises:
  • TypeError – if equilibrium argument is not a valid EFITEquilibrium object.

  • ValueError – if requested time lies outside the range of the data.

  • RuntimeError – if electron density or temperature is absent from core_profiles IDS.

  • ValueError – if psi profile in core_profiles IDS is inconsistent with equilibrium.

property ids#

imas.core_profiles: Return core_profiles IDS.

Core Sources IDS#

class cherab.imas.core_sources.CoreSourcesIDS(shot, run, user='public', database='iterdb')#

Read and process IMAS core_sources IDS.

Parameters:
  • shot (int) – IMAS database shot ID.

  • run (int) – IMAS database run ID.

  • user (str, optional) – IMAS user ID, by default “public”

  • database (str, optional) – IMAS database ID, by default “iterdb”

Example

from cherab.imas import CoreSoucesIDS

core_source = CoreSourcesIDS(134000, 1, user="piblic", database="iter")
energy(equilibrium, source='radiation', particle='electrons', species=None, state=None)#

obtein source term for energy equation in each source

Parameters:
  • equilibrium (EFITEquilibrium) – Equilibrium object

  • source (str) – source term name, by default “radiation”

  • particle (str) – particle name, by default “electrons”

  • species (str, optional) – species label like “D”, by default None

  • state (str, optional) – state label like “H+” or “cold” in ion or neutral, respectively, by default None

Returns:

Returns self instance

Return type:

CoreSourcesIDS

Variables:
  • time (float) – sliced time by equilibrium time

  • source (str) – source value

  • particle (str) – particle value

  • species (str) – species value

  • state (str) – state value

  • equilibrium (EFITEquilibrium) – EFITEquilibrium object

  • psi_normalized (numpy.ndarray) – normalized psi 1D array

  • profile_1d (numpy.ndarray) – extracted 1D-array energy data

Note

If choosing a “radiation” source term, returning energy value is multiplied by -1.

Examples

from cherab.imas import CoreSourcesIDS, EquilibriumIDS
# Loding Equilibrium IDS data
equilibrium_ids = EquilibriumIDS(shot=134000, run=1, user="public", database="iter")

# Extracting EFIT object using time method
# time parameter: -1 means choosing the first time slice
imas_equilibrium = equilibrium_ids.time(-1)

# Loding Core Sources IDS
core_sources = CoreSourcesIDS(shot=134000, run=1, user="public", database="iter")

# extracting 1D energy profile
core_sources.energy(imas_equilibrium).profile_1d
array([0,0,1,2,....])

# extracting 2D energy distribution function
f = core_sources.map2d()
f(3,4) # (r,z)
6000.405949
get_all_particles()#

Return all available particle names.

Returns:

all available particle names

Return type:

list of str

get_all_sources()#

Return all source’s names in core_sources IDS.

Returns:

all source nams’s list in core_sources IDS

Return type:

list of str

get_all_species(source='total', particle='ion')#

Return all particle species labels as list.

Parameters:
  • source (str, optional) – source term name, by default “total”

  • particle (str, optional) – particle name, by default “ion”

Returns:

all particle species labels

Return type:

list of str

get_all_states(source='total', particle='ion', species='D')#

Return all species state labels as list.

Parameters:
  • source (str, optional) – source name, by default “total”

  • particle (str, optional) – particale name, by default “ion”

  • species (str, optional) – species name, by default “D”

Returns:

all species states labels

Return type:

list of str

property ids#

imas.core_sources: Return core_sources IDS object.

map2d()#

Return 2D distribution function(r, z)

Returns:

2D distribution function(r, z)

Return type:

Function2D

map3d()#

Return 3D distribution function(x, y, z)

Returns:

3D distribution function(x, y, z)

Return type:

Function3D

CXS IDS#

class cherab.imas.cxs.CXSIDS(shot, run=1, user='public', machine='iterdb')#

Reads an IMAS core_profiles IDS data object and provides object access to each timeslice.

Parameters:
  • shot (int) – IMAS database shot number.

  • run (int) – IMAS database run number.

  • user (str) – IMAS user ID, by default “public”

  • machine (str) – IMAS machine ID, by default “iterdb”

make_cxs_observers(parent=None, transform=None, name=None)#

Make cxs observer object

Parameters:
  • parent (Node, optional) – The observer’s parent node in the scenegraph, e.g. a World object, by default None

  • transform (AffineMatrix3D, optional) – Affine matrix describing the location and orientation of the observer in the world, by default None

  • name (str, optional) – User friendly name for this obsever, by default None

Returns:

cxs observer node

Return type:

Node

Edge Profiles IDS#

class cherab.imas.edge_profiles.EdgeProfilesIDS(shot, run, user='public', database='iterdb')#

Create EdgeProfilesIDS instance from edge_profiles IDS.

Parameters:
  • shot (int) – IMAS database shot ID.

  • run (int) – IMAS database run ID.

  • user (str, optional) – IMAS user ID, by default “public”

  • database (str, optional) – IMAS database ID, by default “iterdb”

create_plasma(time=0.0, equilibrium=None, parent=None, transform=None, name='Edge Plasma')#

Create a CHERAB plasma object from this edge_profiles IDS.

Parameters:
  • equilibrium (EFITEquilibrium) – Equilibrium object.

  • parent (Node, optional) – The plasma’s parent node in the scenegraph, e.g. a World object, by default None

  • transform (AffineMatrix3D, optional) – Affine matrix describing the location and orientation of the plasma in the world, by default None

  • name (str, optional) – User friendly name for this plasma, by default “Edge Plasma”

Returns:

Plasma instance with requested properties

Return type:

Plasma

Raises:
  • TypeError – if equilibrium argument is not a valid EFITEquilibrium object.

  • ValueError – if requested time lies outside the range of the data.

  • IndexError – if electron temperature data length corresponds with neither nr. of faces nor nr. of vertices.

property ids#

imas.edge_profiles: Return edge_profiles IDS object.

Edge Sources IDS#

class cherab.imas.edge_sources.EdgeSourcesIDS(shot, run, user='public', database='iterdb')#

Create EdgeSourcesIDS instance from edge_sources IDS.

Parameters:
  • shot (int) – IMAS database shot ID.

  • run (int) – IMAS database run ID.

  • user (str, optional) – IMAS user ID, by default “public”

  • database (str, optional) – IMAS database ID, by default “iterdb”

Example

from cherab.imas import EdgeSourcesIDS

edge = EdgeSourcesIDS(134000, 1, user="public", database="iter")
energy(source='radiation', particle='electrons', species=None, state=None, time=-1, grid_subset='nodes')#

obtein source term for energy equation in each source

Parameters:
  • source (str) – source term name, by default “radiation”

  • particle (str) – particle name, by default “electrons”

  • species (str, optional) – species label like “D”, by default None

  • state (str, optional) – state label like “H+” or “cold” in ion or neutral, respectively, by default None

  • time (int, optional) – time, by default -1 (means taking the first time index)

  • grid_subset (str, optional) – grid_subset name, by default “nodes” allowed to choose in [“nodes”, “faces”]

Returns:

Returns self instance

Return type:

EdgeSourcesIDS

Variables:
  • source (str) – source value

  • particle (str) – particle value

  • species (str) – species value

  • state (str) – state value

  • mesh_data (numpy.ndarray) – extracted 1D-array energy data

Examples

from cherab.imas import EdgeSourcesIDS
# Load Edge Sources IDS
edge_sources = EdgeSourcesIDS(shot=134000, run=1, user="public", database="iter")
# Generating mesh
edge_sources.mesh() # default single null grid
<cherab.imas.edge_sources.EdgeSourcesIDS at 0x7f080c0e92e8>

# stored energy data to edge_sources.mesh_data
edge_sources.energy(source="radiation", particle="electrons")
<cherab.imas.edge_sources.EdgeSourcesIDS at 0x7f080c0e92e8>

# Generate 2D distribution function of mesh_data
f = edge_sources.map2d()
f(5, -3.5)  # (r, z)
18477755.36763156
get_all_grid()#

Return all grid name in edge_sources IDS.

Returns:

all grid name list in edge_sources IDS.

Return type:

list

get_all_grid_subset(grid_name='SN')#

Return all grid subset in edge_sources IDS.

Parameters:

grid_name (str, optional) – grid name, by default “SN”

Returns:

all grid subset name list in edge_sources IDS

Return type:

list

get_all_particles()#

Return all available particle names.

Returns:

particle_list – all available particle names.

Return type:

list of str

get_all_sources()#

Return all source’s name in edge_sources IDS.

Returns:

all source nams’s list in edge_sources IDS

Return type:

list of str

get_all_species(source='total', particle='ion')#

Return all particle species labels as list.

Parameters:
  • source (str, optional) – source term name, by default “total”

  • particle (str, optional) – particle name, by default “ion”

Returns:

all particle specis labels

Return type:

list of str

get_all_states(source='total', particle='ion', species='D')#

Return all species state label as list.

Parameters:
  • source (str, optional) – source name, by default “total”

  • particle (str, optional) – particale name, by default “ion”

  • species (str, optional) – species name, by default “D”

Returns:

all species states labels

Return type:

list of str

property ids#

imas.edge_sources: Return edge_sources IDS object.

map2d()#

Return 2D distribution function(r, z)

Returns:

2D distribution function(r, z)

Return type:

Function2D

map3d()#

Return 3D distribution function(x, y, z)

Returns:

3D distribution function(x, y, z)

Return type:

Function3D

mesh(grid_name='SN')#

Get mesh geometry coodinates

Parameters:

grid_name (str, optional) – grid name, by default “SN” (Single Null)

Returns:

Returns self instance

Return type:

EdgeSourcesIDS

Variables:
  • grid_name (str) –

  • num_vertices (int) – the number of mesh vertices

  • num_cells (int) – the number of mesh cells (faces)

  • vertex_coords (numpy.ndarray (N, 2)) – vertex coordinates in double

  • triangles (numpy.ndarray (M, 3)) – triangle cell (faces) container in int32

Examples

edge.mesh(grid_name="SN")
<cherab.imas.edge_sources.EdgeSourcesIDS at 0x7f5731589390>
edge.vertex_coords
array([[ 5.14710589, -3.34978661],
        [ 5.35065068, -3.30333569],
        ...,
        [ 4.23267571, -3.79841576],
        [ 4.21820559, -3.80483435]])

Equilibrium IDS#

class cherab.imas.equilibrium.EquilibriumIDS(shot, run, user='public', database='iterdb')#

Read and process equilibrium IDS.

Parameters:
  • shot (int) – IMAS database shot ID.

  • run (int) – IMAS database run ID.

  • user (str, optional) – IMAS user ID, by default “public”

  • database (str, optional) – IMAS database ID, by default “iterdb”

Raises:
  • RuntimeError – if requested datafile is not found in the database.

  • RuntimeError – if equilibrium IDS is not found in the requested datafile.

property ids#

imas.equilibrium: Return equilibrium IDS object.

time(time)#

Find closest time slice and create EFITEquilibrium object. Regarding EFIT object,

Parameters:

time (float) – Requested time [s].

Returns:

An EFITEquilibrium object.

Return type:

EFITEquilibrium

Raises:
  • ValueError – if requested time lies outside the range of the data.

  • RuntimeError – if equilibrium.time_slice[i].profiles_2d[0].psi is empty.

NBI IDS#

class cherab.imas.nbi.NBIIDS(shot, run, user='public', database='iterdb')#

Create NBIIDS instance from nbi IDS.

Parameters:
  • shot (int) – IMAS database shot ID.

  • run (int) – IMAS database run ID.

  • user (str, optional) – IMAS user ID, by default “public”

  • database (str, optional) – IMAS database ID, by default “iterdb”

create_beam(time, plasma, atomic_data, attenuation_instructions, emission_instructions, integration_step=0.01, parent=None)#

Create a beam using data from nbi IDS.

Parameters:
  • time (float) – Create beam at this moment of time.

  • plasma (Plasma) – CHERAB plasma object.

  • atomic_data (AtomicData) – Atomic database, e.g. a OpenADAS object.

  • attenuation_instructions (dict) – Apply these attenuation instruction to every beamlet.

  • emission_instructions (dict) – Beam emission instructions.

  • integration_step (float, optional) – Integration step [m], by default 0.01

  • parent (Node, optional) – The plasma’s parent node in the scenegraph, e.g. a World object, by default None

Returns:

Beam instance with requested properties.

Return type:

Beam

property ids#

imas.nbi: Return nbi IDS object.

Radiation IDS#

class cherab.imas.radiation.RadiationIDS(shot, run=1, user='public', machine='iterdb')#

Reads an IMAS radiation IDS data object and provides object access to each time slice.

Parameters:
  • shot (int) – IMAS database shot number.

  • run (int) – IMAS database run number.

  • user (str) – IMAS user ID, by default “public”

  • machine (str) – IMAS machine ID, by default “iterdb”

elements(itime, indxprocess)#
emission(itime, indxprocess, indxelement, ion_or_neutral='ion')#

Make a CHERAB plasma object from this edge plasma IDS at the specified time slice.

Parameters:
  • itime (float) – The time slice at which to create a CHERAB plasma object.

  • indxprocess (int or slices) – 0/ line radiation from neutrals under neutral 1/ line and recombination radiation under ion 2/ bremsstrahlung radiation under neutral and ion 3/ possibly recombination and bremsstrahlung under ion

  • indxelement (The plasma's parent node in the scenegraph, e.g. a World object.) –

  • ion_or_neutral (str, optional) – “ion” or “neutral”, by default “ion”

get_geometry_range(itime)#
property ids_object#

imas.radiation: Return radiation IDS object.

Spectrometer Visible IDS#

class cherab.imas.spectrometer_visible.SpectrometerVisibleIDS(shot, run=1, user='public', machine='iterdb')#

Reads an IMAS spectrometer_visible IDS data object and provides object access to each timeslice.

Parameters:
  • shot (int) – IMAS database shot number.

  • run (int) – IMAS database run number.

  • user (str) – IMAS user ID, by default “public”

  • machine (str) – IMAS machine ID, by default “iterdb”

make_observers(parent=None, transform=None, name=None)#

Make fiber optics object as a observer

Parameters:
  • parent (Node, optional) – The observer’s parent node in the scenegraph, e.g. a World object, by default None

  • transform (AffineMatrix3D, optional) – Affine matrix describing the location and orientation of the observer in the world, by default None

  • name (str, optional) – User friendly name for this obsever, by default None

Returns:

fiber observer node

Return type:

Node

Miscellaneous#

Extract the nearest value of data set

param array:

1D data set array

type array:

numpy.ndarray

param value:

input value

type value:

float

returns:

the nearest value index of the array

rtype:

int

cherab.imas.plot.plot2d(fig=None, axes=None, func2D=None, xlim=(0, 1), ylim=(0, 1), res=0.01, title='profile in r-z plane', unit='a.u.', fontsize=14)#

plotting 2D distribution function

Parameters:
  • fig (Figure) – matplotlib figure object. If None, plt.figure(figsize(6.0, 6.5)) is offered.

  • axes (Axes) – matplotlib axes object

  • func2D (callable, required) – 2D distribution function, by default None

  • xlim (tuple, optional) – x axis sample range, by default (0, 1)

  • ylim (tuple, optional) – y axis sample range, by default (0, 1)

  • res (float, optional) – sampling resolution, by default 0.01

  • title (str, optional) – figure title, by default “profile in r-z plane”

  • unit (str, optional) – profile values’ unit, by default “a.u.”

  • fontsize (int, optional) – figure font size, by default 14 pt

Returns:

maplotlib figure object

Return type:

matplotlib.figure.Figure

cherab.imas.plot.plot2d_wo_cbar(fig=None, axes=None, func2D=None, xlim=(0, 1), ylim=(0, 1), res=0.01)#

plotting 2D distribution function w/o color bars plotting only images.

Parameters:
  • fig (Figure) – matplotlib figure object. If None, plt.figure(figsize(6.0, 6.5)) is offered.

  • axes (Axes) – matplotlib axes object

  • func2D (callable, required) – 2D distribution function, by default None

  • xlim (tuple, optional) – x axis sample range, by default (0, 1)

  • ylim (tuple, optional) – y axis sample range, by default (0, 1)

  • res (float, optional) – sampling resolution, by default 0.01

  • title (str, optional) – figure title, by default ‘profile in r-z plane’

Returns:

contains matplotlib objects (Figure, Axes, AxesImage)

Return type:

tuple