Plots¶
dexter.simulate.plot
¶
Plotting functions for simulated objects.
Functions:
-
plot_evolution–Plots the time evolution of a particle's dynamical variables.
-
plot_poloidal_drift–Plots particles' drifts on the $R-Z$ plane.
-
plot_qkinetic_pzeta–Plots a $q_{kin}-P_\zeta$ plot.
-
plot_qkinetic_energy–Plots a $q_{kin}-E$ plot.
-
plot_pzeta_poincare–Plots a $P_\zeta-\theta$ or $P_\zeta-\zeta$ Poincare plot.
-
plot_rz_poincare–Plots an $R-Z$ Poincare plot.
-
orbit_color–Returns an orbit type's color string.
plot_evolution(machine: Machine, particle: Particle, downsample: bool = True, show: bool = True) -> tuple[Figure, tuple[Axes]]
¶
Plots the time evolution of a particle's dynamical variables.
Parameters:
-
machine(Machine) –The machine in which the particle was integrated. It is used to convert specific quantities to SI units.
-
particle(Particle) –The integrated particle.
-
downsample(bool, default:True) –Whether or not to downsample the evolution arrays. This can be really helpful when plotting arrays with a lot of points, since it drastically improves both figure creation and interaction performance. Downsampling is done by increasing the [::step] just enough so that the final number of points is more than 50.000.
-
show(bool, default:True) –Whether or not to call
plt.show().
Raises:
-
RuntimeError–If the particle has not been integrated (
particle.steps_taken == 0).
plot_poloidal_drift(machine: Machine, obj: Particle | Queue, array_shape: ArrayShape = (300, 300), levels: int = 50, locator: Locator = 'MaxN', colors: Literal['Orbit', 'Cycle'] | str = 'Cycle', equal: bool = True, mask: float | None = None, show: bool = True) -> tuple[Figure, Axes]
¶
Plots particles' drifts on the $R-Z$ plane, overlaid on a contour plot of the Hamiltonian.
If a single particle is passed, an extra bold contour line is drawn at its energy level.
The contour of the Hamiltonian is only plotted if all passed particles have the same $P_\zeta$ and $\mu$.
Parameters:
-
machine(Machine) –The machine in which the particle was integrated. It is used to convert specific quantities to SI units.
-
obj(Particle | Queue) –The Particle or Queue containing the particles.
-
array_shape(ArrayShape, default:(300, 300)) –The shape of the $(r/\psi, \theta)$ array on which to calculate the contour lines.
-
colors(Literal['Orbit', 'Cycle'] | str, default:'Cycle') –The coloring method for each particle's orbit.
'Orbit'colors each point depending on its orbit type, as calculated from theclassifyroutine.'Cycle'cycles through the colorsbrcmk. Ifstrthen it is passed toax.plot(). -
levels(int, default:50) –The number of contour levels.
-
show(bool, default:True) –Whether or not to call
plt.show().
Other Parameters:
-
locator(Locator) –The tick locator to use to locate contour levels.
-
equal(bool) –Whether or not to set the axis aspect ratio to
equal. -
mask(float | None) –The value at which to mask the energy array where greater, in $keV$. If
None, no masking is performed. This is useful in cases where the Hamiltonian presents singularities.
Raises:
-
AttributeError–If
machinehas not defined ageometry.
plot_qkinetic_pzeta(machine: Machine, queue: Queue, show: bool = True) -> tuple[Figure, Axes]
¶
plot_qkinetic_energy(machine: Machine, queue: Queue, show: bool = True) -> tuple[Figure, Axes]
¶
plot_pzeta_poincare(machine: Machine, queue: Queue, intersect_params: IntersectParams, *, color: bool = True, initial: bool = False, show: bool = True) -> tuple[Figure, Axes]
¶
Plots a $P_\zeta-\theta$ or $P_\zeta-\zeta$ Poincare plot.
The kind of plot depends on the intersection field of intersect_params.
Parameters:
-
machine(Machine) –The machine in which the
queuewas integrated. -
queue(Queue) –The
Queuecontaining the integrated particles. -
intersect_params(IntersectParams) –The queue's intersection parameters.
-
color(bool, default:True) –Whether or not to color each orbit with a different color.
-
initial(bool, default:False) –Whether or not to plot each particle's initial point.
-
show(bool, default:True) –Whether or not to call
plt.show().
plot_rz_poincare(machine: Machine, queue: Queue, intersect_params: IntersectParams, *, color: bool = True, initial: bool = False, show: bool = True) -> tuple[Figure, Axes]
¶
Plots an $R-Z$ Poincare plot.
The kind of plot depends on the intersection field of intersect_params.
Parameters:
-
machine(Machine) –The machine in which the
queuewas integrated. -
queue(Queue) –The
Queuecontaining the integrated particles. -
intersect_params(IntersectParams) –The queue's intersection parameters.
-
color(bool, default:True) –Whether or not to color each orbit with a different color.
-
initial(bool, default:False) –Whether or not to plot each particle's initial point.
-
show(bool, default:True) –Whether or not to call
plt.show().
Raises:
-
RuntimeError–If
queuewas run with a 'ConstTheta' intersection. -
RuntimeError–If
machine.geometryis not defined.