The pyOpTools package is composed by a set of python modules that allow to simulate the behavior of optical systems. Initially it was only oriented to the ray tracing, but currently in the development version it has some tools which can be used to simulate optical fields and their propagation.
This tutorial will introduce the simulation of optical systems by ray tracing in a Jupiter notebook.
In the following video there is a small demo of an old version of pyOpTools
In [ ]:
from IPython.lib.display import YouTubeVideo
YouTubeVideo("DB8sfm7pVPI",width=640,height=480)
The fist step to simulate an optical system in pyOpTools, is to import the package. The most simple way to perform this task is to import the pyoptools.all subpackage:
In [ ]:
from pyoptools.all import *
After the module is imported, a simulation can be performed. In the folowing example we will create a simple system composer by a lens, a detector, and a light source.
As a first step we will create a lens from the Edmund Scientific catalog (reference 32475), we will create a CCD-like sensor with 20 mm X 20 mm size, and a parallel ray source with cartesian beam distribution.
In [ ]:
L=library.Edmund.get("32475")
SEN=CCD(size=(20,20))
R=parallel_beam_c(origin=(0.0, 0.0, 0.0), direction=(0.0, 0.0, 0.0),
size=(10, 10), num_rays=(5, 5), wavelength=0.58929)
with this components created, we will create a system, where the lens is placed at the position (0,0,50) , and the CCD is placed at the position (0,0,150). At the end the Plot3D command will be used to show the resulting system.
Note: The plot obtained with the Plot3D command is interactive. Meaning you can rotate it (left click), zoom it (scroll wheel), and drag it (right click), by clicking on it and moving the mouse.
In [ ]:
S=System(complist=[(L,(0,0,50),(0,0,0)),(SEN,(0,0,150),(0,0,0))],n=1)
Plot3D(S)
After the system is created, we can add the raysource and propagate the system.
In [ ]:
S.ray_add(R)
S.propagate()
Plot3D(S)