piol.plotter module¶
Inheritance diagram¶

API reference¶
- class piol.plotter.Plotter[source]¶
Bases:
object
Class for plotting the system on dual sideview.
Container class to provide a framework to generate figures based on the system and trajectories that are given. Plots the system using two subfigures, the upper one being (s,x) and the lower one being (s,y) coordinates. The trajectories are projected to the subfigures while most elements plot a graphical representation of themselves, which resemble cross-sectional views.
- fig_side¶
Figure containing the x and y cross section views.
- Type
matplotlib.Figure
- ax_sx¶
Axis for the x cross section.
- Type
matplotlib.Axis
- ax_sy¶
Axis for the y cross section.
- Type
matplotlib.Axis
- .. todo::
Find how the elements are drawn. Now they are extending much more than the active area and the active area is not marked (eg. quadrupole inner radius).
- getView(view)[source]¶
Get the correct axis based on a view string.
- Parameters
view ({'sx', 'sy'}) – String defining the sideview
- Returns
ax – Axis object related to the given view
- Return type
matplotlib.Axis
- plotField(system, driver, aspect=1)[source]¶
Plot element fields.
- Parameters
system (ElementStack) – ElementStack that will be drawn on the section view or None.
driver (Driver) – Driver from which the trajectory information is collected.
aspect (float) – Element scaling factor. Used for having fields and geometry visible in the same plot.
- plotTrajectories(system, driver, kind='envelope', envspan=(0, 100), nsint=100, cmap='viridis')[source]¶
Plot the trajectories on the sideview.
- Parameters
system (ElementStack) – ElementStack that will be drawn on the section view or None.
driver (Driver) – Driver from which the trajectory information is collected.
kind ({'envelope', 'histogram', 'lines', 'recthisto'}) – The type of plot to be used. ‘lines’ will plot the trajectory of each particle, ‘envelope’ will draw a shaded area around the extrema of the beam at each s location. ‘histogram’ uses a hexbin and interpolated particle location values to generate a beam intensity distribution. ‘recthisto’ is the same as histogram but uses rectangular binning.
envspan (tuple) – Span used to define the drawn envelope. The default (0,100) draws the envelope from 0 percentile to 100 percentile of the distribution. Other percentiles, such as (9,95) for example, can be chosen to discard rogue trajectories.
nsint (int) – Number of interpolated s values between minimum and maximum to use.
cmap (str, optional) – String or instance of matplotlib colormap, used if a histogram is drawn.
- polyline(s, x, view)[source]¶
Draw and additional polyline with coordinates (s,x) on view (‘sx’ or ‘sy’)
- setLimits(view, limits)[source]¶
Set the limits of a certain view.
- Parameters
view ({'sx', 'sy'}) – String defining the sideview
limits (Sequence of tuples) – Sequence of tuples, the form being ((xmin, xmax), (ymin, ymax)). If one axis is not to be changed, replace that tuple with None.
- setUnit(ax, prefix, axis='x')[source]¶
Change unit of axis
Set the unit of the axis defined by the viewstring and the axis.
- Parameters
view ({'sx', 'sy'}) – Viewstring to be passed to
getView()
.prefix (str) – SI unit prefix name.
axis (str, optional) – Either ‘s’ for the x-axis, or anything else for the other axis.