PyPO User Manual
Checks.py File Reference

File containing all commonly used checks for PyPO user input. More...

Classes

class  PyPO.Checks.InputTransformError
 Input transformation error. More...
 
class  PyPO.Checks.InputReflError
 Input reflector error. More...
 
class  PyPO.Checks.InputRTError
 Input ray-trace error. More...
 
class  PyPO.Checks.RunRTError
 Propagate ray-trace error. More...
 
class  PyPO.Checks.InputPOError
 Input physical optics error. More...
 
class  PyPO.Checks.RunPOError
 Propagate physical optics error. More...
 
class  PyPO.Checks.HybridPropError
 Hybrid propagation error. More...
 
class  PyPO.Checks.ElemNameError
 Element name error. More...
 
class  PyPO.Checks.FieldNameError
 Field name error. More...
 
class  PyPO.Checks.CurrentNameError
 Current name error. More...
 
class  PyPO.Checks.FrameNameError
 Frame name error. More...
 
class  PyPO.Checks.ScalarFieldNameError
 Scalarfield name error. More...
 
class  PyPO.Checks.GroupNameError
 Group name error. More...
 
class  PyPO.Checks.MergeBeamError
 Merge beamerror. More...
 
class  PyPO.Checks.ApertureError
 ApertureError. More...
 

Functions

def PyPO.Checks.getIndex (name, nameList)
 Get the regular expression for checking if an object already exists. More...
 
def PyPO.Checks.has_CUDA ()
 Check if the CUDA dynamically linked libraries exist. More...
 
def PyPO.Checks.check_elemSystem (name, elements, clog, errStr="", extern=False)
 Check if a specified element is in the system dictionary. More...
 
def PyPO.Checks.check_fieldSystem (name, fields, clog, errStr="", extern=False)
 Check if a specified field is in the fields dictionary. More...
 
def PyPO.Checks.check_currentSystem (name, currents, clog, errStr="", extern=False)
 Check if a specified current is in the currents dictionary. More...
 
def PyPO.Checks.check_scalarfieldSystem (name, scalarfields, clog, errStr="", extern=False)
 Check if a specified scalarfield is in the scalarfields dictionary. More...
 
def PyPO.Checks.check_frameSystem (name, frames, clog, errStr="", extern=False)
 Check if a specified frame is in the frames dictionary. More...
 
def PyPO.Checks.check_groupSystem (name, groups, clog, errStr="", extern=False)
 Check if a specified group is in the groups dictionary. More...
 
def PyPO.Checks.errMsg_field (fieldName, elemName)
 Error message when a mandatory field has not been filled in a dictionary. More...
 
def PyPO.Checks.errMsg_type (fieldName, inpType, elemName, fieldType)
 Error message when a field has not been filled has been filled with an incorrect type. More...
 
def PyPO.Checks.errMsg_option (fieldName, option, elemName, args)
 Error message when a field has an unknown option. More...
 
def PyPO.Checks.errMsg_shape (fieldName, shape, elemName, shapeExpect)
 Error message when a field has an incorrect shape. More...
 
def PyPO.Checks.errMsg_value (fieldName, value, elemName)
 Error message when a wrong input value is encountered. More...
 
def PyPO.Checks.errMsg_noelem (elemName)
 Error message when a reflector element is not present in System. More...
 
def PyPO.Checks.errMsg_noframe (frameName)
 Error message when a frame object is not present in System. More...
 
def PyPO.Checks.errMsg_nofield (fieldName)
 Error message when a field object is not present in System. More...
 
def PyPO.Checks.errMsg_nocurrent (currentName)
 Error message when a current object is not present in System. More...
 
def PyPO.Checks.errMsg_noscalarfield (scalarfieldName)
 Error message when a scalarfield object is not present in System. More...
 
def PyPO.Checks.errMsg_nogroup (groupName)
 Error message when a group is not present in System. More...
 
def PyPO.Checks.errMsg_mergebeam (beamName, surf0, surfd)
 Error message when beams are to be merged but are not on the same surface. More...
 
def PyPO.Checks.check_array (array, clog, array_type=np.ndarray, array_shape=(3,))
 Error message when and array is of incorrect type/shape. More...
 
def PyPO.Checks.block_ndarray (fieldName, elemDict, shape, cust_name=False)
 Check if an input array has correct shape. More...
 
def PyPO.Checks.check_ElemDict (elemDict, nameList, clog)
 Check element input dictionary. More...
 
def PyPO.Checks.check_TubeRTDict (TubeRTDict, nameList, clog)
 Check a tubular input frame dictionary. More...
 
def PyPO.Checks.check_GRTDict (GRTDict, nameList, clog)
 Check a Gaussian input frame dictionary. More...
 
def PyPO.Checks.check_runRTDict (runRTDict, elements, frames, clog, extern=True)
 Check a ray-trace propagation input dictionary. More...
 
def PyPO.Checks.check_PSDict (PSDict, nameList, clog)
 Check a point source input beam dictionary. More...
 
def PyPO.Checks.check_GPODict (GPODict, nameList, clog)
 Check a Gaussian input beam dictionary. More...
 
def PyPO.Checks.check_runPODict (runPODict, elements, fields, currents, scalarfields, frames, clog)
 Check a physical optics propagation input dictionary. More...
 
def PyPO.Checks.check_hybridDict (hybridDict, elements, frames, fields, clog)
 Check a hybrid propagation input dictionary. More...
 
def PyPO.Checks.check_aperDict (aperDict, clog)
 CHeck if aperture dictionary is valid. More...
 
def PyPO.Checks.check_ellipseLimits (ellipsoid, clog)
 Check if ellipsoid limits are valid points. More...
 
def PyPO.Checks.check_sameBound (beams, checkDict, clog)
 Check if beams to be merged are defined on same surface. More...
 
def PyPO.Checks.check_associations (associations, fieldName, frameName, surf, clog)
 Check if field and frame are associated on the same surface. More...
 

Variables

int PyPO.Checks.nThreads_cpu = os.cpu_count() - 1 if os.cpu_count() > 1 else 1
 
list PyPO.Checks.PO_modelist = ["JM", "EH", "JMEH", "EHP", "FF", "scalar"]
 

Detailed Description

File containing all commonly used checks for PyPO user input.

Function Documentation

◆ block_ndarray()

def PyPO.Checks.block_ndarray (   fieldName,
  elemDict,
  shape,
  cust_name = False 
)

Check if an input array has correct shape.

Parameters
fieldNameName of field containing array.
elemDictDictionary containing field.
shapeExpected shape of input array.
Returns
errStr The errorstring.

◆ check_aperDict()

def PyPO.Checks.check_aperDict (   aperDict,
  clog 
)

CHeck if aperture dictionary is valid.

Parameters
aperDictAn aperture dictionary.
clogCustomLogger object.
See also
aperDict

◆ check_array()

def PyPO.Checks.check_array (   array,
  clog,
  array_type = np.ndarray,
  array_shape = (3,) 
)

Error message when and array is of incorrect type/shape.

Parameters
arrayArray to check.
array_typeExpected type of array.
array_shapeExpected shape of array.

◆ check_associations()

def PyPO.Checks.check_associations (   associations,
  fieldName,
  frameName,
  surf,
  clog 
)

Check if field and frame are associated on the same surface.

Used for hybrid propagations. Currently, can only have one single association per surface!

Parameters
associationsAll present associations in system.
fieldNameName of field to be propagated.
frameNameName of frame to be propagated.
surfName of surface from which a hybrid propagation is performed.
clogCustomLogger object.

◆ check_currentSystem()

def PyPO.Checks.check_currentSystem (   name,
  currents,
  clog,
  errStr = "",
  extern = False 
)

Check if a specified current is in the currents dictionary.

Parameters
nameName of current.
currentsThe currents dictionary containing all currents.
clogCustomLogger object.
errStrError string for appending error messages.
externWhether this function is called from System or from here.
Returns
errStr The error string with any new entries appended.

◆ check_ElemDict()

def PyPO.Checks.check_ElemDict (   elemDict,
  nameList,
  clog 
)

Check element input dictionary.

Checks the input dictionary for errors. Raises exceptions when encountered. Also fills in defaults if these are not supplied.

Parameters
elemNameName of element, string.
nameListList of names in system dictionary.
clogCustomLogger object.

◆ check_elemSystem()

def PyPO.Checks.check_elemSystem (   name,
  elements,
  clog,
  errStr = "",
  extern = False 
)

Check if a specified element is in the system dictionary.

Parameters
nameName of element.
elementsThe system dictionary containing all elements.
clogCustomLogger object.
errStrError string for appending error messages.
externWhether this function is called from System or from here.
Returns
errStr The error string with any new entries appended.

