gbspy.plots module
Collection of plotting routines
- gbspy.plots.movie(gbssim, which_field, t1=None, t2=None, z1=None, z2=None, x1=None, x2=None, y1=None, y2=None, plane='xy')
Animated image of a field in time
The axes of the resulting image are controlled by the
plane
argument. The remaining spatial dimension is averaged. The limits of the colorbar are adjusted automatically to exclude outliers (which may have a large impact when investigating crashes).- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
.t1 (float, optional) – Time at which to start the animation. By default, the first available time is selected.
t2 (float, optional) – Time at which to stop the animation. By default, the last available time is selected.
z1 (float, optional) – Angle of the first slice, only relevant when
plane='xy'
. By default, the first angle available is selected.z2 (float, optional) – Angle of the last slice, only relevant when
plane='xy'
. By default, the first angle available is selected.x1 (float, optional) – Radius of the first slice, only relevant when
plane='yz'
. By default, the first radius available is selected.x2 (float, optional) – Radius of the last slice, only relevant when
plane='yz'
. By default, the first radius available is selected.y1 (float, optional) – Height of the first slice, only relevant when
plane='xz'
. By default, the first height available is selected.y2 (float, optional) – Height of the last slice, only relevant when
plane='xz'
. By default, the first height available is selected.plane (str, optional) – The plane which the image should correspond to. Choose among
'xy'
,'xz'
and'yz'
. By default, a poloidal plane is selected.
- Returns
An animation object using blitting to improve the drawing time.
- Return type
- gbspy.plots.plot1d(gbssim, which_field, t1=None, t2=None, x1=None, x2=None, y1=None, y2=None, z1=None, z2=None, direction='x')
1D plot of a field
The x-axis of the plot will correspond to the dimension chosen with the
direction
argument. All other dimensions will be averaged out.- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
.t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.
t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.
z1 (float, optional) – Angle of the first slice. By default, the first angle available is selected.
z2 (float, optional) – Angle of the last slice. By default, if
direction='z'
the last angle available is selected, otherwise, the first angle is selected.x1 (float, optional) – Radius of the first slice. By default, if
direction='x'
the first radius available is selected, otherwise,x1
is chosen such that \(R(x_1)=(R_{\mathrm{min}}+R_{\mathrm{max}})/2\).x2 (float, optional) – Radius of the last slice. By default, if
direction='x'
the last radius available is selected, otherwise, equal tox1
.y1 (float, optional) – Height of the first slice. By default, if
direction='y'
the first height available is selected, otherwise,y1
is chosen such that \(Z(y_1)=(Z_{\mathrm{min}}+Z_{\mathrm{max}})/2\).y2 (float, optional) – Height of the last slice. By default, if
direction='y'
the last height available is selected, otherwise, equal toy1
.direction (str, optional) – Axis along which the quantity should be plotted. Choose among
'x'
,'y'
and'z'
.
- gbspy.plots.plot2d(gbssim, which_field, t1=None, t2=None, x1=None, x2=None, y1=None, y2=None, z1=None, z2=None, plane='xy')
2D plot of a field
The plot axes will correspond to the dimensions chosen with the
plane
argument. All other dimensions will be averaged out.- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
.t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.
t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.
z1 (float, optional) – Angle of the first slice. Relevant only if
plane='xy'
. By default, the first angle available is selected.z2 (float, optional) – Angle of the last slice. Relevant only if
plane='xy'
. By default, the first angle is selected.x1 (float, optional) – Radius of the first slice. Relevant only if
plane='yz'
. By default, chosen such that \(R(x_1)=(R_{\mathrm{min}}+R_{\mathrm{max}})/2\).x2 (float, optional) – Radius of the last slice. Relevant only if
plane='yz'
. By default, chosen equal tox1
.y1 (float, optional) – Height of the first slice. Relevant only if
plane='xz'
. By default, chosen such that \(Z(y_1)=(Z_{\mathrm{min}}+Z_{\mathrm{max}})/2\).y2 (float, optional) – Height of the last slice. Relevant only if
plane='xz'
. By default, chosen equal toy1
.plane (str, optional) – Plane on which the quantity should be plotted. Choose among
'xy'
,'xz'
and'yz'
.
- gbspy.plots.plot_all(gbssim, t1=None, t2=None, z1=None, z2=None)
Plot plasma fields in the poloidal plane
If multiple slices are selected in the time or toroidal (
z
) direction, they will be averaged out.- Parameters
gbssim (gbspy.pp.Sim) – Simulation object.
t1 (float, optional) – First time to load. By default, the last available time is selected.
t2 (float, optional) – Last time to load. By default, the last available time is selected.
z1 (float, optional) – Angle of the first slice. By default, the first available slice is selected.
z2 (float, optional) – Angle of the last slice. By default, the first available slice is selected.
- gbspy.plots.plot_avg(gbssim, which_field, x1=None, x2=None, y1=None, y2=None, z1=None, z2=None, t1=None, t2=None)
Plots the spatial average of
which_field
in time- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
. Ifwhich_field='all'
, plots the average ofn
,Te
,Ti
andstrmf
.x1 (float, optional) – The range of values to select in the radial direction. By default, all available points are loaded.
x2 (float, optional) – The range of values to select in the radial direction. By default, all available points are loaded.
y1 (float, optional) – The range of values to select in the vertical direction. By default, all available points are loaded.
y2 (float, optional) – The range of values to select in the vertical direction. By default, all available points are loaded.
z1 (float, optional) – The range of values to select in the toroidal direction. By default, all available points are loaded.
z2 (float, optional) – The range of values to select in the toroidal direction. By default, all available points are loaded.
t1 (float, optional) – First time slice to load. By default, the first available slice is selected.
t2 (float, optional) – Last time slice to load. By default, the last available slice is selected.
- gbspy.plots.plot_crossfield_profile(gbssim, data, ysep=None)
Plot the LFS profile along a line obtained with gbspy.surfaces.get_line. at heigth Z = ysep at separatrix, as function of (psi-psi0)/(psi_sep-psi0)
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
data (data to plot, 2dim array (ny,nx)) –
ysep (float, optional) – y coordinate at the separatrix
- Returns
rline (np.ndarray) – positions for the profile
data_line (np.ndarray) – profile of the averaged field
- gbspy.plots.plot_evol(gbssim, which_field=None, sigscale=1.0, legend=None)
Average plots with standard deviation
This function replicates the functionality of
gbspy.plots.plot_avg()
, but provides error bars scaled to the point-wise standard (also known as “dispersion index”) deviation of the plotted quantities.If no fields are passed, defaults will be provided.
- Parameters
gbssim (gbspy.pp.Sim or tuple) – Simulation object, or list of simulation objects.
which_field (str or tuple, optional) – Name of the field to plot, or list of names. The names should be accepted by
gbspy.pp.Sim.get_field()
. By default, all fields are plotted.sigscale (float, optional) – A parameter to resize errorbars.
legend (bool, optional) – Adds a title to the plots, helpful to distinguish multiple simulations. Legends are added by default if mutliple simulations are passed.
- gbspy.plots.plot_evol_multiproc(gbssim, which_field=None, sigscale=1.0)
Parallelized version of
gbspy.plots.plot_avg()
The plots will be saved to disk as PNG files.
- Parameters
gbssim (gbspy.pp.Sim or tuple) – Simulation object, or list of simulation objects.
which_field (str or tuple, optional) – Name of the field to plot, or list of names. The names should be accepted by
gbspy.pp.Sim.get_field()
. By default, all fields are plotted.sigscale (float, optional) – A parameter to resize errorbars.
- gbspy.plots.plot_fluct(gbssim, which_field, t1=None, t2=None, norm=False)
Plot 2D fluctuations in the poloidal plane.
The time and toroidal directions are used to average the requested quantity in the poloidal plane. The difference between the quantity at time
t2
with respect to this average is plotted.- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
.t1 (float, optional) – First time slice to load. By default, choose
t1
such that \(t(t_1)=t(t_2)-2\).t2 (float, optional) – Last time slice to load. By default, select the last available time slice.
norm (bool, optional) – Normalizes the fluctuations in a point-wise manner using the local average.
- gbspy.plots.plot_integral_core(gbssim, data, Nr=100)
Evaluate and plot the integral profile of data inside the core.
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
data (np.ndarray) – Field to integrate as a 2D array with shape compatible with a poloidal plane size from
gbssim
.Nr (int, optional) – Number of points in radial direction.
- Returns
rcore (np.ndarray) – Radial positions
data_int (np.ndarray) – Integral profile
- gbspy.plots.plot_mp_profile(gbssim, which_field='n', t1=None, t2=None, z1=None, z2=None, y1=None, y2=None, Xcore=None, Ycore=None, Xsol=None, Ysol=None, side='l')
Plot the MP average profile of the chosen field using the field-aligned coordinate system built with build_grid
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str, optional) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
.t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.
t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.
z1 (float, optional) – Angle of the first slice. By default, the first angle available is selected.
z2 (float, optional) – Angle of the last slice. By default, the first angle available is selected.
y1 (float, optional) – y lower coordinate at the separatrix
y2 (float, optional) – y upper coordinate at the separatrix
Xcore (float, optional) – field-aligned coords in core, if not given it is evaluated
Ycore (float, optional) – field-aligned coords in core, if not given it is evaluated
Xsol (float, optional) – field-aligned coords in SOL, if not given it is evaluated
Ysol (float, optional) – field-aligned coords in SOL, if not given it is evaluated
side (str, optional) –
'l'
or'h'
, for the low or high, field side
- Returns
romp (np.ndarray) – positions for the profile
data_omp (np.ndarray) – profile of the averaged field
- gbspy.plots.plot_neutrals(gbssim, t1=None, t2=None, z1=None, z2=None)
Plot neutral fields in the (x,y) plane
INPUT gbssim: GBS simulation object t1: time of the first slice t2: time of the last slice z1: angle of the first slice z2: angle of the last slice
- gbspy.plots.plot_poloidal_profile(gbssim, which_field='n', t1=None, t2=None, z1=None, z2=None, r1=None, r2=None, Xsol=None, Ysol=None, rsol=None, chisol=None)
Plot the average profile of the chosen field along the poloidal coordinate (chi) using the field-aligned coordinate system
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
which_field (str, optional) – Name of the field to plot. This name should be accepted by
gbspy.pp.Sim.get_field()
.t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.
t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.
z1 (float, optional) – Angle of the first slice. By default, the first angle available is selected.
z2 (float, optional) – Angle of the last slice. By default, the first angle available is selected.
r1 (float, optional) – minimum radius
r2 (float, optional) – maximum radius
Xsol (np.ndarray) – Field-aligned coords in SOL, if not given it is evaluated by calling
gbspy.grid.build_grid()
.Ysol (np.ndarray) – Field-aligned coords in SOL, if not given it is evaluated by calling
gbspy.grid.build_grid()
.rsol (np.ndarray) – Field-aligned coords in SOL, if not given it is evaluated by calling
gbspy.grid.build_grid()
.chisol (np.ndarray) – Field-aligned coords in SOL, if not given it is evaluated by calling
gbspy.grid.build_grid()
.
- Returns
chipos (np.ndarray) – length of the field line (sum of poloidal and toroidal component)
data_chi (np.ndarray) – profile of the averaged field
- gbspy.plots.plot_power_source(gbssim, z1=None, z2=None, t1=None, t2=None)
Plot the total power source.
The plot is averaged in z.
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
z1 (float, optional) – Angle of the first slice. By default, the first angle available is selected.
z2 (float, optional) – Angle of the last slice. By default, the first angle available is selected.
t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.
t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.
- Returns
Sp – total power source
- Return type
np.ndarray
- gbspy.plots.plot_source(gbssim)
Plot the density and temperature source
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
- Returns
Sn (np.ndarray) – A two dimensional array containing the density source in a poloidal plane.
St (np.ndarray) – A two dimensional array containing the temperature source in a poloidal plane.
- gbspy.plots.plot_sources_neutrals(gbssim, z1=None, z2=None, t1=None, t2=None)
Plot the density, the electron and the ion temperature sources due to the neutrals. The plot shows the last time slice averaged in z.
- Parameters
gbssim (gbspy.pp.Sim) – Simulation object
z1 (float, optional) – Angle of the first slice. By default, the first angle available is selected.
z2 (float, optional) – Angle of the first slice. By default, the first angle available is selected.
t1 (float, optional) – First time slice to load. By default, only the last available slice is loaded.
t2 (float, optional) – Last time slice to load. By default, only the last available slice is loaded.
- Returns
Sn (np.ndarray) – Density source as a 4D array.
Ste (np.ndarray) – Electron temperature source as a 4D array.
Sti (np.ndarray) – Ion temperature source as a 4D array.
- gbspy.plots.plotf2d(f, x, y)
Plots a generic 2D field
- Parameters
f (np.ndarray) – A multi-dimensional array which can be squeezed to a 2D array.
x (np.ndarray) – X-coordinate associated to
f
. Can either be the same shape asf
or 1D.y (np.ndarray) – Y-coordinate associated to
f
. Can either be the same shape asf
or 1D.
See also