KineticQuantity

The KineticQuantity encapsulates the output of a kinetic quantity in DREAM, i.e. a quantity which has two momentum (\(p, \xi\)), one radial (\(r\)) and one time dimension (\(t\)).

Class documentation

class DREAM.Output.KineticQuantity.KineticQuantity(name, data, grid, output, momentumgrid=None, attr=[])

Bases: DREAM.Output.UnknownQuantity.UnknownQuantity

__getitem__(index)

Direct access to data.

__init__(name, data, grid, output, momentumgrid=None, attr=[])

Constructor.

__repr__()

Convert this object to an “official” string.

angleAveraged(t=None, r=None, moment='distribution')

Returns the angle-averaged distribution function. Depending on the input parameters, the whole or only some parts of the spatiotemporal distribution can be angle-averaged.

This method can only be applied to distributions defined on p/xi momentum grids.

Supported moments:

  • distribution: \(\left\langle f \right\rangle_{\xi_0}\)

  • density: \(\left\langle V'f\right\rangle_{\xi_0}\)

  • current: \(\left\langle v\xi_0 V' f\right\rangle_{\xi_0}\)

  • …or a vector (or scalar) to weight the distribution function with.

where \(\left\langle X \right\rangle_{\xi_0} = \int_{-1}^1 X\,\mathrm{d}\xi_0\).

animate(keep=[], r=0, ax=None, repeat=False, repeat_delay=None, speed=None, blit=True, moment='distribution', save=None, dpi=None, **kwargs)

Creates an animation of the time evolution of the angle average of this kinetic quantity.

Parameters
  • keep (list) – List of time indices to keep in the plot.

  • r – Radius to plot angle average for.

  • ax – Axes object to use for plotting.

  • repeat (bool) – If True, repeats animation after it is finished.

  • repeat_delay (int) – Number of milliseconds to wait before repeating animation.

  • speed (int) – Number of milliseconds to show each frame.

  • blit (bool) – If True, use blitting to optimize drawing.

  • moment (str) – Moment of distribution function to plot (same values as for DREAM.Output.KineticQuantity.KineticQuantity.angleAveraged()).

  • save (str) – If provided, saves the animation to the named file instead of showing it.

  • dpi (int) – Video resolution (if saving animation to file).

  • kwargs – Keyword arguments passed to ax.plot().

animatePolar(t=None, repeat=False, repeat_delay=None, speed=None, dpi=100, save=None, **kwargs)

Make an animation of poloidal plots of the present quantity, including the specified time steps.

Parameters
  • t (slice) – time steps to include in the animation

  • repeat (bool) – If True, repeats the animation.

  • repeat_delay (int) – Time between consecutive animation runs in milliseconds

  • speed (int) – delay between frames in milliseconds

  • dpi (int) – animation resolution

  • save (str) – title of the file (if any) into which the animation is saved

get(t=None, r=None, p2=None, p1=None)

Returns data using the specified indexing. If an argument is None, this method will return all elements along that dimension.

getMultiples()

Get the number of “multiples” (e.g. number of ion species and charge states) covered by this quantity. The total number of elements in ‘self.data’ is the size of the grid on which this quantity lives (i.e. scalar grid, fluid grid, or a kinetic grid) times this number.

moment(weight, t=None, r=None)

Evaluate a moment of this distribution function with the given weighting factor.

plot(t=- 1, r=0, ax=None, show=None, logarithmic=False, coordinates=None, **kwargs)

Visualize this kinetic quantity at one time and radius using a filled contour plot.

Parameters
  • t – Time index to visualize quantity at.

  • r – Radial index to visualize quantity at.

  • ax – Matplotlib Axes object to draw plot on.

  • show – If True, calls matplotlib.pyplot.show() with block=False after plotting the quantity.

  • logarithmic – If True, plots the base-10 logarithm of the quantity.

  • coordinates – Determines which momentum coordinate system to use.

  • kwargs – Keyword arguments passed on to matplotlib.Axes.contourf() method.

plotPolar(t=- 1, r=0, ax=None, show=None, colorbar=True, displayGrid=False, logarithmic=False, thetaMin=0, thetaMax=3.141592653589793, maxMinScale=True, **kwargs)

Plot this kinetic quantity on a polar axis.

t: Time index to plot ax: Matplotlib axes object to use for plotting. show: If ‘True’, shows the plot immediately via a call to

‘matplotlib.pyplot.show()’ with ‘block=False’. If ‘None’, this is interpreted as ‘True’ if ‘ax’ is also ‘None’.

colorbar: Specify wether or not to include a colorbar displayGrid: Specify wether or not to display a polar grid in the plot logarithmic: If ‘True’, plot logarithm of the data thetaMin: Minimum pitch angle included in the plot thetaMax: Maximum pitch angle included in the plot maxMinScale: If ‘True’, set tha max and min of the color scale to the

maximum and minimum values of the data stored by this object over all time steps at the radial grid point specified by r

RETURNS a matplotlib axis object and a colorbar object (which may be ‘None’ if not used).