The ScalarQuantity
class encapsulates data from scalar quantities in DREAM
output, i.e. data which only has a single, scalar value at a given time. Scalar
quantities only evolve in time. Examples of scalar quantities found in DREAM
are the total plasma current I_p
and the poloidal flux on the tokamak
wall psi_edge
.
s1 = ScalarQuantity(name='MyScalarQuantity', data=[1,2,3], grid=grid, output=do)
s2 = ScalarQuantity(name='MyScalarQuantity', data=[4,5,6], grid=grid, output=do)
As with any UnknownQuantity, a ScalarQuantity
can be part of an
arithmetic expression with another ScalarQuantity
:
s3 = s1 + s2
s4 = s1 - s2
s5 = s1 * s2
s6 = s1 / s2
Operations are element-wise.
It is also possible to easily plot a ScalarQuantity
by calling the
plot()
member method:
s1.plot()
If desired, a selection of time points for which to plot the quantity can be
specified to plot()
:
s1.plot(t=[2,3])
DREAM.Output.ScalarQuantity.
ScalarQuantity
(name, data, grid, output, attr=[])¶Bases: DREAM.Output.UnknownQuantity.UnknownQuantity
__getitem__
(index)¶Direct access to data.
__init__
(name, data, grid, output, attr=[])¶Constructor.
name (str) – Name of quantity.
data (numpy.ndarray) – Data for quanity.
attr (list) – List of attributes for quantity.
grid – Grid on which the quantity is defined.
output (DREAMOutput) – Parent output object.
dumps
(t=None)¶Dumps the data of this quantity as a string.
t – Selection of time points to dump.
plot
(ax=None, show=None, t=None, t_shift=0, **kwargs)¶Generate a plot of the time evolution of this quantity.
ax (matplotlib.axes.Axes) – Axes object to create the plot on.
show (bool) – If True
, calls matplotlib.pyplot.show(block=False)
after creating the plot.
t – Selection of time points to plot. Can be a list, numpy array, slice or None
.
print
(t=None)¶Print the data in this quantity at the given time.
t – Time, or selection of times, from which to print the data.