PyPO User Manual
PyPO.System.System Class Reference
Inheritance diagram for PyPO.System.System:

Public Member Functions

def __init__ (self, logging.RootLogger redirect=None, bool verbose=True, bool override=True)
 Constructor. More...
 
logging.RootLogger getSystemLogger (self)
 Obtain a reference to the custom logger used by system. More...
 
str __str__ (self)
 Print system contents.
 
None setCustomBeamPath (self, str path, bool append=False)
 Set path to folder containing custom beam patterns. More...
 
def setSavePath (self, str path, bool append=False)
 Set path to folder were to save output plots. More...
 
def setSavePathSystems (self, path, append=False)
 Set path to folder were to save systems. More...
 
def setLoggingVerbosity (self, bool verbose=True)
 Set the verbosity of the logging from within the system. More...
 
def setOverride (self, bool override=True)
 Set the override toggle. More...
 
def addParabola (self, dict reflDict)
 Add a paraboloid reflector to the System. More...
 
def addHyperbola (self, dict reflDict)
 Add a hyperboloid reflector to the System. More...
 
def addEllipse (self, dict reflDict)
 Add an ellipsoid reflector to the System. More...
 
def addPlane (self, dict reflDict)
 Add a planar surface to the System. More...
 
def rotateGrids (self, str name, np.ndarray rotation, Objects obj=Objects.ELEMENT, Modes mode=Modes.REL, np.ndarray pivot=None, bool keep_pol=False)
 Rotate reflector grids. More...
 
None translateGrids (self, str name, np.ndarray translation, Objects obj=Objects.ELEMENT, Modes mode=Modes.REL)
 Translate reflector grids. More...
 
def homeReflector (self, str name, Objects obj=Objects.ELEMENT, bool trans=True, bool rot=True)
 Home a reflector or a group back into default configuration. More...
 
def snapObj (self, str name, str snap_name, Objects obj=Objects.ELEMENT)
 Take and store snapshot of object's current configuration. More...
 
def revertToSnap (self, str name, str snap_name, Objects obj=Objects.ELEMENT)
 Revert object configuration to a saved snapshot. More...
 
def deleteSnap (self, str name, str snap_name, Objects obj=Objects.ELEMENT)
 Delete a saved snapshot belonging to an object. More...
 
def groupElements (self, str name_group, *str names, np.ndarray pos=None, np.ndarray ori=None)
 Group elements together into a single block. More...
 
def removeGroup (self, str name_group)
 Remove a group of elements from system. More...
 
PTypes.reflGrids generateGrids (self, str name, bool transform=True, bool spheric=True)
 Generate reflector grids and normals. More...
 
def saveSystem (self, str name)
 Save a system object to disk. More...
 
def loadSystem (self, str name)
 Load a system object from the savePathSystems path. More...
 
def mergeSystem (self, *Self systems)
 Merge multiple systems together into current system. More...
 
def removeElement (self, str name)
 Remove reflector from system. More...
 
def copyElement (self, str name, str name_copy)
 Copy reflector. More...
 
def copyGroup (self, str name, str name_copy)
 Copy group. More...
 
def removeFrame (self, str frameName)
 Remove a ray-trace frame from system. More...
 
def removeField (self, str fieldName)
 Remove a PO field from system. More...
 
def removeCurrent (self, str currentName)
 Remove a PO current from system. More...
 
def removeScalarField (self, str fieldName)
 Remove a scalar PO field from system. More...
 
def readCustomBeam (self, str name_beam, str name_source, FieldComponents comp, float lam, bool normalise=True, float scale=1, str outname=None)
 Read a custom beam from disk into the system. More...
 
def runPO (self, dict runPODict)
 Instantiate a PO propagation. More...
 
def mergeBeams (self, *str beams, Objects obj=Objects.FIELD, str merged_name="combined")
 Merge multiple beams that are defined on the same surface. More...
 
def createTubeFrame (self, dict argDict)
 Create a tube of rays from a TubeRTDict. More...
 
def createGRTFrame (self, dict argDict)
 Create a Gaussian beam distribution of rays from a GRTDict. More...
 
list[np.ndarray] calcRayLen (self, *str frames, np.ndarray start=None)
 Calculate total length of a ray-trace beam. More...
 
def createGaussian (self, dict gaussDict, str name_surface)
 Create a vectorial Gaussian beam. More...
 
def createScalarGaussian (self, dict gaussDict, str name_surface)
 Create a scalar Gaussian beam. More...
 
def runRayTracer (self, dict runRTDict)
 Run a ray-trace propagation from a frame to a surface. More...
 
def runHybridPropagation (self, dict hybridDict)
 Perform a hybrid RT/PO propagation, starting from a reflected field and set of Poynting vectors. More...
 
np.ndarray interpFrame (self, str name_fr_in, str name_field, str name_target, str name_out, FieldComponents comp=FieldComponents.NONE, str method="nearest")
 Interpolate a frame and an associated field on a regular surface. More...
 
np.ndarray calcRTcenter (self, str name_frame)
 Calculate the geometric center of a ray-trace frame. More...
 
np.ndarray calcRTtilt (self, str name_frame)
 Calculate the mean direction normal of a ray-trace frame. More...
 
float calcSpotRMS (self, str name_frame)
 Calculate the RMS spot size of a ray-trace frame. More...
 
float calcSpillover (self, str name_field, FieldComponents comp, dict aperDict)
 Calculate spillover efficiency of a beam defined on a surface. More...
 
float calcTaper (self, str name_field, FieldComponents comp, dict aperDict=None)
 Calculate taper efficiency of a beam defined on a surface. More...
 
float calcXpol (self, str name_field, FieldComponents comp_co, FieldComponents comp_cr)
 Calculate cross-polar efficiency of a field defined on a surface. More...
 
