pyoptools.raytrace.system package

Submodules

Module contents

class pyoptools.raytrace.system.IdealThickLens(lens_shape, lens_thickness, principal_plane_positions=(0.0, 0.0), pupil_config=None, focal_length=100, show_internal_rays=False)

Bases: System

Class defined to create an Ideal Thick Lens.

It is implemented as a subsystem because the propagation inside involves multiple rays: first surface -> first principal plane -> second principal plane -> second surface

Parameters:
  • lens_shape (object) – Shape of the lens (shape of both lens surfaces).

  • lens_thickness (float) – Thickness of the lens (distance between the two surfaces).

  • principal_plane_positions (tuple of float, optional) – Principal planes position. The position of each principal plane is measured from its corresponding surface. Default is (0., 0.).

  • pupil_config (tuple or None, optional) –

    Configuration for the pupil. If None, no pupil is defined. Default is None. When provided, it should be a tuple containing: (pupil_distance, pupil_aperture_shape, pupil_reference_surface)

    • pupil_distancefloat

      Distance of the pupil from the reference surface.

    • pupil_aperture_shapeobject

      Shape of the pupil aperture.

    • pupil_reference_surfacebool

      Determines which lens surface is used as the reference for pupil positioning. If True, E1 is the reference surface. If False, E2 is the reference surface.

  • focal_length (float, optional) – Focal length of the lens. Default is 100.

  • show_internal_rays (bool, optional) – If True, the trace between the principal planes will be shown. If False, only the trace from and to the lens surfaces will be exact. Default is False.

Notes

The origin of the component is located at the midpoint between the two lens surfaces.

E1 is positioned at -lens_thickness/2 along the z-axis. E2 is positioned at +lens_thickness/2 along the z-axis.

Rays can travel in either direction through the lens: - For rays traveling in the positive z-direction, E1 is encountered first. - For rays traveling in the negative z-direction, E2 is encountered first.

For the pupil_config parameter:

The pupil_distance is always measured from the reference surface.

When pupil_reference_surface is True (E1 is reference):
  • For rays entering through E1, it acts as an entrance pupil.

  • For rays exiting through E1, it acts as an exit pupil.

  • For rays entering through E2, it acts as an exit pupil.

  • For rays exiting through E2, it acts as an entrance pupil.

When pupil_reference_surface is False (E2 is reference), the roles of E1 and E2 are reversed.

The behavior of the pupil depends on the direction of ray propagation and the reference surface chosen.

TODO: Convert from python to cython everything possible to increase performance

distance(ri)

Calculate the distance to the first intersection with the lens.

Only C1 and C2, which are the entrance and exit surfaces of the system, are taken into account.

Parameters:

ri (Ray) – Incident ray.

Returns:

(distance, intersection point, intersected surface)

Return type:

tuple

propagate_ray(ri)

Propagate a ray through the ideal thick lens.

Parameters:

ri (Ray) – Incident ray to be propagated.

Returns:

The propagated ray with its child rays.

Return type:

Ray

class pyoptools.raytrace.system.System

Bases: Picklable

Class to define an optical system.

The System class defines an optical system as a list of optical components, the coordinates of the component origin, and the rotation angles of such components. To define a system, the refraction index, or the material surrounding the components must also be given in the n attribute.

To avoid recursion errors, two other parameters are given: max_ray_parent and intensity_threshold. See the parameters description to understand their use.

Parameters:
  • complist (list of tuples) – Contains a tuple list that defines the optical system. The first component of the tuple is an instance of the component to include in the system. The second is a tuple with the component location (X, Y, Z). The third is a tuple with the rotation around each axis (rx, ry, rz). The rotations are applied in the order: rz, then ry, and then rx.

  • n (float) – Contains the refraction index of the media where the system is immersed.

  • max_ray_parent (int, optional) – Limits the number of parents and grandparents a ray can have, effectively limiting the number of times a ray can be propagated. This is used to avoid recursion errors in case a resonant cavity is simulated. Default is None, meaning there is no limit for the propagation.

  • intensity_threshold (float, optional) – Another way to limit the number of times a ray is propagated. This is used to avoid recursion errors in case a resonant cavity is simulated. If a ray has an intensity less than the threshold, the ray is not propagated. The intensity value of a ray is reduced each time it is reflected in a beam splitter. Default is 0, meaning there is no limit for the propagation.

Examples

Example of a system containing a doublet and a CCD detector:

# Definition of a doublet type lens
DB1 = Doublet(radius=12.5,
            curvature_as=1./61.47,
            curvature_ms=-1./44.64,
            curvature_ps=-1./129.94,
            thickness_al=6.,
            thickness_pl=2.5,
            material_al=N_BK7,
            material_pl=SF5)

# Definition of a CCD type detector
ccd = CCD()

# Definition of a system
os = System(complist=[(DB1, (20, 0, 200), (0, 0, 0)),
                    (ccd, (20, 0, 400), (0, 0, 0))],
            n=1)
clear()
clear_ray_list()

Clear the ray lists of the system

complist
distance(ri)

Distance length from a ray origin to a subsystem, following the ray path.

Method that calculates the distance traveled by a ray from its origin to the next surface of the component. It returns the physical distance, not the optical distance

Return value

A tuple with the distance, the point of intersection using the coordinate system of the surface, and a pointer to the surface that is closest to the ray (distance,point of intersection, surface)

get_component(path)

Return the component thatis defined using the surface described by path

get_surf_paths()

Method that returns a list that contains the path for each surface.

A path here is a list containing the keys needed to read each surface.

This method is an auxiliary method so this works when called from a System

get_surface(path)

Return a surface, given a path.

A path is given as a list of keys

intensity_threshold
items()
iter()
iteritems()
iterkeys()
itervalues()
keys()
max_ray_parent
merge(os)

Method to merge simulation systems. Useful for joining raytraces that where split for parallel processing.

n
pop(*argv, **argkw)
popitem()
prop_ray
propagate(update_ids=True)

Propagates all the rays in the non propagated list.

propagate_ray(ri)

Method to propagate the ray in the system. It creates the nexts rays and links them using the Ray.parent, and Ray.childs attributes. It calls itself recurrently.

Arguments:

ri

Ray to propagate

Return Value

It returns ri

propagate_ray_ns(gr, dpath)

Method to propagate the ray in the system.

Arguments

gr

Guide ray previously propagated in the system using the non sequential algorithm. This ray contains the surface sequence that the rays must follow.

dpath

Path (key) of the destination surface.

This method uses the same n as the calculated in the non sequential propagation. If the wavelength change, assertion error is raised

ray_add(ray)

Rutina que adiciona un rayo a la lista de rayos primarios del sistema optico. Recibe como parametro una rayo o una lista de rayos. Genera un error si se le pasa algo diferente a un rayo (instancia de la clase Ray, genera una excepcion ‘’’

reset()

Run the reset method on all the components used to create the system

setdefault(*argv, **argkw)
update(*argv, **argkw)
update_ids()

Update the ids for all the surfaces in the system.

This should be done before running a propagation.

values()
viewitems()
viewkeys()
viewvalues()