◆ check_ellipseLimits()

def PyPO.Checks.check_ellipseLimits (   ellipsoid,
  clog 
)

Check if ellipsoid limits are valid points.

If not, reduces limits to acceptable values.

Parameters
ellipsoidA reflDict containing description of ellipsoid surface.
clogCustomLogger object.

◆ check_fieldSystem()

def PyPO.Checks.check_fieldSystem (   name,
  fields,
  clog,
  errStr = "",
  extern = False 
)

Check if a specified field is in the fields dictionary.

Parameters
nameName of field.
fieldsThe fields dictionary containing all fields.
clogCustomLogger object.
errStrError string for appending error messages.
externWhether this function is called from System or from here.
Returns
errStr The error string with any new entries appended.

◆ check_frameSystem()

def PyPO.Checks.check_frameSystem (   name,
  frames,
  clog,
  errStr = "",
  extern = False 
)

Check if a specified frame is in the frames dictionary.

Parameters
nameName of frame.
framesThe frames dictionary containing all frames.
clogCustomLogger object.
errStrError string for appending error messages.
externWhether this function is called from System or from here.
Returns
errStr The error string with any new entries appended.

◆ check_GPODict()

def PyPO.Checks.check_GPODict (   GPODict,
  nameList,
  clog 
)

Check a Gaussian input beam dictionary.

Parameters
GPODictA GPODict object.
namelistList containing names of fields in System.
clogCustomLogger object.
See also
GPODict

◆ check_groupSystem()

def PyPO.Checks.check_groupSystem (   name,
  groups,
  clog,
  errStr = "",
  extern = False 
)

Check if a specified group is in the groups dictionary.

Parameters
nameName of group.
groupsThe groups dictionary containing all groups.
clogCustomLogger object.
errStrError string for appending error messages.
externWhether this function is called from System or from here.
Returns
errStr The error string with any new entries appended.

◆ check_GRTDict()

def PyPO.Checks.check_GRTDict (   GRTDict,
  nameList,
  clog 
)

Check a Gaussian input frame dictionary.

Parameters
GRTDictA GRTDict object.
namelistList containing names of frames in System.
clogCustomLogger object.
See also
GRTDict

◆ check_hybridDict()

def PyPO.Checks.check_hybridDict (   hybridDict,
  elements,
  frames,
  fields,
  clog 
)

Check a hybrid propagation input dictionary.

Parameters
hybridDictA hybridDict.
elementsList containing names of surfaces in System.
framesList containing names of frames in System.
fieldsList containing names of frames in System.
clogCustomLogger object.

◆ check_PSDict()

def PyPO.Checks.check_PSDict (   PSDict,
  nameList,
  clog 
)

Check a point source input beam dictionary.

Parameters
PSDictA PSDict object.
namelistList containing names of fields in System.
clogCustomLogger object.
See also
PSDict

◆ check_runPODict()

def PyPO.Checks.check_runPODict (   runPODict,
  elements,
  fields,
  currents,
  scalarfields,
  frames,
  clog 
)

Check a physical optics propagation input dictionary.

Parameters
runPODictA runPODict.
elementsList containing names of surfaces in System.
currentsList containing names of currents in System.
scalarfieldsList containing names of scalarfields in System.
clogCustomLogger object.

◆ check_runRTDict()

def PyPO.Checks.check_runRTDict (   runRTDict,
  elements,
  frames,
  clog,
  extern = True 
)

Check a ray-trace propagation input dictionary.

Parameters
runRTDictA runRTDict.
elementsList containing names of surfaces in System.
framesList containing names of frames in System.
clogCustomLogger object.
externDo not raise InputRTError if "extern" = False.
Returns
errStr The errorstring. Only returned if "extern" = True.

◆ check_sameBound()

def PyPO.Checks.check_sameBound (   beams,
  checkDict,
  clog 
)

Check if beams to be merged are defined on same surface.

If not, raise MergeBeam Error.

Parameters
beamsFields/currents to be merged.
checkDictSystem c=dictionary containing fields/currents.
clogCustomLogger object.

◆ check_scalarfieldSystem()

def PyPO.Checks.check_scalarfieldSystem (   name,
  scalarfields,
  clog,
  errStr = "",
  extern = False 
)

Check if a specified scalarfield is in the scalarfields dictionary.