np.ndarray fitGaussAbs (self, str name_field, FieldComponents comp, float thres=None, Scales scale=Scales.LIN, bool full_output=False, float ratio=1)
 Fit a Gaussian profile to the amplitude of a field component and adds the result to scalar field in system. More...
 
float calcMainBeam (self, str name_field, FieldComponents comp, float thres=None, Scales scale=Scales.LIN)
 Calculate main-beam efficiency of a beam pattern. More...
 
tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray] calcBeamCuts (self, str name_field, FieldComponents comp, int interp=1001, float phi=0, bool center=True, bool align=True, FieldComponents norm=FieldComponents.NONE, bool transform=False, Scales scale=Scales.dB, bool full_output=False)
 Calculate cross sections of a beam pattern. More...
 
tuple[pt.Figure, pt.Axes] 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[float, float] calcHPBW (self, str name_field, FieldComponents comp, bool center=False, float align=False)
 Calculate half-power beamwidth. More...
 
def createPointSource (self, dict PSDict, str name_surface)
 Generate point-source PO fields and currents. More...
 
def createUniformSource (self, dict UDict, str name_surface)
 Generate uniform PO fields and currents. More...
 
def createPointSourceScalar (self, dict PSDict, str name_surface)
 Generate point-source scalar PO field. More...
 
def createUniformSourceScalar (self, dict UDict, str name_surface)
 Generate scalar uniform PO fields and currents. More...
 
def interpBeam (self, str name, int gridsize_new, Objects obj=Objects.FIELD)
 Interpolate a PO beam. More...
 
tuple[pt.Figure, pt.Axes] 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] 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] 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] plotGroup (self, str name_group, bool show=True, bool ret=False)
 Plot a group of reflectors. More...
 
def 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...
 
np.ndarray findRTfocus (self, str name_frame, float f0=None, float tol=1e-12)
 Find the focus of a ray-trace frame. More...
 
def copyObj (self, obj=None)
 Create a deep copy of any object. More...
 
np.ndarray findRotation (self, np.ndarray v, np.ndarray u)
 Find rotation matrix to rotate v onto u. More...
 
np.ndarray getAnglesFromMatrix (self, np.ndarray M)
 Find x, y and z rotation angles from general rotation matrix. More...
 
int autoConverge (self, str source_field, str name_target, float tol=1e-2, int add=10, float patch_size=1/9, int max_iter=1000)
 Calculate gridsize for which calculation converges. More...
 
def runGUIPO (self, dict runPODict)
 system Instantiate a GUI PO propagation. More...
 
def runGUIRayTracer (self, dict runRTDict)
 Run a ray-trace propagation from a frame to a surface in the GUI. More...
 
def hybridGUIPropagation (self, dict hybridDict)
 Perform a hybrid RT/PO GUI propagation, starting from a reflected field and set of Poynting vectors. More...
 

Public Attributes

 verbosity
 
 system
 
 frames
 
 fields
 
 currents
 
 scalarfields
 
 groups
 
 assoc
 
 savePath
 
 clog_mgr
 
 clog
 

Static Public Attributes

 customBeamPath = os.getcwd()
 
 customReflPath = os.getcwd()
 
 savePathSystems = os.getcwd()
 

Constructor & Destructor Documentation

◆ __init__()

def PyPO.System.System.__init__ (   self,
logging.RootLogger   redirect = None,
bool   verbose = True,
bool   override = True 
)

Constructor.

Initializes system state.

Parameters
redirectRedirect all print statements within system to given stdout. To use, pass an instance of logging.RootLogger object or an object that inherrits from logging.RootLogger
verboseEnable system logger.
overrideAllow overriding names.

Member Function Documentation

◆ copyObj()

def PyPO.System.System.copyObj (   self,
  obj = None 
)

Create a deep copy of any object.

Parameters
objObject do be deepcopied.
Returns
copy A deepcopy of obj.

◆ findRotation()

np.ndarray PyPO.System.System.findRotation (   self,
np.ndarray  v,
np.ndarray  u 
)

Find rotation matrix to rotate v onto u.

Parameters
vNumpy array of length 3.
uNumpy array of length 3.
Returns
R_transf Rotation martix.

◆ getAnglesFromMatrix()

np.ndarray PyPO.System.System.getAnglesFromMatrix (   self,
np.ndarray  M 
)

Find x, y and z rotation angles from general rotation matrix.

Note that the angles are not necessarily the same as the original angles of the matrix. However, the matrix constructed by the found angles applies the same 3D rotation as the input matrix.

Parameters
MNumpy array of shape (3,3) containg a general rotation matrix.
Returns
r Numpy array of length 3 containing rotation angles around x, y and z.

◆ hybridGUIPropagation()

def PyPO.System.System.hybridGUIPropagation (   self,
dict  hybridDict 
)

Perform a hybrid RT/PO GUI propagation, starting from a reflected field and set of Poynting vectors.

Parameters
hybridDictA hybridDict dictionary.

◆ runGUIPO()

def PyPO.System.System.runGUIPO (   self,
dict  runPODict 
)

system Instantiate a GUI PO propagation.

Stores desired output in the system.fields and/or system.cursystemrents lists. If the 'EHP' mode is selected, the reflected Poynting frame is stored in system.frames.

Parameters
PODictDictionary containing the PO propagation instructions.
See also
PODict

◆ runGUIRayTracer()

def PyPO.System.System.runGUIRayTracer (   self,
dict  runRTDict 
)

Run a ray-trace propagation from a frame to a surface in the GUI.

Parameters
runRTDictA runRTDict object specifying the ray-trace.

The documentation for this class was generated from the following file: