pyoptools.raytrace.ray package¶
Module contents¶

class
pyoptools.raytrace.ray.
Ray
¶ Bases:
object
Class to define a ray
ARGUMENTS
pos Tuple (x,y,z) containing the origin of the Ray dir Tuple (x,y,z) containing the direction vector of the Ray intensity Floating point number representing the Intensity of the Ray. Warning: Check how can a physically correct definition can be made wavelength Wavelength (in vacuum) of the ray in micrometers (.58929 by default) n Refraction index of the point originating the ray. If the value is None, the ray was emitted from the media and its Refraction index is taken (not from inside a component) label String used to follow the rays through the system. draw_color Color used to render this ray. If None, the wavelength will be used to determine the color. Otherwise, can be any valid matplotlib color identifier. parent Ray where this ray comes from (used to follow ray trajectory). childs List of rays originated by the interaction of this ray with an optical surface. 
add_child
()¶ Add childs to the current ray, and create the appropriate links
 cr
 Ray to include in the child list

static
almost_equal
()¶ Test if two rays are equal up to desired precision.
ARGUMENTS
other Ray other ray to be compared against. decimal int, optional, Desired precision, default is 7.  RETURN VALUE
 bool True if two rays are equal to the desired precision. i.e.
 if abs(self  other) < 1.5 * 10**(decimal) for attributes pos, dir, wavelength and n.

ch_coord_sys
()¶ Transform the coordinate system of the Ray
Parameters no Tuple (X,Y,Z) containing the coordinates of the origin of the new coordinate system in the old coordinate system ae Tuple (RX,RY,RZ) containing the rotation angles to be applied to the old coordinate system. The rotations are applied RZ first, then RY and last RX
Note this has to be checked

ch_coord_sys_inv
()¶ Transform the coordinate system of the Ray
Parameters
 no
 Tuple (X,Y,Z) containing the coordinates of the origin of the old coordinate system in the new coordinate system
 ae
 Tuple (RX,RY,RZ) containing the rotation angles to be applied to the old coordinate system. The rotations are applied RZ first, then RY and last RX
 childs
 Transform also the coordinate system of the childs. By default (False) don’t do it.
The rotation is made first, and then the translation is made. Note, this has to be checked

ch_coord_sys_inv_f
()¶ Transform the coordinate system of the Ray
Fast version
Parameters
 no
 Tuple (X,Y,Z) containing the coordinates of the origin of the old coordinate system in the new coordinate system
 ae
 Tuple (RX,RY,RZ) containing the rotation angles to be applied to the old coordinate system. The rotations are applied RZ first, then RY and last RX
 childs
 Transform also the coordinate system of the childs. By default (False) don’t do it.
The rotation is made first, and then the translation is made. Note, this has to be checked

childs
¶

copy
()¶ Return a copy ray leaving the parent=None, and childs=[], and order=0

dir
¶

draw_color
¶

get_final_rays
()¶ Find the final rays of the raytrace
 inc_zeros
 If inc_zeros == True, all the child rays are included. If set to false, the rays with intensity==0 are not included

intensity
¶

label
¶

n
¶

optical_path
()¶ Return the optical path of the beam propagation from the origin of the origin ray, to the end of this ray (intersection with a surface)

optical_path_parent
()¶ Return the optical path from the origin of the origin ray to the end of this ray parent (this ray origin)

order
¶

orig_surf
¶

parent
¶

pop
¶

pos
¶

reverse
()¶ Return a copy ray leaving the parent=None, and childs=[], and order=0, and inverting the ray direction.

wavelength
¶


pyoptools.raytrace.ray.
parallel_beam_c
(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0.0), size=(1.0, 1.0), num_rays=(10, 10), wavelength=0.58929, label='', draw_color=None)¶ Cartesian grid parallel beam
This function creates a parallel beam, where the rays are organized in a cartesian grid.
Parameters:
 origin
 Tuple with the coordinates of the central ray origin
 direction
 Tuple with the rotation of the beam around the XYZ axes.
 size
 Tuple with the beam’s width and the height.
 num_rays
 Tuple (nx,ny) containing the number of rays used to create the beam.
 label
 String used to identify the ray source
 draw_color
Color used to represent the rays in plots. Default (None) automatically chooses a color based on the wavelength. Otherwise, can be any valid matplotlib color descriptor. See :

pyoptools.raytrace.ray.
parallel_beam_p
(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0), radius=0.5, num_rays=(5, 10), wavelength=0.58929, label='', draw_color=None)¶ Polar grid parallel beam
This function creates a parallel beam, where the rays are organized in a polar grid.
Parameters:
 origin
 Tuple with the coordinates of the central ray origin
 direction
 Tuple with the rotation of the beam around the XYZ axes.
 r
 Beam radious
 num_rays
 Tuple (nr,na) containing the number of rays used to create the beam.
 label
 String used to identify the ray source
 draw_color
Color used to represent the rays in plots. Default (None) automatically chooses a color based on the wavelength. Otherwise, can be any valid matplotlib color descriptor. See :

pyoptools.raytrace.ray.
point_source_c
(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0), span=(0.39269908169872414, 0.39269908169872414), num_rays=(10, 10), wavelength=0.58929, label='', draw_color=None)¶ Point source, with a cartesian beam distribution
This function creates a point source, where the rays are organized in a cartesian grid.
Parameters:
 origin
 Tuple with the coordinates of the central ray origin
 direction
 Tuple with the rotation of the beam around the XYZ axes.
 span
 Tuple angular size of the ray pencil.
 num_rays
 Tuple (nx,ny) containing the number of rays used to create the beam.
 label
 String used to identify the ray source
 draw_color
Color used to represent the rays in plots. Default (None) automatically chooses a color based on the wavelength. Otherwise, can be any valid matplotlib color descriptor. See :

pyoptools.raytrace.ray.
point_source_p
(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0), span=0.39269908169872414, num_rays=(10, 10), wavelength=0.58929, label='', draw_color=None)¶ Point source, with a polar beam distribution
This function creates a point source, where the rays are organized in a polar grid.
Parameters:
 origin
 Tuple with the coordinates of the central ray origin
 direction
 Tuple with the rotation of the beam around the XYZ axes.
 span
 Tuple angular size of the ray pencil.
 num_rays
 Tuple (nr,na) containing the number of rays used to create the beam # TODO Please be more descriptive. It seems really hard to know how much rays we’ll get in advance. What is nr? # TODO What is na?
 label
 String used to identify the ray source
 draw_color
Color used to represent the rays in plots. Default (None) automatically chooses a color based on the wavelength. Otherwise, can be any valid matplotlib color descriptor. See :

pyoptools.raytrace.ray.
point_source_r
(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0), span=0.39269908169872414, num_rays=100, wavelength=0.58929, label='', draw_color=None)¶ Point source, with a ranrom beam distribution
This function creates a point source, where the rays are organized in a random grid.
Parameters:
 origin
 Tuple with the coordinates of the central ray origin
 direction
 Tuple with the rotation of the beam around the XYZ axes.
 span
 Tuple angular size of the ray pencil.
 num_rays
 Number of rays used to create the beam
 label
 String used to identify the ray source
 draw_color
Color used to represent the rays in plots. Default (None) automatically chooses a color based on the wavelength. Otherwise, can be any valid matplotlib color descriptor. See :