# DistributionFunction¶

The DistributionFunction encapsulates the output of a distribution function from DREAM, and is the base class from which the more specific HotElectronDistributionFunction and RunawayElectronDistributionFunction classes are derived.

## Class documentation¶

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

Constructor.

currentDensity(t=None, r=None)

Calculates the current density carried by the electrons of this distribution function.

density(t=None, r=None)

Calculates the total density of this distribution function.

kineticEnergy(t=None, r=None)

Calculates the kinetic energy contained in the distribution function. (energy in Joule).

plasmaCurrent(t=None)

Calculates the total plasma current carried by the electrons of this distribution function.

plot(t=- 1, r=0, moment='distribution', p2=None, ax=None, show=None, logy=True, **kwargs)

Alias for semilogy() henceforth.

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

Make a contour plot of this quantity.

Parameters
• t (int) – Time index to plot.

• r (int) – Radial index to plot.

• ax – Matplotlib axes object to use for plotting.

• show (bool) – If True, or None and ax is NOT provided, calls matplotlib.pyplot.show() just before returning.

• logarithmic (bool) – If True, uses a logarithmic colour scale.

• coordinates (str) – Name of coordinates to use (either ‘spherical’ (p/xi) or ‘cylindrical’ (ppar/pperp)).

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

semilog(t=- 1, r=0, p2=None, ax=None, show=None, **kwargs)

Alias for semilogy().

semilogy(t=- 1, r=0, moment='distribution', p2=None, ax=None, show=None, **kwargs)

Plot this distribution function on a semilogarithmic scale. If ‘p2’ is None, the distribution function is first angle-averaged. Otherwise, ‘p2’ is interpreted as an index into the distribution function (second momentum dimension, i.e. xi or pperp).

Parameters
• t (int) – Integer, or list of integers, specifying the time indices of the distributions to plot.

• r (int) – Integer, or list of integers, specifying the radial indices of the distributions to plot.

• moment (str) – String (or array) speciyfing the angle averaged moment of the distribution to plot. See DREAM.Output.KineticQuantity.KineticQuantity.angleAveraged() for possible values.

• p2 (int) – Index into second momentum parameter (xi or pperp) of distribution to plot.

• ax (matplotlib.Axes) – Axes object to draw on.

• show (bool) – If True, show the figure after plotting.

synchrotron(model='spectrum', B=3.1, wavelength=7e-07, t=None, r=None)

Returns the synchrotron radiation emitted by this distribution function as a DREAM.Output.KineticQuantity.KineticQuantity.

Parameters
• model (str) – Model to use for synchrotron moment. Either ‘spectrum’ (for synchrotron spectrum at specified wavelength and magnetic field) or ‘total’ (for total emitted power).

• B (float) – Magnetic field strength to use with ‘spectrum’ model.

• wavelength (float) – Wavelength to use with ‘spectrum’ model (in meters).