PyPO User Manual
Visualisation Methods

This section contains a list of public PyPO methods which are used for visualising systems, elements, frames and PO fields/currents. More...

Functions

tuple[pt.Figure, pt.Axes] PyPO.System.System.plotBeamCut (self, str name_field, FieldComponents comp, float vmin=None, float vmax=None, bool center=True, bool align=True, Scales scale=Scales.dB, Units units=Units.DEG, str name="", bool show=True, bool save=False, bool ret=False)
 Plot beam pattern cross sections. More...
 
tuple[pt.Figure, pt.Axes] PyPO.System.System.plotBeam2D (self, str name_obj, FieldComponents comp=FieldComponents.NONE, str contour=None, fieldOrCurrentComponents contour_comp=FieldComponents.NONE, float vmin=None, float vmax=None, contourLevels levels=None, bool show=True, bool amp_only=False, bool save=False, bool norm=True, dict aperDict=None, Scales scale=Scales.dB, Projections project=Projections.xy, Units units=Units.MM, str name="", str titleA="Power", str titleP="Phase", bool unwrap_phase=False, bool ret=False)
 Generate a 2D plot of a PO (scalar)field or current. More...
 
tuple[pt.Figure, pt.Axes] PyPO.System.System.plot3D (self, str name_surface, cm cmap=cm.cool, bool norm=False, int fine=2, bool show=True, bool foc1=False, bool foc2=False, bool save=False, bool ret=False)
 Plot a 3D reflector. More...
 
tuple[pt.Figure, pt.Axes] PyPO.System.System.plotSystem (self, cm cmap=cm.cool, bool norm=False, int fine=2, bool show=True, bool foc1=False, bool foc2=False, bool save=False, bool ret=False, list[str] select=None, list[str] RTframes=None, str RTcolor="black")
 Plot the current system. More...
 
tuple[pt.Figure, pt.Axes] PyPO.System.System.plotGroup (self, str name_group, bool show=True, bool ret=False)
 Plot a group of reflectors. More...
 
def PyPO.System.System.plotRTframe (self, str name_frame, Projections project=Projections.xy, bool ret=False, float aspect=1, Units units=Units.MM)
 Create a spot diagram of a ray-trace frame. More...
 

Detailed Description

This section contains a list of public PyPO methods which are used for visualising systems, elements, frames and PO fields/currents.

Function Documentation

◆ plot3D()

tuple[pt.Figure, pt.Axes] PyPO.System.System.plot3D (   self,
str  name_surface,
cm   cmap = cm.cool,
bool   norm = False,
int   fine = 2,
bool   show = True,
bool   foc1 = False,
bool   foc2 = False,
bool   save = False,
bool   ret = False 
)

Plot a 3D reflector.

Note that matplotlib offers custom control over figures in the matplotlib window. This means that most parameters described for this method can be adjusted in the matplotlib plotting window.

Parameters
name_surfaceName of reflector to plot.
cmapColormap of reflector. Default is cool.
normPlot reflector normals. Default is False.
fineSpacing of normals for plotting. Default is 2.
showShow plot. Default is True.
foc1Plot focus 1. Default is False.
foc2Plot focus 2. Default is False.
saveSave the plot.
retReturn Figure and Axis. Only used in GUI.
Returns
fig Figure object.
ax Axes object.

◆ plotBeam2D()

tuple[pt.Figure, pt.Axes] PyPO.System.System.plotBeam2D (   self,
str  name_obj,
FieldComponents   comp = FieldComponents.NONE,
str   contour = None,
fieldOrCurrentComponents   contour_comp = FieldComponents.NONE,
float   vmin = None,
float   vmax = None,
contourLevels   levels = None,
bool   show = True,
bool   amp_only = False,
bool   save = False,
bool   norm = True,
dict   aperDict = None,
Scales   scale = Scales.dB,
Projections   project = Projections.xy,
Units   units = Units.MM,
str   name = "",
str   titleA = "Power",
str   titleP = "Phase",
bool   unwrap_phase = False,
bool   ret = False 
)

Generate a 2D plot of a PO (scalar)field or current.

Note that matplotlib offers custom control over figures in the matplotlib window. This means that most parameters described for this method can be adjusted in the matplotlib plotting window.