Parameters
nameName of scalarfield.
scalarfieldsThe scalarfields dictionary containing all scalarfields.
clogCustomLogger object.
errStrError string for appending error messages.
externWhether this function is called from System or from here.
Returns
errStr The error string with any new entries appended.

◆ check_TubeRTDict()

def PyPO.Checks.check_TubeRTDict (   TubeRTDict,
  nameList,
  clog 
)

Check a tubular input frame dictionary.

Parameters
TubeRTDictA TubeRTDict object.
namelistList containing names of frames in System.
clogCustomLogger object.
See also
TubeRTDict

◆ errMsg_field()

def PyPO.Checks.errMsg_field (   fieldName,
  elemName 
)

Error message when a mandatory field has not been filled in a dictionary.

Parameters
fieldNameName of field in dictionary that is not filled.
elemNameName of dictionary where error occurred.
Returns
errStr The errorstring.

◆ errMsg_mergebeam()

def PyPO.Checks.errMsg_mergebeam (   beamName,
  surf0,
  surfd 
)

Error message when beams are to be merged but are not on the same surface.

Parameters
beamNameName of field/current that is not on surface.
surf0Zeroth surface, taken as the merging surface.
surfdSurface on which current beam is defined.
Returns
errStr The errorstring.

◆ errMsg_nocurrent()

def PyPO.Checks.errMsg_nocurrent (   currentName)

Error message when a current object is not present in System.

Parameters
currentNameName of current.
Returns
errStr The errorstring.

◆ errMsg_noelem()

def PyPO.Checks.errMsg_noelem (   elemName)

Error message when a reflector element is not present in System.

Parameters
elemNameName of element.
Returns
errStr The errorstring.

◆ errMsg_nofield()

def PyPO.Checks.errMsg_nofield (   fieldName)

Error message when a field object is not present in System.

Parameters
fieldNameName of field.
Returns
errStr The errorstring.

◆ errMsg_noframe()

def PyPO.Checks.errMsg_noframe (   frameName)

Error message when a frame object is not present in System.

Parameters
frameNameName of frame.
Returns
errStr The errorstring.

◆ errMsg_nogroup()

def PyPO.Checks.errMsg_nogroup (   groupName)

Error message when a group is not present in System.

Parameters
groupNameName of group.
Returns
errStr The errorstring.

◆ errMsg_noscalarfield()

def PyPO.Checks.errMsg_noscalarfield (   scalarfieldName)

Error message when a scalarfield object is not present in System.

Parameters
scalarfieldNameName of scalarfield.
Returns
errStr The errorstring.

◆ errMsg_option()

def PyPO.Checks.errMsg_option (   fieldName,
  option,
  elemName,
  args 
)

Error message when a field has an unknown option.

Parameters
fieldNameName of field in dictionary.
optionGiven option.
elemNameName of dictionary where error occurred.
argsExpected options.
Returns
errStr The errorstring.

◆ errMsg_shape()

def PyPO.Checks.errMsg_shape (   fieldName,
  shape,
  elemName,
  shapeExpect 
)

Error message when a field has an incorrect shape.

Parameters
fieldNameName of field in dictionary.
shapeShape of input.
elemNameName of dictionary where error occurred.
shapeExpectExpected input shape for field.
Returns
errStr The errorstring.

◆ errMsg_type()

def PyPO.Checks.errMsg_type (   fieldName,
  inpType,
  elemName,
  fieldType 
)

Error message when a field has not been filled has been filled with an incorrect type.

Parameters
fieldNameName of field in dictionary that is incorrectly filled.
inpTypeType of given input.
elemNameName of dictionary where error occurred.
fieldTypeExpected type of input.
Returns
errStr The errorstring.

◆ errMsg_value()

def PyPO.Checks.errMsg_value (   fieldName,
  value,
  elemName 
)

Error message when a wrong input value is encountered.

Parameters
fieldNameName of field where incorrect value is encountered.
valueInput value.
Nameof dictionary where error occurred.
Returns
errStr The errorstring.

◆ getIndex()

def PyPO.Checks.getIndex (   name,
  nameList 
)

Get the regular expression for checking if an object already exists.

Counts the amount of occurrences in order to avoid conflicting names.

Parameters
nameName of object.
nameListList of names to check.
Returns
num Increment of highest occurrence of number.

◆ has_CUDA()

def PyPO.Checks.has_CUDA ( )

Check if the CUDA dynamically linked libraries exist.

Checks the paths for Windows, Linux and Mac OS.