Parameters
name_objName of field or current to plot.
compComponent of field or current to plot. String of two characters; an uppercase {E, H, J, M} for field followed by a lowercase {x, y, z} for component. (e.g: 'Jz')
contourA PyPO field or current component to plot as contour.
contour_compComponent of contour to plot as contour. If None, assumes the contour is a scalarfield.
vminMinimum amplitude value to display. Default is -30.
vmaxMaximum amplitude value to display. Default is 0.
levelsLevels for contourplot.
showShow plot. Default is True.
amp_onlyOnly plot amplitude pattern. Default is False.
saveSave plot to /images/ folder.
normNormalise field (only relevant when plotting linear scale). Default is True.
aperDictPlot an aperture defined in an aperDict object along with the field or current patterns. Default is None.
scalePlot amplitude in linear or decibel values. Instance of Scales enum object.
projectSet abscissa and ordinate of plot. Should be given as an instance of the Projection enum. Default is Projection.xy.
unitsThe units of the axes. Instance of Units enum object.
nameName of .png file where plot is saved. Only when save=True. Default is "".
titleATitle of the amplitude plot. Default is "Amp".
titlePTitle of the phase plot. Default is "Phase".
unwrap_phaseUnwrap the phase patter. Prevents annular structure in phase pattern. Default is False.
retReturn the Figure and Axis object. Default is False.
Returns
fig Figure object.
ax Axes object.
See also
aperDict

◆ plotBeamCut()

tuple[pt.Figure, pt.Axes] PyPO.System.System.plotBeamCut (   self,
str  name_field,
FieldComponents  comp,
float   vmin = None,
float   vmax = None,
bool   center = True,
bool   align = True,
Scales   scale = Scales.dB,
Units   units = Units.DEG,
str   name = "",
bool   show = True,
bool   save = False,
bool   ret = False 
)

Plot beam pattern cross sections.

Plot the beam cross sections for a PO field. In this case, calcBeamCuts() will try to translate and rotate the supplied beam pattern to lie along the x- and y-axes. Note that using the "center" and "align" arguments should not be done when plotting beam cuts of very non-Gaussian beams. For these patterns, it is advised to set the arguments to False and calculate the beam cuts as-is.

Parameters
name_fieldName of field object.
compComponent of field object. Instance of FieldComponents enum object.
comp_crossCross-polar component. If given, is plotted as well. Defaults to None.
vminMinimum amplitude value to display. Default is -30.
vmaxMaximum amplitude value to display. Default is 0.
centerWhether to calculate beam center and center the beam cuts on this point.
alignWhether to find position angle of beam cuts and align cut axes to this.
scalePlot in decibels or linear.
unitsThe units of the axes. Instance of Units enum object.
nameName of .png file where plot is saved. Only when save=True. Default is "".
showShow plot. Default is True.
saveSave plot to savePath.
retReturn the Figure and Axis object. Default is False.
Returns
fig Figure object.
ax Axes object.

◆ plotGroup()

tuple[pt.Figure, pt.Axes] PyPO.System.System.plotGroup (   self,
str  name_group,
bool   show = True,
bool   ret = False 
)

Plot a group of reflectors.

Note that matplotlib offers custom control over figures in the matplotlib window. This means that most parameters described for this method can be adjusted in the matplotlib plotting window.

Parameters
name_groupName of group to be plotted.
showShow the plot.
retWhether to return figure and axis.
Returns
fig Figure object.
ax Axes object.

◆ plotRTframe()

def PyPO.System.System.plotRTframe (   self,
str  name_frame,
Projections   project = Projections.xy,
bool   ret = False,
float   aspect = 1,
Units   units = Units.MM 
)

Create a spot diagram of a ray-trace frame.

Note that matplotlib offers custom control over figures in the matplotlib window. This means that most parameters described for this method can be adjusted in the matplotlib plotting window.

Parameters
name_frameName of frame to plot.
projectSet abscissa and ordinate of plot. Should be given as an instance of the Projection enum. Default is Projection.xy.
retReturn Figure and Axis. Default is False.
aspectAspect ratio of plot. Default is 1.
unitsUnits of the axes for the plot. Instance of Units enum object.
Returns
fig Figure object.
ax Axes object.

◆ plotSystem()

tuple[pt.Figure, pt.Axes] PyPO.System.System.plotSystem (   self,
cm   cmap = cm.cool,
bool   norm = False,
int   fine = 2,
bool   show = True,
bool   foc1 = False,
bool   foc2 = False,
bool   save = False,
bool   ret = False,
list[str]   select = None,
list[str]   RTframes = None,
str   RTcolor = "black" 
)

Plot the current system.

Plots the reflectors and optionally ray-trace frames in a 3D plot.

The ray-trace frames to plot are supplied as a list to the "RTframes" parameter. Note that matplotlib offers custom control over figures in the matplotlib window. This means that most parameters described for this method can be adjusted in the matplotlib plotting window.

Parameters
name_surfaceName of reflector to plot.
cmapColormap of reflector. Default is cool.
normPlot reflector normals. Default is False.
fineSpacing of normals for plotting. Default is 2.
showShow plot. Default is True.
foc1Plot focus 1. Default is False.
foc2Plot focus 2. Default is False.
saveSave the plot.
retReturn Figure and Axis. Only used in GUI.
selectA list of names of reflectors to plot. If not given, plot all reflectors.
RTframesA list of names of frame to plot. If not given, plot no ray-trace frames.
Returns
fig Figure object.
ax Axes object.