Post on 16-Oct-2021
ray-opticsRelease 0.7.4+1.g3b2c9ab.dirty
Aug 14, 2021
Contents
1 Introduction 3
2 Installation 5
3 Scripting Usage 7
4 iPython setup code 9
5 Jupyter setup code 11
6 Qt application 13
7 Triplet example 15
8 ThorLabs catalog lens example 23
9 Edmund catalog lens example 35
10 Models and Representations 41
11 Optical Calculations and Analysis 45
12 GUI Layers 47
13 rayoptics package 49
14 Contributors 135
15 License 137
16 Changelog 139
17 Indices and tables 143
Python Module Index 145
Index 147
i
ii
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
RayOptics is a Python geometrical optics and image forming optics library. It provides a geometric ray tracing foun-dation for the analysis of image forming and coherent optical systems. A number of standard geometrical analysisoptions such as transverse ray and wavefront aberration analysis are provided on this base. Paraxial layout of opticalsystems is also supported by 𝑦 − 𝑦 diagrams and graphical editing of paraxial rays in lens layout views. Import ofZemax .zmx and CODEV .seq files is supported. RayOptics can be used in Python scripts, the Python and IPythonshells, the Jupyter notebook, and a Qt-based graphical user interface application.
Contents 1
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
2 Contents
CHAPTER 1
Introduction
1.1 Tools for image forming optical design and analysis
The ray-optics project has several goals, both in the optical domain and in the software development domain
• Rethink how image forming optical calculations are done absent historical constraints on computer speed andmemory
• Investigate interactive graphics for optical design
• Serve as a reference implementation of basic ray tracing and wavefront analysis algorithms
• Leverage extensive Python libraries to avoid reinventing the wheel
• Look for architectures that can be deployed on the desktop (e.g. using Qt), using (Jupyter) notebooks, and inmobile environments
Image forming optical design and analysis was one of the first domain areas to be transferred from the realm ofhuman computers to the first electronic computing machines. The calculations were so voluminous and tedious thatautomation was a tremendous benefit. Because the capabilities of electronic computers were extremely limited, thecomputational workflow was optimized to be maximally efficent for computational effort, paralleling the practice withhuman computers.
Computers are vastly more powerful now than they were when the venerable CODE V program was initially devel-oped. Zemax and Oslo date from the early IBM PC days, when both speed and memory were limiting factors. Theprograms were developed to be comprehensive tools. The software tools available then were limited as well. In order togain acceptable performance, compiled languages such as C and FORTRAN were required. Graphical user interfaceswere also expensive to develop and were often considered secondary in importance to developing a comprehensivefeature set.
The ray-optics project doesn’t aspire to be comprehensive. Instead, it tries to do several dominant use cases very well:
• Rotationally symmetric optical systems
• Bilaterally symmetric optical systems
These two categories represent a vast space of practical imaging and/or coherent optical systems. The reason torestrict the program in this way is simplify the development of an interactive graphic user interface focused on optical
3
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
modeling. These use cases can be represented in 2D with no loss in generality. This offers the potential of significentlysimplified and/or more focused tools for manipulation of optical properties.
The rotationally symmetric case has a rich set of paraxial or first order design methods, in addition to a well developedaberration theory. The interactive optical layout view uses the ideas behind paraxial ray solves to implement graphicalediting operations directly with paraxial rays. Interactive 𝑦 − 𝑦 and 𝜔 − 𝜔 diagrams provide alternative forms ofparaxial design.
In an interactive design environment, the graphical renderings mostly correspond with optical elements, not individualsurfaces (excepting mirrors). The virtue of having an element-based description of the optical model, in parallel witha sequential interface description, is highly leveraged when graphical tools become a focus of the software. It isimportant that either the sequence or the element description be able to generate the other description.
The core analysis operation is geometrical ray tracing through a sequence of optical interfaces.
Optical calculation technology can be considered a mature field. There is a long history in the literature of investi-gations tying optical theory to calculation approaches that maintain accuracy, handle corner cases, etc. Much of thisknowledge is embedded in production optical design software; having it available in an open source implementationbrings this knowledge out of the literature and makes it accessible to students and researchers.
The advent of scripting environments like Python make a fresh look at optical design calculations worthwhile. Pythonhas many advantages for scientific and engineering applications, including libraries for numerical calculations, a va-riety of graphics options including a very full featured plotting library, and support for data science applications thatlook promising for managing data generated during extensive analysis of optical systems. There is also good supportfor unit testing of Python software, as well as debugging and performance profiling.
Finally, computational notebooks, such as those of the Jupyter project, provide the ability to document reproduciblythe implementation of an algorithm and results produced by the algorithm.
4 Chapter 1. Introduction
CHAPTER 2
Installation
To install rayoptics using pip, use
> pip install rayoptics
Alternatively, rayoptics can be installed from the conda-forge channel using conda
> conda install rayoptics --channel conda-forge
5
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
6 Chapter 2. Installation
CHAPTER 3
Scripting Usage
The environment.py module imports many useful classes and functions. All the symbols defined in the moduleare intended to be imported into a rayoptics interactive session.
> from rayoptics.environment import *
Create a new OpticalModel
> opm = OpticalModel()
Alternatively, restore a model from a file
> opm = open_model('ritchey_chretien.roa')
CODE V sequence files can be imported
> opm = open_model('ag_dblgauss.seq')
Zemax .zmx files can be imported
> opm = open_model('US05831776-1.zmx')
Please note that the author doesn’t have access to either CODE V or Zemax so if you find problems with the import,please create an issue in Git-Hub with the problem file and the expected results.
Whether created new or restored from a file, setting up the following names makes reuse of code snippets much easier
> sm = opm.seq_model> osp = opm.optical_spec> pm = opm.parax_model> em = opm.ele_model
7
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
8 Chapter 3. Scripting Usage
CHAPTER 4
iPython setup code
One can use the flow above in the iPython environment. If you want to import fewer things into your iPython environ-ment, you can import just the modules you need:
import numpy as npimport matplotlib.pyplot as pltfrom rayoptics.optical.opticalmodel import OpticalModelfrom rayoptics.gui.appcmds import open_model
# open an OpticalModel from a fileopm = open_model("codev/test/landscape_lens.seq")
# or create a new OpticalModel#opm = OpticalModel()sm = opm.seq_modelosp = opm.optical_specpm = opm.parax_model
9
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
10 Chapter 4. iPython setup code
CHAPTER 5
Jupyter setup code
Depending on whether you are using Jupyter or JupyterLab, you may want to set a particular matplotlib back-end foryour session. If the “out of the box” default isn’t working, you can try changing it at the beginning of your session:
> %matplotlib widget
11
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
12 Chapter 5. Jupyter setup code
CHAPTER 6
Qt application
6.1 Running the app
A desktop application is installed as part of rayoptics. It is invoked by running rayoptics at the command line.
> rayoptics
On a Windows machine, the rayoptics command will be located in a Scripts directory underneath the installdirectory. For example, if using a virtual environment named optics, the command would be
> \optics\Scripts\rayoptics
13
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
14 Chapter 6. Qt application
CHAPTER 7
Triplet example
This triplet design, used in Jose Sasian’s Lens Design OPTI 517 course at the Univ. of Arizona, is attributed to Geiser.
%matplotlib inline
isdark = False
7.1 Setup the rayoptics environment
The environment.py module imports many useful classes and functions. All the symbols defined in the moduleare intended to be imported into a rayoptics interactive session.
from rayoptics.environment import *
7.2 Create a new model
Create a new OpticalModel instance and set up some convenient aliases to important constituents of the model.
opm = OpticalModel()sm = opm['seq_model']osp = opm['optical_spec']pm = opm['parax_model']
7.2.1 Define first order aperture and field for system
The pupil and field specifications can be specified in a variety of ways. The key keyword argument takes a list of 2strings. The first string indicates whether the specification is in object or image space. The second one indicates whichparameter is the defining specification.
15
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
The PupilSpec can be defined in object or image space. The defining parameters can be pupil, f/# or NA, wherepupil is the pupil diameter.
osp['pupil'] = PupilSpec(osp, key=['object', 'pupil'], value=12.5)
The FieldSpec can be defined in object or image space. The defining parameters can be height or angle, whereangle is given in degrees. The is_relative keyword argument may be used to specify fields as a fraction of themaximum value
osp['fov'] = FieldSpec(osp, key=['object', 'angle'], value=20.0, flds=[0., 0.707, 1.],→˓ is_relative=True)
The WvlSpec defines the wavelengths and weights to use when evaluating the model. The wavelength values can begiven in either nanometers or a spectral line designation.
osp['wvls'] = WvlSpec([('F', 0.5), (587.5618, 1.0), ('C', 0.5)], ref_wl=1)
7.2.2 Define interface and gap data for the sequential model
opm.radius_mode = True
sm.gaps[0].thi=1e10
sm.add_surface([23.713, 4.831, 'N-LAK9', 'Schott'])sm.add_surface([7331.288, 5.86])sm.add_surface([-24.456, .975, 'N-SF5,Schott'])sm.set_stop()sm.add_surface([21.896, 4.822])sm.add_surface([86.759, 3.127, 'N-LAK9', 'Schott'])sm.add_surface([-20.4942, 41.2365])
7.2.3 Update the model
opm.update_model()
7.3 Draw a lens picture
layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, is_dark=isdark).→˓plot()
16 Chapter 7. Triplet example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
opm.ele_model.list_elements()
0: Object (DummyInterface): Surface(lbl='Obj', profile=Spherical(c=0.0), interact_→˓mode=dummy)1: Object space (AirGap): Gap(t=10000000000.0, medium=Air())2: Image (DummyInterface): Surface(lbl='Img', profile=Spherical(c=0.0), interact_→˓mode=dummy)3: E1 (Element): Element: Spherical(c=0.042170961076202926), Spherical(c=0.→˓00013640168003221264), t=4.8310, sd=10.0087, glass: N-LAK94: AG1 (AirGap): Gap(t=5.86, medium=Air())5: E2 (Element): Element: Spherical(c=-0.04088976120379457), Spherical(c=0.→˓04567044208987943), t=0.9750, sd=4.7919, glass: N-SF56: AG2 (AirGap): Gap(t=4.822, medium=Air())7: E3 (Element): Element: Spherical(c=0.011526181721781025), Spherical(c=-0.→˓04879429301948844), t=3.1270, sd=8.3321, glass: N-LAK98: Image space (AirGap): Gap(t=41.2365, medium=Air())
7.4 Draw a 𝑦 − 𝑦 diagram
yybar_plt = plt.figure(FigureClass=InteractiveDiagram, opt_model=opm, dgm_type='ht',do_draw_axes=True, do_draw_frame=True, is_dark=isdark).plot()
7.4. Draw a 𝑦 − 𝑦 diagram 17
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
7.5 Plot the transverse ray aberrations
abr_plt = plt.figure(FigureClass=RayFanFigure, opt_model=opm, data_type='Ray', scale_→˓type=Fit.All_Same, is_dark=isdark).plot()
18 Chapter 7. Triplet example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
7.6 Plot the wavefront aberration
wav_plt = plt.figure(FigureClass=RayFanFigure, opt_model=opm, data_type='OPD', scale_→˓type=Fit.All_Same, is_dark=isdark).plot()
7.7 List the optical specifications
pm.first_order_data()
efl 50ffl -37.1pp1 12.9bfl 41.24ppk 8.763f/# 4m -5e-09red -2e+08obj_dist 1e+10obj_ang 20enp_dist 11.68enp_radius 6.25na obj 6.25e-10n obj 1img_dist 41.24img_ht 18.2exp_dist -10.01exp_radius 6.406na img -0.124n img 1optical invariant 2.275
7.6. Plot the wavefront aberration 19
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
7.8 List the paraxial model
pm.list_lens()
ax_ray_ht ax_ray_slp0: 0 6.25e-101: 6.25 -0.1821262: 5.72969 -0.1815863: 4.66559 -0.05325084: 4.63455 0.08913575: 5.06436 0.04886: 5.1546 -0.1249987: 0.000143648 -0.124998
pr_ray_ht pr_ray_slp0: -3.6397e+09 0.363971: -4.25088 0.4878422: -2.85718 0.4875733: 3.53405e-07 0.4875734: 0.2842 0.4963045: 2.67738 0.474986: 3.55571 0.3550927: 18.1985 0.355092
power tau index type0: 0 1e+10 1.00000 dummy1: 0.02914022 2.8569 1.69100 transmit2: -9.425384e-05 5.86 1.00000 transmit3: -0.02750683 0.58289 1.67271 transmit4: -0.03072283 4.822 1.00000 transmit5: 0.007964615 1.8492 1.69100 transmit6: 0.03371696 41.236 1.00000 transmit7: 0 0 1.00000 dummy
7.9 Third Order Seidel aberrations
7.9.1 Computation and tabular display
to_pkg = compute_third_order(opm)to_pkg
7.9.2 Bar chart for surface by surface third order aberrations
fig, ax = plt.subplots()ax.set_xlabel('Surface')ax.set_ylabel('third order aberration')ax.set_title('Surface by surface third order aberrations')to_pkg.plot.bar(ax=ax, rot=0)ax.grid(True)fig.tight_layout()
20 Chapter 7. Triplet example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
7.9.3 convert aberration sums to transverse measure
ax_ray, pr_ray, fod = osp.parax_datan_last = pm.sys[-1][mc.indx]u_last = ax_ray[-1][mc.slp]to.seidel_to_transverse_aberration(to_pkg.loc['sum',:], n_last, u_last)
TSA -0.043893TCO 0.010944TAS -0.015198SAS -0.101860PTB -0.145190DST 0.018387dtype: float64
7.9.4 convert sums to wavefront measure
central_wv = opm.nm_to_sys_units(sm.central_wavelength())to.seidel_to_wavefront(to_pkg.loc['sum',:], central_wv).T
W040 2.334457W131 -0.776108W222 -9.218154W220 10.834770W311 -3.911650dtype: float64
7.9. Third Order Seidel aberrations 21
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
7.9.5 compute Petzval, sagittal and tangential field curvature
to.seidel_to_field_curv(to_pkg.loc['sum',:], n_last, fod.opt_inv)
TCV 0.000734SCV 0.004921PCV 0.007014dtype: float64
7.10 Save the model
opm.save_model('Sasian Triplet')
22 Chapter 7. Triplet example
CHAPTER 8
ThorLabs catalog lens example
This notebook shows the steps to follow to open a Zemax zmx file of a ThorLabs aspheric singlet
%matplotlib inline
# initializationfrom rayoptics.environment import *
8.1 Use the object oriented filesystem interface from Python 3
root_pth = Path(rayoptics.__file__).resolve().parent
8.2 Read Zemax .zmx file for ThorLabs part 354710-C
Use the open_model() function to read Zemax .zmx files, CODE V .seq files and the native rayoptics JSON files,.roa
It returns an instance of OpticalModel that contains all of the model data.
Use the info keyword argument to get additional information about the details of the imported file.
The webpage for the 354710-C aspheric lens is here
opm, info = open_model(root_pth/"zemax/tests/354710-C-Zemax(ZMX).zmx", info=True)
info is a tuple of the following items:
• the track_contents dict
• glasses not found dict
23
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
info
({'VERS': '140124 258 36214','pupil': ('aperture', 'object', 'pupil'),'FTYP': '0 0 1 1 0 0 0','STANDARD': 5,'EVENASPH': 1,'CONI': 1,'conj type': 'infinite','# surfs': 6,'# wvls': 1,'fov': ('field', 'object', 'angle'),'# fields': 1,'GCAT': ['LIGHTPATH', 'SCHOTT'],'glass not found': 1,'glass substituted': 1,'encoding': 'utf-16'},
{'D-ZK3M': 1, 'BK7': "create_glass('N-BK7','Schott')"})
The second dict indicates that there were two glasses in the model file that are not in the glass catalog set that ray-opticsuses from the opticalglass package. There is a file called 354710-C-Zemax(ZMX)_tmpl.smx that contains the glassesnot found dict dict.
One is a substitute material. One of the glasses was named BK7, and that’s not an exact match in the current Schottcatalog. But there is a similar glass N-BK7, and what the import process did was substitute that glass for the BK7glass.
The other glass here isn’t in any of the ray-optics catalogs, and it apparently is from the LightPath catalog, as indicatedby the ‘GCAT’ key in the track contents dict. A web search leads to this D-ZK3M datasheet.
One thing of importance is what wavelength this material is going to be used. The usual convenient way of specifyingan optical glass with the index and V number is really only adequate in the visible wavelengths. In this case, the lensfile is going to be used in the infrared, at 1550 nanometers. Fortunately there are adequate data points for the materialdefinition in the IR.
The best approach to using the available data is to interpolate refractive index values from the refractive index tablein the datasheet. There is a material model in the medium package called InterpolatedGlass that takes a glassname, a catalog name, and a list of wavelength/refractive index pairs. The template .smx file is edited with newInterpolatedGlass definition for D-ZK3M and saved with the same name as the .zmx file but with a .smx extender. Thetemplate file can be deleted, because it’s no longer needed.
The name of this file should be the same as the name of the original Zemax file. But instead of an extender of zmxuse an extender of smx, so when we do that, we now have an smx file right next to it. We can delete the template file,because that’s no longer needed.
Open the model again.
opm, info = open_model(root_pth/"zemax/tests/354710-C-Zemax(ZMX).zmx", info=True)
info
({'VERS': '140124 258 36214','pupil': ('aperture', 'object', 'pupil'),'FTYP': '0 0 1 1 0 0 0','STANDARD': 5,'EVENASPH': 1,'CONI': 1,
(continues on next page)
24 Chapter 8. ThorLabs catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
(continued from previous page)
'conj type': 'infinite','# surfs': 6,'# wvls': 1,'fov': ('field', 'object', 'angle'),'# fields': 1,'GCAT': ['LIGHTPATH', 'SCHOTT'],'encoding': 'utf-16'},
{'BK7': "create_glass('N-BK7','Schott')",'D-ZK3M': "InterpolatedGlass('D-ZK3M', cat='LightPath', pairs=[(2352.4, 1.555),
→˓(1970.1, 1.561),(1529.6, 1.568),(1128.6, 1.573),(1014.0, 1.575),(852.1, 1.578),(706.→˓5, 1.582),(656.3, 1.583),(643.8, 1.584),(632.8, 1.584),(589.3, 1.586),(587.6,1.586),→˓(546.1, 1.589),(486.1, 1.593),(480.0, 1.594),(435.8, 1.598),(404.7, 1.602),(365.0,→˓1.610)])"})
Examining the info, The InterpolatedGlass definition for D-ZK3M is being used as well as the N-BK7 substitution forBK7. All of the flags for glass not found or glass substituted have been resolved.
Setup convenient aliases for using rayoptics functions
sm = opm['seq_model']osp = opm['optical_spec']pm = opm['parax_model']
osp['wvls'].wavelengths
[1550.0]
sm.list_model()
c t medium mode zdr sdObj: 0.000000 1.00000e+10 air 1 0.0000
Stop: 1.182174 0.862527 D-ZK3M 1 0.750002: 0.000000 0.523243 air 1 0.574173: 0.000000 0.250000 N-BK7 1 0.249174: 0.000000 0.249999 air 1 0.15527
Img: 0.000000 0.00000 1 8.9134e-06
8.3 Display first order properties of the model
The calculated first order data is in the FirstOrderData class. An instance of FirstOrderData,parax_data, is managed by the OpticalSpecs class.
Other essential optical specification data is also managed by the OpticalSpecs class:
• spectral_region (WvlSpec)
• pupil (PupilSpec)
• field_of_view (FieldSpec)
• defocus (FocusRange)
A convenience method in ParaxialModel, first_order_data(), can be used to display the first order prop-erties of the model.
8.3. Display first order properties of the model 25
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
pm.first_order_data()
efl 1.49ffl -1.49pp1 -0bfl 0.2499ppk 1.24f/# 0.9933m -1.49e-10red -6.712e+09obj_dist 1e+10obj_ang 1enp_dist -0enp_radius 0.75na obj 7.5e-11n obj 1img_dist 0.2499img_ht 0.02601exp_dist -1.24exp_radius 0.75na img -0.4496n img 1optical invariant 0.01309
8.4 Generate a lens picture
This is done using the interactivelayout module. All graphics in rayoptics are based on matplotlib.
layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm,do_draw_rays=True, do_paraxial_layout=False).plot()
26 Chapter 8. ThorLabs catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
8.5 Draw a transverse ray aberration plot
This is done using the axisarrayfigure module.
abr_plt = plt.figure(FigureClass=RayFanFigure, opt_model=opm, data_type='Ray',scale_type=Fit.All_Same).plot()
8.5. Draw a transverse ray aberration plot 27
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
The model from ThorLabs only had 1 wavelength defined. Use the OpticalSpecs instance, osp, to modify thespectral_region in the optical subpackage to add wavelengths in the red and blue. The wavelenghts can bespecified directly in nm or by using spectral line designations.
osp['wvls'].set_from_list([[1050., 1], [1550., 2], [1700., 1]])osp['wvls'].reference_wvl = 1
osp['wvls'].wavelengths
[1050.0, 1550.0, 1700.0]
After changing the wavelengths, update the optical model using update_model() to ensure all of the data isconsistent. The OpticalModel class is in the opticalmodel module in the optical subpackage.
opm.update_model()
The aberration plot can be updated by calling refresh() on abr_plt
abr_plt.refresh()
28 Chapter 8. ThorLabs catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
List the model, and use an alternate model listing command, list_sg, for “list surface and gap”. This is useful becauseit will allow us to look at element decenters or surface decenters in our model.
sm.list_model()
c t medium mode zdr sdObj: 0.000000 1.00000e+10 air 1 0.0000
Stop: 1.182174 0.862527 D-ZK3M 1 0.750002: 0.000000 0.523243 air 1 0.574173: 0.000000 0.250000 N-BK7 1 0.249174: 0.000000 0.249999 air 1 0.15527
Img: 0.000000 0.00000 1 8.9134e-06
sm.list_sg()
c mode type y alphat medium
Obj: 0.000001.00000e+10 air
Stop: 1.182170.862527 D-ZK3M
2: 0.000000.523243 air
3: 0.000000.250000 N-BK7
4: 0.000000.249999 air
Img: 0.00000
So we just take a quick look at what the actual surface definition is. We see the first surface has an even polynomial: asphere with a conic constant, and aspheric coefficients, up to 12th order, and it’s a transmitting surface.
repr(sm.ifcs[1])
8.5. Draw a transverse ray aberration plot 29
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
'Surface(profile=EvenPolynomial(c=1.1821736792829385, cc=-0.4776343430417, coefs=[0.0,→˓ -0.006313587842251, -0.009394960901464, -0.01707674864971, 0.008070222726967, -0.→˓02139444912229, 0.0, 0.0]), interact_mode=transmit)'
Now add decentered surfaces to both the first and the second surface of the lens element. These surfaces are definedas a local decenter type and a reverse decenter. A local decenter applies a translation first, and then a rotation, wherasthe reverse decenter applies the reverse: the inverse of the rotation matrix, and then subtracting the translation.
sm.ifcs[1].decenter = srf.DecenterData(DecenterType.LOCAL)sm.ifcs[2].decenter = srf.DecenterData(DecenterType.REV)
Listing the model shows the decentered parameters.
sm.list_sg()
c mode type y alphat medium
Obj: 0.000001.00000e+10 air
Stop: 1.18217 LOCAL 0.0000 0.00000.862527 D-ZK3M
2: 0.00000 REV 0.0000 0.00000.523243 air
3: 0.000000.250000 N-BK7
4: 0.000000.249999 air
Img: 0.00000
The decenter is defined by a translation, the tilt is defined by alpha, beta, and gamma euler angles. The euler angleswill be converted into a rotation matrix. So, this information gives you a translation and a rotation matrix.
sm.ifcs[1].decenter
'LOCAL': Decenter: array([0., 0., 0.]), Tilt: array([0., 0., 0.])
To laterally offset the lens element in the y direction, say by 0.2 millimeters, set the second element of the translationvector of each of the surfaces to 0.2. And because the second surface is a reverse decenter we’ll see that the opticalaxis comes back to the original position. So now we’ve decentered the surfaces we see that the y component value is0.2.
sm.ifcs[1].decenter.dec[1] = .2sm.ifcs[2].decenter.dec[1] = .2
sm.list_sg()
c mode type y alphat medium
Obj: 0.000001.00000e+10 air
Stop: 1.18217 LOCAL 0.20000 0.00000.862527 D-ZK3M
2: 0.00000 REV 0.20000 0.00000.523243 air
3: 0.00000
(continues on next page)
30 Chapter 8. ThorLabs catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
(continued from previous page)
0.250000 N-BK74: 0.00000
0.249999 airImg: 0.00000
When perturbing the lens position, we want the ray bundle to stay directed along the axis. So we want to separate thedefinition of the stop surface from the first surface, and put the stop on a dummy plane in front of the lens element. Sowhen the lens element is laterally shifted, the stop plane, which is what the rays are aimed at, will stay the same.
Add a dummy plane, following the object surface. I’ll list the model, and we see here, the dummy plane, and thecurrent surface should be the surface that we did the insert at so that’s surface one, and we want to set the stop to thecurrent surface. And when we redo the listing, we see the stop is moved to the dummy plane. We have laterally offsetthe second and third surfaces by an amount of 0.2,
opm.add_dummy_plane(idx=0)
sm.list_sg()
c mode type y alphat medium
Obj: 0.000001.00000e+10 air
1: 0.000000.00000 air
Stop: 1.18217 LOCAL 0.20000 0.00000.862527 D-ZK3M
3: 0.00000 REV 0.20000 0.00000.523243 air
4: 0.000000.250000 N-BK7
5: 0.000000.249999 air
Img: 0.00000
sm.cur_surface
1
sm.set_stop()
1
sm.list_sg()
c mode type y alphat medium
Obj: 0.000001.00000e+10 air
Stop: 0.000000.00000 air
2: 1.18217 LOCAL 0.20000 0.00000.862527 D-ZK3M
3: 0.00000 REV 0.20000 0.0000
(continues on next page)
8.5. Draw a transverse ray aberration plot 31
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
(continued from previous page)
0.523243 air4: 0.00000
0.250000 N-BK75: 0.00000
0.249999 airImg: 0.00000
Now update the model and redraw the layout. Note that the lens element has shifted upward by 0.2 millimeters. Theoriginal ray fan is is unperturbed in object space but note that it gets deflected off axis, and in fact the aberration islarge enough that flare is visible, even on the lens layout.
opm.update_model()
layout_plt.refresh()
Now refresh the aberration plot to see what the aberrations look like now. Notice the scale size is now about two anda half times larger than it was just previously. Across the center of the aperture you’re pretty well corrected but thereis some flare occurring at the lower edge of the aperture.
abr_plt.refresh()
32 Chapter 8. ThorLabs catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
8.5. Draw a transverse ray aberration plot 33
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
34 Chapter 8. ThorLabs catalog lens example
CHAPTER 9
Edmund catalog lens example
This notebook shows the steps to follow to open a CODE V seq file of a Edmund achromatic doublet.
%matplotlib inline
# initializationfrom rayoptics.environment import *
9.1 Use the object oriented filesystem interface from Python 3
root_pth = Path(rayoptics.__file__).resolve().parent
9.2 Read CODE V seq file for Edmund part 32-327, Achromatic Lens
Use the open_model() function to read CODE V .seq files, Zemax .zmx files, and the native rayoptics JSON files,.roa
It returns an instance of OpticalModel that contains all of the model data.
opm = open_model(root_pth/"codev/tests/CODV_32327.seq")
Setup convenient aliases for using rayoptics functions
sm = opm['seq_model']osp = opm['optical_spec']pm = opm['parax_model']
sm.list_model()
35
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
r t medium mode zdr sdObj: 0.000000 1.00000e+13 air 1 0.0000
32327: 61.470000 6.00000 N-BK7 1 12.0002: -44.640000 2.50000 N-SF5 1 12.2893: -129.940000 95.9519 air 1 12.000
Img: 0.000000 0.00000 1 0.0046062
9.3 Display first order properties of the model
The calculated first order data is in the FirstOrderData class. An instance of FirstOrderData,parax_data, is managed by the OpticalSpecs class.
Other essential optical specification data is also managed by the OpticalSpecs class:
• spectral_region (WvlSpec)
• pupil (PupilSpec)
• field_of_view (FieldSpec)
• defocus (FocusRange)
A convenience method in ParaxialModel, first_order_data(), can be used to display the first order prop-erties of the model.
pm.first_order_data()
efl 100ffl -98.58pp1 1.451bfl 95.95ppk 4.079f/# 4.001m -1e-11red -9.997e+10obj_dist 1e+13obj_ang 1enp_dist -0enp_radius 12.5na obj 1.25e-12n obj 1img_dist 95.95img_ht 1.746exp_dist -5.551exp_radius 12.68na img -0.124n img 1optical invariant 0.2182
9.4 Generate a lens picture
This is done using the interactivelayout module. All graphics in rayoptics are based on matplotlib.
36 Chapter 9. Edmund catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm,do_draw_rays=True, do_paraxial_layout=False).plot()
9.5 Draw a transverse ray aberration plot
This is done using the axisarrayfigure module.
abr_plt = plt.figure(FigureClass=RayFanFigure, opt_model=opm, data_type='Ray',scale_type=Fit.All_Same).plot()
9.5. Draw a transverse ray aberration plot 37
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
The model in the CODE V seq file only had 1 wavelength defined. Use the OpticalSpecs instance, osp, to modifythe spectral_region in the optical subpackage to add wavelengths in the red and blue. The wavelenghts can bespecified directly in nm or by using spectral line designations, as done here.
osp['wvls'].set_from_list([['F', 1], ['d', 2], ['C', 1]])osp['wvls'].reference_wvl = 1
osp['wvls'].wavelengths
[486.1327, 587.5618, 656.2725]
After changing the wavelengths, update the optical model using update_model() to ensure all of the data isconsistent. The OpticalModel class is in the opticalmodel module in the optical subpackage.
opm.update_model()
The aberration plot can be updated by calling refresh() on abr_plt
abr_plt.refresh()
38 Chapter 9. Edmund catalog lens example
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
9.5. Draw a transverse ray aberration plot 39
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
40 Chapter 9. Edmund catalog lens example
CHAPTER 10
Models and Representations
10.1 Optical Model
10.1.1 Overview
The OpticalModel serves as a top level container of model properties. Key aspects are built-in se-quential surface, paraxial and element based representations of the optical model. Each representationcan be used build and modify the optical model.
For design and analysis of image forming systems, the sequential surface model is often the most directmethod for specifying an optical system. The SequentialModel describes a sequence of Interfacesand Gaps that light propagates through to form an image. First order properties and ray tracing can bedone directly with this representation. It is straightforward to produce an element based representationfrom the SequentialModel in many cases. Changes in the SequentialModel can be propagatedto the peer models in the OpticalModel by calling update_model() on OpticalModel.
A SequentialModel is a high fidelity representation of the geometry and optical properties of theoptical model. In contrast, the ParaxialModel is obtained by assuming all optical ray angles are smallso that trigonometric relationships can be replaced by the angles themselves. This enables deriving theconstructional parameters from paraxial ray specifications. This can be done using paraxial ray solvesand/or 𝑦 − 𝑦 and 𝜔 − 𝜔 diagrams.
Finally, the physical model of the components is managed in the ElementModel class. A major re-quirement is the elements be able to render themselves in a 2D drawing view. It is planned to use thegrouping of interfaces into elements to allow 𝑦 − 𝑦 diagram to collapse individual nodes for interfacesinto a single node for elements or groups of elements. It should also be possible in the future to raytrace the ElementModel to generate a SequentialModel corresponding to a ray’s path through theelements.
The OpticalSpecs class holds the optical usage definition of the model. Aperture, field of view,wavelength, and focal position are all aspects of the OpticalSpecs. The first order properties arecalculated and maintained by OpticalSpecs in the parax_data variable. The usage specificationof the optical model is given by the SpecSheet class in combination with the OpticalSpecs class.
41
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Paraxial layout operations are handled via the ParaxialModel. This enables model manipulation viathe 𝑦 − 𝑦 or 𝜔 − 𝜔 diagrams. The goal is to smoothly integrate the information in the SpecSheet withconstraints on movement in the 𝑦 − 𝑦 diagram or changes to the paraxial rays in the Optical Layout.
The system units and other information is contained in the SystemSpec class. It is the system_specattribute in OpticalModel.
10.2 Sequential Model
10.2.1 Overview
The SequentialModel abstracts the essential parts of a physical optical system when using ray tracingto compute imaging performance. For rotationally symmetric optical systems, this requires a minimumof information: a list of curvature, thickness, and refractive index. Similarly, the needs of ray tracing forperformance evaluation is satisfied by the sequence of optical surfaces involved in image formation.
A sequential optical model is a sequence of interfaces and gaps. The first interface is the object surfaceand the last is the image surface. Light propagates sequentially through the interfaces and gaps.
10.2.2 Structure
The sequential model has this structure:
IfcObj Ifc1 Ifc2 Ifc3 ... IfcN-1 IfcN IfcImg\ / \ / \ / \ / \ /GObj G1 G2 GN-1 GImg
where
• Ifc is a Interface instance
• G is a Gap instance
A complete SequentialModel mates a top level assembly with an Object space and Image space. Anadvantage of this structure is that it facilitates the substitution of one set of interfaces for another. A toplevel view of a SequentialModel looks like this:
IfcObj System IfcImg\ / \ /GObj GImg
The Object space consists of an object interface and object gap, with Image space similarly constituted.Note that the Image gap is associated with the Image surface, not the final System interface. Thismakes editing operations such as inserting or replacing elements straightforward. The user view (e.g.list_model() still groups the image thickness with the final interface, with no loss of generality.
Sub-assemblies are defined by N interfaces and N-1 gaps. The low level view of System looks like this:
Ifc1 Ifc2 Ifc3 ... IfcN-1 IfcN\ / \ / \ /G1 G2 GN-1
The low level view might be easier to manipulate at an intermediate level of detail. For example, aTelescope might be represented as:
42 Chapter 10. Models and Representations
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
IfcObj Telescope IfcImg\ / \ /GObj GImg
where the Telescope is:
Objective Eyepiece\ /GSep
and GSep is the gap separating the Objective and the Eyepiece.
10.2.3 Constituents
The Interface API supports implementation of an optical action, such as refraction, reflection, scatter,diffraction, etc. The Interface may be realized as a physical profile separating the adjacent gaps or anidealized object, such as a thin lens or 2 point HOE.
The Gap class maintains a simple separation (z translation) and the medium filling the gap. More complexcoordinate transformations are handled through the Interface API.
The medium in the Gap is provided via classes that implement rindex(). For simple modeling, themedium provides constant refractive index classes for Air and Glass.
If you have a list of refractive indices and their corresponding wavelengths (in nm), you can use theInterpolatedGlass class. This uses the scipy routine interp1d to interpolate the data.
Commercial optical glasses are supported by the opticalglass package.
10.2.4 Sequential Paths
The combination of Interfaces and Gaps completely define the path of a ray through the optical model.For convenience and efficiency when doing optical calculations, it is useful to extract a subset of data thatis required for ray tracing. The method path() in SequentialModel returns a Python generator thatis used to drive the ray tracing process.
10.3 Optical Usage Specification
10.3.1 Optical Specification Overview
The OpticalSpecs class holds the optical usage definition of the model. Aperture, field of view,wavelength, and focal position are all aspects of the OpticalSpecs.
The first order properties are calculated and maintained by OpticalSpecs in the parax_datavariable. This is an instance of ParaxData that includes the paraxial axial and chief rays, and theFirstOrderData that contains first order properties.
The optical configuration is broken into four parts:
* aperture
* field of view
* spectral region
* focus range
10.3. Optical Usage Specification 43
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
The pupil and field specifications can be specified in a variety of ways. The key keyword argument takesa list of 2 strings. The first string indicates whether the specification is in object or image space. Thesecond one indicates which parameter is the defining specification.
The PupilSpec class maintains the aperture specification. The PupilSpec can be defined in object orimage space. The defining parameters can be pupil, f/# or NA, where pupil is the pupil diameter.
osp.pupil = PupilSpec(osp, key=['object', 'pupil'], value=12.5)
The PupilSpec class allows rays to be specified as fractions of the pupil dimension. A list of pupil_raysand ray_labels define rays to be used to establish clear aperture dimensions on optical elements and raysto be drawn for the lens layout. A default set of pupil rays is provided that is appropriate for circular pupilsystems with plane symmetry.
The FieldSpec can be defined in object or image space. The defining parameters can be height orangle, where angle is given in degrees.
osp.field_of_view = FieldSpec(osp, key=['object', 'angle'], flds=[0., 20.0])
The FieldSpec maintains a list of Field instances. Each Field contains an absolute field spec-ification of the type specified in FieldSpec. It can also have attributes set for the chief ray dataat the field (chief_ray) as well as the definition of the reference sphere for OPD calculations(ref_sphere). These are calculated by analyses.get_chief_ray_pkg() and analyses.setup_exit_pupil_coords() respectively.
The WvlSpec defines the wavelengths and weights to use when evaluating the model. The wavelengthvalues can be given in either nanometers or a spectral line designation.
osp.spectral_region = WvlSpec([('F', 0.5), (587.5618, 1.0), ('C', 0.5)], ref_→˓wl=1)
The FocusRange defines the amount of defocus and, optionally, focal range to use when evaluating themodel.
osp.defocus = FocusRange(focus_shift=0.01)
44 Chapter 10. Models and Representations
CHAPTER 11
Optical Calculations and Analysis
11.1 Paraxial Design Model
11.1.1 Overview
Paraxial layout operations are handled via the ParaxialModel. This enables model manipulation viathe 𝑦 − 𝑦 or 𝜔 − 𝜔 diagrams.
Optical layout is facilitated by being able to use paraxial properties to solve for constructional parameters.
11.2 Ray Tracing
11.2.1 Ray Tracing Overview
Real Ray Tracing is a fundamental operation in optical design and analysis. Ray-optics has a layeredarchitecture for the ray trace engine. The low level interface can be used directly or through higher levelinterfaces.
The low level trace_raw() function is the building block of the ray trace system, based on Spencer andMurty’s General Ray-Tracing Procedure. The first argument to this function is an iterator that returns atuple of interface, gap, refractive index, transform to the next interface and a z direction. This informationis sufficent to satisfy the input requirements of the ray trace algorithm.
The Interface API is used extensively by the ray trace. The following methods are required by theray trace:
• intersect(): intersect input ray with Interface
• normal(): return surface normal at input point
• phase(): return output direction and path increment
The following attributes of Interface are used:
45
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• interact_mode: reflect | transmit | dummy (no action)
• decenter: DecenterData for the Interface, if any
Ray tracing is two operations, repeated until reaching the image. They are:
• find the next ray-interface intersection
• scatter the ray based on the interface properties
Sequential models of optical systems make the first operation very straightforward. No search for the nextclosest surface is performed, rather, the sequence of the interfaces is used to determine the next surfaceinterface to calculate. Sequential models also have only one dominant optical behavior per interface. Thismeans there will be a one to one relationship between the incident and exiting rays from an interface.
Sequential ray tracing in ray-optics by default is configured to ray trace the seq_model of theOpticalModel. The trace() function is the low level interface to the ray trace system. It’s ar-guments include a SequentialModel and the ray starting point, direction and wavelength.
The trace_raw() function is the building block of the ray trace system. The first argument to thisfunction is an iterator that returns a tuple of interface, gap, refractive index, transform to the next interfaceand a z direction. Python provides a generator capability that could be used to programmatically generatea sequence of interfaces, for example for a ghost image analysis, without explicitly constructing a list ofinterfaces. The method path() in SequentialModel returns a Python generator that is used to drivethe ray tracing process.
46 Chapter 11. Optical Calculations and Analysis
CHAPTER 12
GUI Layers
12.1 Generic GUI Overview
The appmanager.AppManager manages connections between a model and a UI view. It is purposelylightweight, relying on window manager support for most windowing functions. The refresh_gui()function provides a means of synchronizing model changes across all UI views associated with that model.
The AppManager supports multiple open models at the same time. The model attribute corresponds tothe model for the active UI view.
12.2 Matplotlib Support
Many forms of graphics can be supported portably by using the matplotlib package.
• 2D lens layout graphics
• Aberration plots for transverse ray aberrations and wavefront aberrations
• Wavefront maps
• Interactive 𝑦 − 𝑦 and 𝜔 − 𝜔 diagrams
12.3 Qt application
12.3.1 Qt5 app version of rayoptics
The qtgui subpackage provides a desktop app, rayopticsapp. It provides an integration of rayopticswith the Qt GUI toolkit. Capabilities include:
• an interface that hosts matplotlib graphics
• a table grid for numeric model displays (template-based)
47
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• docking panel support for python objects
• iPython console window (desktop app only)
12.3.2 Running the app
A desktop application is installed as part of rayoptics. It is invoked by running rayoptics at the command line.
> rayoptics
On a Windows machine, the rayoptics command will be located in a Scripts directory underneath the installdirectory. For example, if using a virtual environment named optics, the command would be
> \optics\Scripts\rayoptics
48 Chapter 12. GUI Layers
CHAPTER 13
rayoptics package
The ray-optics geometrical ray tracing and optical modeling and analysis package
The optical model is contained in the optical subpackage. It is supported by the following subpackages:
• seq: support for the Sequential model
• raytr: support for ray tracing and analysis
• parax: support for paraxial optical design
• oprops: optical property and actions
• elem: support for the Element model
• codev: handles import of CODE V .seq files
• opticalglass: this package interfaces with glass manufacturer optical data
The gui subpackage is a layer that implements the platform neutral part of the graphical user interface.
The mpl subpackage implements a variety of plotting/charting based graphics using the matplotlib package. Theqtgui subpackage implements a desktop ui style application using Qt featuring interactive layouts and diagrams.
The util subpackage provides a variety of different math and other miscellaneous calculations.
13.1 Subpackages
13.1.1 rayoptics.codev package
package to read a CODE V sequence file and produce a rayoptics OpticalModel
Submodules
49
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.codev.cmdproc module
Functions to read a CODE V .seq file and populate a sequential model
fictitious_glass_decode(gc)glass code parser, allowing for greater precision of n and v
read_lens(filename, **kwargs)given a CODE V .seq filename, return an OpticalModel
Parameters
• filename (pathlib.Path) – a CODE V .seq file path
• kwargs (dict) – keyword args passed to the reader functions
Returns an OpticalModel instance and a info tuple
process_command(cmd)
log_cmd(label, tla, qlist, dlist)
post_process_input(opt_model, filename, **kwargs)
wvl_spec_data(optm, tla, qlist, dlist)
pupil_spec_data(optm, tla, qlist, dlist)
field_spec_data(optm, tla, qlist, dlist)
spec_data(optm, tla, qlist, dlist)
get_index_qualifier(seq_model, qtype, qlist)
surface_cmd(opt_model, tla, qlist, dlist)
update_surface_and_gap(opt_model, dlist, idx=None)
private_catalog(optm, tla, qlist, dlist)
surface_data(optm, tla, qlist, dlist)
update_surface_profile(seq_model, profile_type, idx=None)
profile_data(optm, tla, qlist, dlist)
aperture_data(opm, tla, qlist, dlist)add aperture data, either creating a new aperture or modifying the last
aperture_data_general(opm, tla, qlist, dlist)handle the general aperture commands, add to end of list
aperture_offset(opm, tla, qlist, dlist)handle the aperture offset commands, assume last aperture in list
decenter_data(optm, tla, qlist, dlist)
diffractive_optic(optm, tla, qlist, dlist)
class CVGlassHandler(filename)Bases: rayoptics.seq.medium.GlassHandlerBase
Handle glass restoration during CODEV import.
This class relies on GlassHandlerBase to provide most of the functionality needed to find the requested glass ora substitute.
process_glass_data(glass_data)
50 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.codev.reader module
Support for reading CODE V .seq files
tokenize_command(cmd)
next_line(it)
strip_comments(textLine)
read_seq_buffer(inputLines, tokenize=True)
read_seq_file(filename, tokenize=True)
rayoptics.codev.tla module
Support for CODE V TLAs
class MapTLABases: object
Create and maintain a dictionary of CODE V 3 letter commands
find(tla)
13.1.2 rayoptics.elem package
Package providing support for element based optical modeling
The elem subpackage provides classes and functions for element based models and rendering. These include:
• Element based model, elements
• Geometric constituents including profiles and surface
• Lens layout and rendering support layout
• Coordinate transformation support transform
The element model is managed by the ElementModel class
Submodules
rayoptics.elem.elements module
Module for element modeling
class GraphicsHandle(polydata, tfrm, polytype, color)Bases: tuple
colorRGBA for the polydata or None for default
polydatapoly data in local coordinates
polytype‘polygon’ (for filled) or ‘polyline’
tfrmglobal transformation for polydata
13.1. Subpackages 51
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
create_thinlens(power=0.0, indx=1.5, sd=None, **kwargs)
create_mirror(c=0.0, r=None, cc=0.0, ec=None, power=None, profile=None, sd=None, **kwargs)Create a sequence and element for a mirror.
Parameters
• c – vertex curvature
• r – vertex radius of curvature
• cc – conic constant
• ec – 1 + cc
• power – optical power of the mirror
• sd – semi-diameter
• profile – Spherical or Conic type, or a profile instance
lens_from_power(power=0.0, bending=0.0, th=None, sd=1.0, med=None, nom_wvl=’d’)
create_lens(power=0.0, bending=0.0, th=None, sd=1.0, med=None, **kwargs)
achromat(power, Va, Vb)Compute lens powers for a thin doublet achromat, given their V-numbers.
create_cemented_doublet(power=0.0, bending=0.0, th=None, sd=1.0, glasses=(’N-BK7, Schott’, ’N-F2, Schott’), **kwargs)
create_dummy_plane(sd=1.0, **kwargs)
create_air_gap(t=0.0, **kwargs)
create_from_file(filename, **kwargs)
calc_render_color_for_material(matl)get element color based on V-number of glass
class Element(s1, s2, g, tfrm=None, idx=0, idx2=1, sd=1.0, label=None)Bases: object
Lens element domain model. Manage rendering and selection/editing.
An Element consists of 2 Surfaces, 1 Gap, and edge_extent information.
parentthe ElementModel
labelstring identifier
s1first/origin Interface
s2second/last Interface
gapelement thickness and material Gap
tfrmglobal transform to element origin, (Rot3, trans3)
medium_namethe material filling the gap
52 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
flat1, flat2semi-diameter of flat or None. Setting to None will result in re-evaluation of flat ID
do_flat1, do_flat2‘if concave’, ‘always’, ‘never’, ‘if convex’
handlesdict of graphical entities
actionsdict of actions associated with the graphical handles
clut = <rayoptics.util.rgbtable.RGBTable object>
label_format = 'E{}'
serial_number = 0
sdSemi-diameter
sync_to_restore(ele_model, surfs, gaps, tfrms)
sync_to_update(seq_model)
tree(**kwargs)Build tree linking sequence to element model.
reference_interface()
reference_idx()
interface_list()
gap_list()
get_bending()
set_bending(bending)
update_size()
compute_flat(s)
extent()
render_shape()
render_handles(opt_model)
handle_actions()
class Mirror(ifc, tfrm=None, idx=0, sd=1.0, thi=None, z_dir=1.0, label=None)Bases: object
label_format = 'M{}'
serial_number = 0
get_thi()
sync_to_restore(ele_model, surfs, gaps, tfrms)
sync_to_update(seq_model)
tree(**kwargs)
reference_interface()
13.1. Subpackages 53
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
reference_idx()
interface_list()
gap_list()
update_size()
extent()
substrate_offset()
render_shape()
render_handles(opt_model)
handle_actions()
class CementedElement(ifc_list, label=None)Bases: object
Cemented element domain model. Manage rendering and selection/editing.
A CementedElement consists of 3 or more Surfaces, 2 or more Gaps, and edge_extent information.
parentthe ElementModel
labelstring identifier
idxslist of seq_model interface indices
ifcslist of Interface
gapslist of thickness and material Gap
tfrmglobal transform to element origin, (Rot3, trans3)
medium_namethe material filling the gap
flatssemi-diameter of flat if ifc is concave, or None
handlesdict of graphical entities
actionsdict of actions associated with the graphical handles
clut = <rayoptics.util.rgbtable.RGBTable object>
label_format = 'CE{}'
serial_number = 0
sdSemi-diameter
sync_to_restore(ele_model, surfs, gaps, tfrms)
sync_to_update(seq_model)
54 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
element_list()
tree(**kwargs)
reference_interface()
reference_idx()
interface_list()
gap_list()
update_size()
compute_flat(s)
extent()
render_shape()
render_handles(opt_model)
handle_actions()
class ThinElement(ifc, tfrm=None, idx=0, sd=None, label=None)Bases: object
label_format = 'TL{}'
serial_number = 0
tree(**kwargs)
sync_to_restore(ele_model, surfs, gaps, tfrms)
sync_to_update(seq_model)
reference_interface()
reference_idx()
interface_list()
gap_list()
update_size()
render_shape()
render_handles(opt_model)
handle_actions()
class DummyInterface(ifc, idx=0, sd=None, tfrm=None, label=None)Bases: object
label_format = 'D{}'
serial_number = 0
sync_to_restore(ele_model, surfs, gaps, tfrms)
sync_to_update(seq_model)
tree(**kwargs)
reference_interface()
reference_idx()
interface_list()
13.1. Subpackages 55
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
gap_list()
update_size()
render_shape()
render_handles(opt_model)
handle_actions()
class AirGap(g, idx=0, tfrm=None, label=None)Bases: object
label_format = 'AG{}'
serial_number = 0
sync_to_restore(ele_model, surfs, gaps, tfrms)
sync_to_update(seq_model)
tree(**kwargs)
reference_interface()
reference_idx()
interface_list()
gap_list()
update_size()
render_handles(opt_model)
handle_actions()
class ElementModel(opt_model, **kwargs)Bases: object
Maintain the element based representation of the optical model
opt_modelthe OpticalModel
elementslist of element type things
reset()
sync_to_restore(opt_model)
reset_serial_numbers()
airgaps_from_sequence(seq_model, tfrms)add airgaps and dummy interfaces to an older version model
add_dummy_interface_at_image(seq_model, tfrms)
update_model(**kwargs)
sequence_elements()Sort elements in order of reference interfaces in seq_model
relabel_airgaps()
add_element(e)
remove_element(e)
56 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
remove_node(e_node)
get_num_elements()
list_model(tag=’#element#dummyifc’)
list_elements()
element_type(i)
rayoptics.elem.layout module
Interactive 2D lens picture
The Lens Layout capability provides a 2D display of the optical model represented by shapes. Shapescontain dict attributes to manage the graphical rendering and editing actions associated with their parentobjects. These attributes must include:
handles: named graphic handles for different aspects of the parent object
actions: functions for press, drag, and release actions
light_or_dark(is_dark=True)
setup_shift_of_ray_bundle(seq_model, start_offset)compute transformation for rays “start_offset” from 1st surface
Parameters
• seq_model – the sequential model
• start_offset – z distance rays should start wrt first surface. positive if to left of firstsurface
Returns
transformation rotation and translation:: (rot, t)
shift_start_of_ray_bundle(start_bundle, ray_bundle, rot, t, cr_indx=0)modify ray_bundle so that rays begin “start_offset” from 1st surface
Parameters
• ray_bundle – list of rays in a bundle, i.e. all for one field. ray_bundle[cr_indx] is thechief/central ray
• start_offset – z distance rays should start wrt first surface. positive if to left of firstsurface
• rot – transformation rotation
• t – transformation translation
• cr_indx – index of the central ray in the bundle
create_optical_element(opt_model, e)
class OpticalElement(opt_model, e)Bases: object
mediator class for rendering and editing optical elements
update_shape(view)
render_color()
get_label()
13.1. Subpackages 57
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
edit_shape_actions()
class RayBundle(opt_model, fld, fld_label, wvl, start_offset, ray_table_callback=None)Bases: object
class for ray bundle from a single field point
get_label()
render_ray(ray, start_seg, tfrms)
render_shape(rayset, start_bundle, tfrms)
update_shape(view)
edit_ray_bundle_actions()
class RayFanBundle(opt_model, ray_fan, start_offset, label=’ray fan’)Bases: object
class for a RayFan from a single field point
get_label()
render_ray(ray_pkg, start_seg, tfrms)
update_shape(view)
class ParaxialRay(opt_model, ray, color, seq_start=1, label=’paraxial’)Bases: object
class for paraxial ray rendering/editing
get_label()
render_ray(ray, tfrms)
update_shape(view)
apply_data(vertex, lcl_pt)
edit_paraxial_layout_actions()
class LensLayout(opt_model, is_dark=True, **kwargs)Bases: object
manager for live layout graphics entities
sync_light_or_dark(is_dark)
system_length(ele_bbox, offset_factor=0.05)returns system length and ray start offset
create_element_entities(view)
create_ray_entities(view, start_offset)
create_ray_fan_entities(view, start_offset, num_rays=21)
create_paraxial_ray_entities(view)
get_ray_table()
register_commands(*args, **kwargs)
add_element_cmd_actions(**kwargs)
split_gap(opt_model, idx, lcl_pt)split g=gap[idx] into t_old = t_0 + t_k using t_0 = lcl_pt.x
58 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
add_elements(opt_model, idx, lcl_pt, create, **kwargs)
add_reflector(opt_model, idx, lcl_pt, create, **kwargs)
add_thinlens(opt_model, idx, lcl_pt, **kwargs)
add_lens(opt_model, idx, lcl_pt, **kwargs)
add_mirror(opt_model, idx, lcl_pt, **kwargs)
add_conic(opt_model, idx, lcl_pt, **kwargs)
add_doublet(opt_model, idx, lcl_pt, **kwargs)
class GlassDropActionBases: object
dragEnterEvent(view, event)
dragMoveEvent(view, event)
dragLeaveEvent(view, event)
dropEvent(view, event)
rayoptics.elem.parttree module
Manage connectivity between sequence and element models using a tree.
class PartTree(opt_model, **kwargs)Bases: object
sync_to_restore(opt_model)
update_model(**kwargs)
init_from_sequence(seq_model)Initialize part tree using a seq_model.
sort_using_sequence(seq_model)Resequence part tree using a seq_model.
add_element_model_to_tree(ele_model)
add_element_to_tree(e, **kwargs)
node(obj)Return the node paired with obj.
trim_node(obj)Remove the branch where obj is the sole leaf.
parent_node(obj, tag=’#element#airgap#dummyifc’)Return the parent node for obj, filtered by tag.
parent_object(obj, tag=’#element#airgap#dummyifc’)Return the parent object (and node) for obj, filtered by tag.
list_tree(*args, **kwargs)Print a graphical console representation of the tree.
The optional arguments are passed through to the by_attr filter. Useful examples or arguments include:
• pt.list_tree(lambda node: f”{node.name}: {node.tag}”)
• pt.list_tree(attrname=’tag’)
13.1. Subpackages 59
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
list_tree_full()Print a graphical console representation of the tree with tags.
nodes_with_tag(tag=’#element’, not_tag=”, root=None)Return a list of nodes that contain the requested tag.
list_model(tag=’#element’)
sync_part_tree_on_restore(ele_model, seq_model, root_node)
sync_part_tree_on_update(ele_model, seq_model, root_node)Update node names to track element labels.
elements_from_sequence(ele_model, seq_model, part_tree)generate an element list from a sequential model
process_airgap(ele_model, seq_model, part_tree, i, g, z_dir, s, g_tfrm, add_ele=True)
rayoptics.elem.profiles module
Module for different surface profile shapes
resize_list(lst, new_length, null_item=None)
intersect_parabola(cv, p, d, z_dir=1.0)Intersect a parabolid, starting from an arbitrary point.
Parameters
• cv – vertex curvature
• p – start point of the ray in the profile’s coordinate system
• d – direction cosine of the ray in the profile’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
class SurfaceProfileBases: object
Base class for surface profiles.
update()
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
normal(p)Returns the unit normal of the profile at point p.
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
profile(sd, dir=1, steps=6)Return a 2d polyline approximating the surface profile.
Parameters
• sd – semi-diameter of the profile
• dir – +1 for profile from neg to postive direction, -1 if otherwise
• steps – number of points to generate
60 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
apply_scale_factor(scale_factor)Apply scale_factor to the profile definition.
intersect(p0, d, eps, z_dir)Intersect a profile, starting from an arbitrary point.
Parameters
• p0 – start point of the ray in the profile’s coordinate system
• d – direction cosine of the ray in the profile’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
intersect_welford(p, d, eps, z_dir)Intersect a profile, starting from an arbitrary point.
From Welford, Aberrations of Optical Systems (ISBN-10: 0852745648), eqs 4.34 thru 4.41.
Parameters
• p0 – start point of the ray in the profile’s coordinate system
• d – direction cosine of the ray in the profile’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
intersect_spencer(p0, d, eps, z_dir)Intersect a profile, starting from an arbitrary point.
From Spencer and Murty, General Ray-Tracing Procedure
Parameters
• p0 – start point of the ray in the profile’s coordinate system
• d – direction cosine of the ray in the profile’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
intersect_scipy(p0, d, eps, z_dir)Intersect a profile, starting from an arbitrary point.
Parameters
• p0 – start point of the ray in the profile’s coordinate system
13.1. Subpackages 61
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• d – direction cosine of the ray in the profile’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
class Spherical(c=0.0, r=None)Bases: rayoptics.elem.profiles.SurfaceProfile
Spherical surface profile parameterized by curvature.
r
listobj()
copyFrom(other)
copyDataFrom(other)
mutate(new_profile)
apply_scale_factor(scale_factor)Apply scale_factor to the profile definition.
intersect_tangent_plane(p, d, eps, z_dir)
intersect(p, d, eps, z_dir)Intersection with a sphere, starting from an arbitrary point.
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
profile(sd, dir=1, steps=6)Return a 2d polyline approximating the surface profile.
Parameters
• sd – semi-diameter of the profile
• dir – +1 for profile from neg to postive direction, -1 if otherwise
• steps – number of points to generate
class Conic(c=0.0, cc=0.0, r=None, ec=None)Bases: rayoptics.elem.profiles.SurfaceProfile
Conic surface profile parameterized by curvature and conic constant.
Conics produced for conic constant values:
• cc > 0.0: oblate spheroid
• cc = 0.0: sphere
• cc < 0.0 and > -1.0: ellipsoid
• cc = -1.0: paraboloid
62 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• cc < -1.0: hyperboloid
r
ec
listobj()
copyFrom(other)
copyDataFrom(other)
apply_scale_factor(scale_factor)Apply scale_factor to the profile definition.
intersect_tangent_plane(p, d, eps, z_dir)
intersect(p, d, eps, z_dir)Intersection with a conic, starting from an arbitrary point.
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
profile(sd, dir=1, steps=6)Return a 2d polyline approximating the surface profile.
Parameters
• sd – semi-diameter of the profile
• dir – +1 for profile from neg to postive direction, -1 if otherwise
• steps – number of points to generate
append_pt_to_2d_profile(surface_profile, y, poly_profile)calc surface sag at y and append to poly if ok, else return None
aspheric_profile(surface_profile, sd, dir=1, steps=21)
class EvenPolynomial(c=0.0, cc=0.0, r=None, ec=None, coefs=None)Bases: rayoptics.elem.profiles.SurfaceProfile
Even Polynomial asphere up to 20th order, on base conic.
r
ec
listobj()
copyFrom(other)
copyDataFrom(other)
gen_coef_list()
apply_scale_factor(scale_factor)Apply scale_factor to the profile definition.
update()
13.1. Subpackages 63
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
profile(sd, dir=1, steps=21)Return a 2d polyline approximating the surface profile.
Parameters
• sd – semi-diameter of the profile
• dir – +1 for profile from neg to postive direction, -1 if otherwise
• steps – number of points to generate
class RadialPolynomial(c=0.0, cc=None, r=None, ec=1.0, coefs=None)Bases: rayoptics.elem.profiles.SurfaceProfile
Radial Polynomial asphere, on base conic.
Conics produced for conic asphere values: ec > 1.0: oblate spheroid ec = 1.0: sphere ec > 0.0 and < 1.0:ellipsoid ec = 0.0: paraboloid ec < 0.0: hyperboloid
initial_size = 10
r
cc
get_coef(exp)
set_coef(exp, value)
listobj()
copyFrom(other)
copyDataFrom(other)
gen_coef_list()
apply_scale_factor(scale_factor)Apply scale_factor to the profile definition.
update()
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
profile(sd, dir=1, steps=21)Return a 2d polyline approximating the surface profile.
Parameters
• sd – semi-diameter of the profile
• dir – +1 for profile from neg to postive direction, -1 if otherwise
64 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• steps – number of points to generate
class YToroid(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)Bases: rayoptics.elem.profiles.SurfaceProfile
Y Aspheric toroid, up to 20th order, on base conic.
r
rR
ec
listobj()
copyFrom(other)
copyDataFrom(other)
gen_coef_list()
apply_scale_factor(scale_factor)Apply scale_factor to the profile definition.
update()
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
fY(y)
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
profile(sd, dir=1, steps=21)Return a 2d polyline approximating the surface profile.
Parameters
• sd – semi-diameter of the profile
• dir – +1 for profile from neg to postive direction, -1 if otherwise
• steps – number of points to generate
class XToroid(c=0.0, cR=0, cc=0.0, r=None, rR=None, ec=None, coefs=None)Bases: rayoptics.elem.profiles.YToroid
X Aspheric toroid, up to 20th order, on base conic. Leverage YToroid
normal(p)Returns the unit normal of the profile at point p.
sag(x, y)Returns the sagitta (z coordinate) of the surface at x, y.
f(p)Returns the value of the profile surface function at point p.
df(p)Returns the gradient of the profile surface function at point p.
mutate_profile(old_profile, new_profile_type)
test()
13.1. Subpackages 65
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.elem.surface module
Module for optical surface related classes
Surface Container of profile, extent, position and orientation information of the surface
DecenterData Maintains data and actions to support 4 types of position and orientation changes.
• DEC: pos and orientation applied prior to surface
• REV: pos and orientation applied following surface in reverse
• DAR: pos and orientation applied prior to surface and then returned to initial frame
• BEN: used for fold mirrors, orientation applied before and after surface
Aperture
• Circular
• Rectangular
• Elliptical
class Surface(lbl=”, profile=None, clear_apertures=None, edge_apertures=None, **kwargs)Bases: rayoptics.seq.interface.Interface
Container of profile, extent, position and orientation.
interface_type()
update()
sync_to_restore(opt_model)
profile_cv
optical_power
set_optical_power(pwr, n_before, n_after)
apply_scale_factor(scale_factor)
from_first_order(nu_before, nu_after, y)
z_sag(pt)
set_z_sag(pt)
calc_cv_from_zsag(pt)
surface_od()
get_y_aperture_extent()returns [y_min, y_max] for the union of apertures
full_profile(edge_extent, flat_id=None, dir=1, steps=6)
intersect(p0, d, eps=1e-12, z_dir=1.0)Intersect an Interface, starting from an arbitrary point.
Parameters
• p0 – start point of the ray in the interface’s coordinate system
• d – direction cosine of the ray in the interface’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
66 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
normal(p)Returns the unit normal of the interface at point p.
class DecenterData(dtype, x=0.0, y=0.0, alpha=0.0, beta=0.0, gamma=0.0)Bases: object
Maintains data and actions for position and orientation changes.
• ‘decenter’: pos and orientation applied prior to surface
• ‘reverse’: pos and orientation applied following surface in reverse
• ‘dec and return’: pos and orientation applied prior to surface and then returned to initial frame
• ‘bend’: used for fold mirrors, orientation applied before and after surface
listobj()
dtype
update()
apply_scale_factor(scale_factor)
tform_before_surf()
tform_after_surf()
class Aperture(x_offset=0.0, y_offset=0.0, rotation=0.0)Bases: object
sync_to_restore(opt_model)
dimension()
set_dimension(x, y)
max_dimension()
point_inside(x, y)
bounding_box()
apply_scale_factor(scale_factor)
tform(x, y)
class Circular(radius=1.0, **kwargs)Bases: rayoptics.elem.surface.Aperture
dimension()
set_dimension(x, y)
max_dimension()
point_inside(x, y)
apply_scale_factor(scale_factor)
class Rectangular(x_half_width=1.0, y_half_width=1.0, **kwargs)Bases: rayoptics.elem.surface.Aperture
dimension()
13.1. Subpackages 67
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
set_dimension(x, y)
point_inside(x, y)
apply_scale_factor(scale_factor)
class Elliptical(x_half_width=1.0, y_half_width=1.0, **kwargs)Bases: rayoptics.elem.surface.Aperture
dimension()
set_dimension(x, y)
apply_scale_factor(scale_factor)
rayoptics.elem.transform module
Useful transforms for processing sequential models
forward_transform(s1, zdist, s2)generate transform rotation and translation from s1 coords to s2 coords
reverse_transform(s1, zdist, s2)generate transform rotation and translation from s2 coords to s1 coords
cascade_transform(r_prev, t_prev, r_seg, t_seg)take the seg transform and cascade it with the prev transform
transfer_coords(r_seg, t_seg, pt_s1, dir_s1)take p and d in s1 coords of seg and transfer them to s2 coords
transform_before_surface(interface, ray_seg)Transform ray_seg from interface to previous seg.
Parameters
• interface – the :class:’~seq.interface.Interface’ for the path sequence
• ray_seg – ray segment exiting from interface
Returns
(b4_pt, b4_dir)
• b4_pt - ray intersection pt wrt following seg
• b4_dir - ray direction cosine wrt following seg
transform_after_surface(interface, ray_seg)Transform ray_seg from interface to following seg.
Parameters
• interface – the :class:’~seq.interface.Interface’ for the path sequence
• ray_seg – ray segment exiting from interface
Returns
(b4_pt, b4_dir)
• b4_pt - ray intersection pt wrt following seg
• b4_dir - ray direction cosine wrt following seg
68 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
13.1.3 rayoptics.gui package
Package encompassing platform agnostic gui commands and updating
The gui subpackage provides a thin app manager framework:
• lightweight app manager, appmanager
• functions implementing basic commands, appcmds
• interactive functions using ipywidgets, dashboards
• interactive GUI actions, actions
• ray-optics file (.roa) reader, roafile
• GUI utility functions, util
Submodules
rayoptics.gui.actions module
Definitions for user interface actions
Action classes are those that contain a dict called actions. The actions dict contains functions thatare executed for UI actions corresponding to the keyword.
Action keywords include: ‘press’ ‘drag’ ‘release’
The argument lists for the called functions include fig and event. Duck typing is relied on loosen thebinding with a particular GUI implementation - or at least that’s the theory.
fig must support a function refresh_gui()
class Action(getf, setf)Bases: object
Action built on a set/get function pair
class AttrAction(obj, attr)Bases: object
Action built on an object/attribute pair
class SagAction(surf)Bases: object
Action to set the profile_cv via surface sag (related to x,y input)
class BendAction(e)Bases: object
Action to bend a lens element, using x component of user input
class ReplaceGlassAction(gap, update=True)Bases: object
Action for replacing an element’s glass from a drag/drop action.
13.1. Subpackages 69
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.gui.appcmds module
generic ray optics commands for creating plots and tables
open_model(file_name, info=False, post_process_imports=True, **kwargs)open a file and populate an optical model with the data
Parameters
• file_name (str) – a filename of a supported file type
– .roa - a rayoptics JSON encoded file
– .seq - a CODE V (TM) sequence file
– .zmx - a Zemax (TM) lens file
• info (bool) – if true, return an info tuple with import statistics
• post_process_imports (bool) – for lens design program file import,
• kwargs (dict) – keyword args passed to the reader functions
Returns if successful, an OpticalModel instance, otherwise, None
create_new_model()
create_new_optical_system(efl=10.0, epd=1, fov=1.0)
create_new_optical_model_from_specsheet(specsheet)create an OpticalModel with a basic thinlens model, given specsheet
update_specsheet(iid, opt_model)
create_new_ideal_imager_dialog(**inputs)
create_yybar_model()
get_defaults_from_gui_parent(gui_parent)
create_live_layout_view(opt_model, gui_parent=None)
create_live_layout_commands(fig)
create_paraxial_design_view_v2(opt_model, dgm_type, gui_parent=None)
create_ray_fan_view(opt_model, data_type, gui_parent=None)
create_ray_grid_view(opt_model, gui_parent=None)
create_wavefront_view(opt_model, gui_parent=None)
create_field_curves(opt_model, gui_parent=None)
create_3rd_order_bar_chart(opt_model, gui_parent=None)
create_glass_map_view(opt_model, gui_parent=None)
update_table_view(table_view)
create_lens_table_model(seq_model)
create_element_table_model(opt_model)
create_ray_table_model(opt_model, ray)
create_parax_table_model(opt_model)
create_parax_model_table(opt_model)
70 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.gui.appmanager module
Lightweight manager class to connect a model+actions to windows
class ModelInfo(model, fct, args, kwargs)Bases: tuple
argslist of fct arguments
fctview update function, can be None
kwargslist of fct keyword arguments
modelobject associated with view update function
class AppManager(model, gui_parent=None)Bases: object
Lightweight model/view manager class
Lightweight manager class to manage connections between a model and a ui view.
The main function of AppManager is refresh_gui(). This is called after a user input to the gui to update themodel and call a refresh function for each ui view of that model.
modelthe model of the currently active/frontmost ui view
model is expected to respond to:
• update_model()
• name()
gui_parentthe top level gui manager (optional)
gui_parent is expected to implement:
• refresh_app_ui()
view_dictkeys are ui views, values are ModelInfo tuples
view is expected to implement:
• windowTitle() - only for debug logging
set_model(model)
add_view(view, gui_hook, model_info)Add a new view and model tuple into dictionary
Parameters
• view – the ui view, used as a key
• gui_hook – instance of the GUI component to be refreshed
• model_info – instance of the ModelInfo tuple
Returns returns the input view
13.1. Subpackages 71
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
add_figure(fig)Add a new figure to be updated at refresh_gui.
Parameters fig – the ui figure
Returns returns the input figure
delete_view(view)removes view from the view dictionary
Parameters view – view being closed by user
close_model(view_close_fct=None)close all ui views associated with the active model
Parameters view_close_fct – optional fct called on each closing view, with the view as anargument. This function, if used, should call delete_view itself.
refresh_gui(**kwargs)update the active model and refresh its dependent ui views
refresh_views(**kwargs)refresh the dependent ui views of the active model
refresh_figures(**kwargs)refresh the dependent ui views of the active model
on_view_activated(view)Makes the model associated with input view the active model
Parameters view – view becoming the active view
sync_light_or_dark(is_dark)Tells views to update to a light or dark color scheme
rayoptics.gui.dashboards module
Dashboards constructed with ipywidgets.
create_focus_dashboard(figs, ray_data_items, foc, dfoc_rng, shift_rng, on_axis_pt, continu-ous_update=True)
create_mirror_tilt_dashboard(mirror, app_mgr, figs, ray_data_items, foc, tilt_rng, shift_rng,oa_ray=None, continuous_update=True)
class AttrChanger(obj, attr, index=None)Bases: object
Changer built on an object/attribute pair.
get()
set(value)
rayoptics.gui.roafile module
Read an .roa file and return a OpticalModel instance
preprocess_roa(file_name, str_replacements)Read and preprocess raw roa text file, returning preprocessed text.
postprocess_roa(opt_model, **kwargs)Post processing for raw optical_model, including sync_to_restore.
72 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
open_roa(file_name, mapping=None, **kwargs)open a ray-optics file and populate an optical model with the data
Parameters
• file_name (str) – a filename with a .roa extension
• mapping – dict mapping old modules to new. If None, use module_repl_050
Returns if successful, an OpticalModel instance, otherwise, None
rayoptics.gui.util module
utility functions for gui functions
class GUIHandle(poly, bbox)Bases: tuple
bboxbounding box for poly
polypoly entity for underlying graphics system (e.g. mpl)
transform_ray_seg(poly, r, tfrm)
bbox_from_poly(poly)
scale_bounds(bbox, oversize_factor)
transform_poly(tfrm, poly)
inv_transform_poly(tfrm, poly)
fit_data_range(x_data, margin=0.05, range_trunc=0.25, **kwargs)
13.1.4 rayoptics.mpl package
package implementing useful rayoptics graphics using matplotlib
The mpl subpackage provides useful basic optical graphics using the matplotlib plotting package. Particular featuresinclude:
• 2D lens layout, interactivelayout
• 𝑦 − 𝑦 and 𝜔 − 𝜔 paraxial ray diagrams, interactivediagram
• ray aberration and wavefront pupil/field plots, analysisfigure, axisarrayfigure andanalysisplots
• base class to manage light and dark UI styles, styledfigure
Submodules
rayoptics.mpl.analysisfigure module
Single panel, multiplot MPL figure, with support for line and surface plots
This package is designed to work with data sources in the analyses package. This package providesa MPL Figure subclass, AnalysisFigure, that is a container for one or more plots. The plots aremanaged by the other classes in this package:
13.1. Subpackages 73
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• RayFanPlot: transverse ray aberreations and OPD
• RayGeoPSF: spot diagrams and 2D histograms
• Wavefront: wavefront map
• DiffractionPSF: diffraction Point Spread Function
class AnalysisFigure(data_objs=None, subplots=None, grid=None, **kwargs)Bases: rayoptics.mpl.styledfigure.StyledFigure
Containing Figure for single panel plots, supports update_data.
subplotslist of plots for this figure
data_objsthe data sources for the plots. If not specified, the subplots will be queried for the data sources.
gridtuple of the # rows and # columns in the figure, defaults to (1, 1)
gsGridSpec instance, created from grid.
gridspecsoptional, list of subplotspecs, one for each subplot. These are used for detailed control of subplot positions.
kwargspassed to Figure base class
refresh(**kwargs)Call update_data() followed by plot(), return self.
Parameters kwargs – keyword arguments are passed to update_data
Returns self (class Figure) so scripting envs will auto display results
update_data(build=’rebuild’, **kwargs)
plot()
class RayFanPlot(fan_list, user_scale_value=0.1, scale_type=’fit’, yaxis_ticks_position=’left’,**kwargs)
Bases: object
Single axis line plot, supporting data display from multiple RayFans.
fan_listlist of (fan, data_type, kwargs)
• fan: a RayFan instance
• data_type: ‘x’, ‘y’, ‘opd’ to be extracted from fan
• kwargs: passed to axis.plot() call
scale_typeif ‘fit’, set scale to encompass largest data value
user_scale_valuemax scale to apply if scale_type is ‘user’
titletitle, if desired, of this plot panel
74 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
yaxis_ticks_position‘left’ or ‘right’, default is ‘left’
kwargspassed to plot call
init_axis(ax)
refresh(build=’rebuild’)
update_data(build=’rebuild’)
plot(ax)
class RayGeoPSF(ray_list, user_scale_value=0.1, scale_type=’fit’, yaxis_ticks_position=’left’,dsp_typ=’hist2d’, **kwargs)
Bases: object
Single axis spot diagram or 2d histogram.
ray_lista RayList instance
dsp_typedisplay type, either ‘spot’ or ‘hist2d’
scale_typeif ‘fit’, set scale to encompass largest data value
user_scale_valuemax scale to apply if scale_type is ‘user’
titletitle, if desired, of this plot panel
yaxis_ticks_position‘left’ or ‘right’, default is ‘left’
kwargspassed to plot call
init_axis(ax)
refresh(build=’rebuild’)
update_data(build=’rebuild’)
ray_data_bounds()
plot(ax)
class Wavefront(ray_grid, do_contours=False, user_scale_value=None, **kwargs)Bases: object
Single axis wavefront map.
ray_grida RayGrid instance
do_contoursif True, display contour plot, else plot data grid as an
image
scale_typeif ‘fit’, set scale to encompass largest data value
13.1. Subpackages 75
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
user_scale_valuemax scale to apply if scale_type is ‘user’
titletitle, if desired, of this plot panel
yaxis_ticks_position‘left’ or ‘right’, default is ‘left’
cmapcolor map for plot, defaults to ‘RdBu_r’
kwargspassed to plot call
init_axis(ax)
refresh(build=’rebuild’)
update_data(build=’rebuild’)
plot(ax)
class DiffractionPSF(pupil_grid, maxdim, yaxis_ticks_position=’left’, **kwargs)Bases: object
Point Spread Function (PSF) calculation and display.
pupil_grida RayGrid instance
maxdimthe size of the sampling array
titletitle, if desired, of this plot panel
yaxis_ticks_position‘left’ or ‘right’, default is ‘left’
cmapcolor map for plot, defaults to ‘RdBu_r’
kwargspassed to plot call
init_axis(ax)
refresh(build=’rebuild’)
update_data(build=’rebuild’)
plot(ax)
rayoptics.mpl.analysisplots module
mpl implementations of common optical analyses
class FieldCurveFigure(opt_model, eval_fct=<function trace_astigmatism>, user_scale_value=0.1,**kwargs)
Bases: rayoptics.mpl.styledfigure.StyledFigure
Plot of astigmatism curves
refresh(**kwargs)
76 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
update_data(**kwargs)
plot()
class ThirdOrderBarChart(opt_model, user_scale_value=0.1, **kwargs)Bases: rayoptics.mpl.styledfigure.StyledFigure
refresh(**kwargs)
update_data(**kwargs)
plot()
class AnalysisPlot(opt_model)Bases: abc.ABC
abstract api for matplotlib axes customized for specific analyses
refresh(**kwargs)called by the app manager to refresh the plot
update_data()function to update the backend data needed for the plot
plot()function that executes the plotting commands
class AstigmatismCurvePlot(opt_model, eval_fct=<function trace_astigmatism>, **kwargs)Bases: rayoptics.mpl.analysisplots.AnalysisPlot
update_data(**kwargs)function to update the backend data needed for the plot
plot()function that executes the plotting commands
rayoptics.mpl.axisarrayfigure module
class FitBases: enum.Enum
An enumeration.
All = 1
All_Same = 2
User_Scale = 3
clip_to_range(rgb_list, lower, upper)
class AxisArrayFigure(opt_model, num_rays=21, scale_type=<Fit.All: 1>, user_scale_value=0.1,num_rows=1, num_cols=1, eval_fct=None, **kwargs)
Bases: rayoptics.mpl.styledfigure.StyledFigure
init_axis(ax)
construct_plot_array(m, n)
wvl_to_sys_units(wvl)
refresh(**kwargs)
update_data(**kwargs)
plot()
13.1. Subpackages 77
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
class RayFanFigure(opt_model, data_type, override_style=True, do_smoothing=True, **kwargs)Bases: rayoptics.mpl.axisarrayfigure.AxisArrayFigure
update_data(build=’rebuild’, **kwargs)
plot()
class SpotDiagramFigure(opt_model, **kwargs)Bases: rayoptics.mpl.axisarrayfigure.AxisArrayFigure
init_axis(ax)
update_data(build=’rebuild’, **kwargs)
plot()
class WavefrontFigure(opt_model, **kwargs)Bases: rayoptics.mpl.axisarrayfigure.AxisArrayFigure
init_axis(ax)
update_data(build=’rebuild’, **kwargs)
plot()
rayoptics.mpl.interactivediagram module
class InteractiveDiagram(opt_model, dgm_type, refresh_gui=None, do_barrel_constraint=False,barrel_constraint=1.0, enable_slide=False, bend_or_gap=’bend’,parax_model=None, parax_model_key=’ifcs’, **kwargs)
Bases: rayoptics.mpl.interactivefigure.InteractiveFigure
Editable version of optical system layout, aka Live Layout
opt_modelparent optical model
refresh_guifunction to be called on refresh_gui event
dgm_typediagram type, ‘ht’ or ‘slp’
setup_dgm_type(dgm_type)
sync_light_or_dark(is_dark, **kwargs)
update_data(**kwargs)
action_complete()
fit_axis_limits()returns a numpy bounding box that fits the current data
rayoptics.mpl.interactivefigure module
class SelectInfo(artist, info)Bases: tuple
artistthe artist
78 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
infoa dictionary of artist specific details of selection
display_artist_and_event(callback_str, event, artist)
class InteractiveFigure(do_draw_frame=False, do_draw_axes=False, oversize_factor=0.05, as-pect=’equal’, view_bbox=None, do_scale_bounds=False, **kwargs)
Bases: rayoptics.mpl.styledfigure.StyledFigure
Base class for domain specific figures with support for input events
The InteractiveFigure class supplies common implementations for:
• polyline and polygon 2D graphics
• selection support for mpl graphic objects
• mouse/touch event handling
• interface commands for zooming and panning the display area
do_draw_frameif True, draw frame around the figure
do_draw_axesif True, draw coordinate axes for the figure
oversize_factorwhat fraction to oversize the view bounding box
aspect‘equal’ for 1:1 aspect ratio, ‘auto’ for best ratio
artist_filteran (optional) callable applied in find_artists_at_location(), returns True if rejected
connect_events(action_dict=None)connect to all the events we need
disconnect_events()disconnect all the stored connection ids
is_unit_aspect_ratio
refresh(**kwargs)Call update_data() followed by plot(), return self.
Parameters kwargs – keyword arguments are passed to update_data
Returns self (class Figure) so scripting envs will auto display results
update_data(**kwargs)
action_complete()
register_action(*args, **kwargs)
register_pan(on_finished)
register_zoom_box(on_finished)
update_patches(shapes)loop over the input shapes, fetching their current geometry and attaching it to the corresponding Artist
create_patches(handles)
create_polygon(poly, linewidth=0.5, **kwargs)
13.1. Subpackages 79
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
create_polyline(poly, linewidth=0.5, hilite_linewidth=2, **kwargs)
create_vertex(vertex, markersize=5, hilite_markersize=7, **kwargs)
update_axis_limits(bbox)
fit_axis_limits()returns a numpy bounding box that fits the current data
set_view_bbox(bbox)
fit()
zoom(factor)
zoom_in()
zoom_out()
draw_frame(do_draw_frame)
draw_axes(do_draw_axes)
plot()Draw the actual figure.
find_artists_at_location(event)Returns a list of shapes in zorder at the event location.
do_shape_action(event, target, event_key)Execute the target shape’s action for the event_key.
This is the default function that the do_action callable attribute is initialized to.
on_select(event)
display_event(event)
on_press(event)
on_motion(event)
on_release(event)on release we reset the press data
class PanAction(**kwargs)Bases: object
wrapper class to handle pan action, handing off to Axes
class ZoomBoxAction(fig, **kwargs)Bases: object
handle zoom box action by using a RectangleSelector widget
rayoptics.mpl.interactivelayout module
Interactive layout figure with paraxial editing
class InteractiveLayout(opt_model, refresh_gui=None, offset_factor=0.05,do_draw_rays=True, do_draw_beams=True, do_draw_edge_rays=True,do_draw_ray_fans=False, num_rays_in_fan=11,do_paraxial_layout=False, **kwargs)
Bases: rayoptics.mpl.interactivefigure.InteractiveFigure
Editable version of optical system layout, aka Live Layout
80 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
opt_modelparent optical model
refresh_guifunction to be called on refresh_gui event
offset_factorhow much to draw rays before first surface
do_draw_raysif True, draw edge rays
do_paraxial_layoutif True, draw editable paraxial axial and chief ray
sync_light_or_dark(is_dark, **kwargs)
update_data(**kwargs)
action_complete()
fit_axis_limits()returns a numpy bounding box that fits the current data
rayoptics.mpl.styledfigure module
manage light and dark interface color schemes
copy_styles()Copy rayoptics mpl styles to user’s mpl_config dir.
apply_style(is_dark)Assign a light or dark style to mpl plots.
class StyledFigure(**kwargs)Bases: matplotlib.figure.Figure
Provide a standard implementation for mpl styles.
sync_light_or_dark(is_dark, do_refresh=True)
13.1.5 rayoptics.oprops package
Package for optical property modeling for optical systems
The oprops subpackage provides classes and functions for modeling optical properties.
Modules in oprops include:
• Modules implementing the phase_element property in Interface: doe
• Modules subclassing Interface: thinlens
Submodules
rayoptics.oprops.doe module
Module for diffractive/holographic optical elements
13.1. Subpackages 81
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Classes that implement diffractive optics capabilities must implement the function phase() for use by theray trace engine.
The DiffractiveElement and HolographicElement implementations are patterned afterWang, et al, Ray tracing and wave aberration calculation for diffractive optical elements
radial_phase_fct(pt, coefficients)Evaluate the phase and slopes at pt
Parameters
• pt – 3d point of incidence in Interface coordinates
• coefficients – list of even power radial phase coefficients, e.g. r**2, r**4, . . .
Returns
(dW, dWdX, dWdY)
• dW: phase added by diffractive interaction
• dWdX: slope in x direction
• dWdY: slope in y direction
class DiffractiveElement(label=”, coefficients=None, ref_wl=550.0, order=1, phase_fct=None)Bases: object
Container class for a phase fct driven diffractive optical element
phase_fctfct the takes an input pt and returns phase and slope
coefficientslist of coeficients for phase function
ref_wlwavelength in nm for phase measurement
orderwhich diffracted order to calculate the phase for
labeloptical labeling for listing
listobj()
phase(pt, in_dir, srf_nrml, z_dir, wl, n_in, n_out)Returns a diffracted ray and phase increment.
Parameters
• pt – point of incidence in Interface coordinates
• in_dir – incoming direction cosine of incident ray
• srf_nrml – Interface surface normal at pt
• z_dir – -1 if after an odd # of reflections, +1 otherwise
• wl – wavelength in nm for ray, defaults to ref_wl
• n_in – refractive index preceding the interface
• n_out – refractive index following the interface
82 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Returns
(out_dir, dW)
• out_dir: direction cosine of the out going ray
• dW: phase added by diffractive interaction
class HolographicElement(label=”)Bases: object
Two point hologram element.
listobj()
phase(pt, in_dir, srf_nrml, z_dir, wl, n_in, n_out)
rayoptics.oprops.thinlens module
Module for thin lens interface type
class ThinLens(lbl=”, power=0.0, ref_index=1.5, **kwargs)Bases: rayoptics.seq.interface.Interface
list_thinlens()
update()
full_profile(sd, flat_id=None, dir=1, steps=6)
profile_cv
surface_od()
set_max_aperture(max_ap)max_ap is the max aperture radius
optical_power
set_optical_power(pwr, n_before, n_after)
apply_scale_factor(scale_factor)
from_first_order(nu_before, nu_after, y)
normal(p)Returns the unit normal of the interface at point p.
intersect(p0, d, **kwargs)Intersect an Interface, starting from an arbitrary point.
Parameters
• p0 – start point of the ray in the interface’s coordinate system
• d – direction cosine of the ray in the interface’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
13.1. Subpackages 83
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
phase(pt, d_in, normal, z_dir, wl, n_in, n_out)Returns a diffracted ray direction and phase increment.
Parameters
• pt – point of incidence in Interface coordinates
• in_dir – direction cosine of incident ray
• srf_nrml – Interface surface normal at pt
• z_dir – -1 if after an odd # of reflections, +1 otherwise
• wl – wavelength in nm for ray, defaults to ref_wl
• n_in – refractive index preceding the interface
• n_out – refractive index following the interface
Returns
(out_dir, dW)
• out_dir: direction cosine of the out going ray
• dW: phase added by diffractive interaction
13.1.6 rayoptics.optical package
Package encompassing optical modeling and calculations
The optical subpackage provides core classes and functions for optical modeling and basic analyses. The overalloptical model is managed by the OpticalModel class
Submodules
rayoptics.optical.model_constants module
optical model constants
rayoptics.optical.model_enums module
DEPRECATED: optical model enums
The enums in this module are deprecated in favor of strings conveying the same information. The func-tions in this module are used to convert enums into the corresponding strings.
class PupilTypeBases: enum.Enum
DEPRECATED: enum for different aperture specifications
EPD = 0entrance pupil diameter
NAO = 1object space numerical aperture
FNO = 2image space f/#
84 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
NA = 3image space numerical aperture
get_ape_key_for_type(pupil_type)
get_ape_type_for_key(aperture_key)
class FieldTypeBases: enum.Enum
DEPRECATED: enum for different field specifications
OBJ_ANG = 0object space angle in degrees
OBJ_HT = 1object height
IMG_HT = 2image height
IMG_ANG = 3image space angle in degrees
get_fld_key_for_type(field_type)
get_fld_type_for_key(field_key)
class DimensionTypeBases: enum.Enum
DEPRECATED: enum for different linear dimensions
MM = 0millimeters
CM = 1centimeters
M = 2meters
IN = 3inches
FT = 4feet
get_dimension_for_type(dimension_type)
class DecenterTypeBases: enum.Enum
DEPRECATED: enum for different tilt and decenter types
LOCAL = 0pos and orientation applied prior to surface
REV = 1pos and orientation applied following surface in reverse
DAR = 2pos and orientation applied prior to surface and then returned to initial frame
BEND = 3used for fold mirrors, orientation applied before and after surface
13.1. Subpackages 85
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
get_decenter_for_type(decenter_type)
rayoptics.optical.opticalmodel module
Top level model classes
class SystemSpecBases: object
Container for units and other system level constants
titlea short description of the model
Type str
initialsuser initials or other id
Type str
temperaturemodel temperature in degrees Celsius
Type float
pressuremodel pressure in mm/Hg
Type float
dimensionsthe model linear units (str).
nm_to_sys_units(nm)convert nm to system units
Parameters nm (float) – value in nm
Returns value converted to system units
Return type float
class OpticalModel(radius_mode=False, specsheet=None, **kwargs)Bases: object
Top level container for optical model.
The OpticalModel serves as a top level container of model properties. Key aspects are built-in element andsurface based repesentations of the optical surfaces. A sequential optical model is a sequence of surfaces andgaps. Additionally, it includes optical usage information to specify the aperture, field of view, spectrum andfocus.
ro_versioncurrent version of rayoptics
radius_modeif True output radius, else output curvature
specsheetSpecSheet
system_specSystemSpec
86 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
seq_modelSequentialModel
optical_specOpticalSpecs
parax_modelParaxialModel
ele_modelElementModel
map_submodels()Setup machinery for model mapping api.
name()
reset()
set_from_specsheet(specsheet=None)
save_model(file_name, version=None)Save the optical_model in a ray-optics JSON file.
Parameters
• file_name – str or Path
• version – optional override for rayoptics version number
sync_to_restore()
update_model(**kwargs)
nm_to_sys_units(nm)convert nm to system units
Parameters nm (float) – value in nm
Returns value converted to system units
Return type float
add_lens(**kwargs)
add_mirror(**kwargs)
add_thinlens(**kwargs)
add_dummy_plane(**kwargs)
add_from_file(filename, **kwargs)
insert_ifc_gp_ele(*descriptor, **kwargs)insert interfaces and gaps into seq_model and eles into ele_model
Parameters
• descriptor – a tuple of additions for the sequential, element and part tree models
• kwargs – keyword arguments including idx: insertion point in the sequential model in-sert: if True, insert the chunk, otherwise replace it t: the thickness following a chuck wheninserting
remove_ifc_gp_ele(*descriptor, **kwargs)remove interfaces and gaps from seq_model and eles from ele_model
remove_node(e_node)
13.1. Subpackages 87
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rebuild_from_seq()Rebuild ele_model and part_tree from seq_model.
rayoptics.optical.obench module
Import files from OpticalBenchHub web page
This module implements lens import from the OpticalBenchHub portion of Bill Claff’s PhotonsToPhotoswebsite.
To import a file from the website, navigate to the lens you wish to import and select the entire web addressof the page. Paste this into the url argument of the read_obench_url() function.
read_obench_url(url, **kwargs)given a url to a OpticalBench file, return an OpticalModel and info.
read_lens(inpts)
13.1.7 rayoptics.parax package
Package for paraxial optical design and analysis
The parax subpackage provides core classes and functions for paraxial/first order optical design. These include:
• Definition of the first order quantities defining an optical system, specsheet, idealimager, and etendue
• Paraxial and third order calculations, firstorder, thirdorder
• Support for 𝑦 − 𝑦 and 𝜔 − 𝜔 diagrams, paraxialdesign and diagram
The paraxial model is managed by the ParaxialModel class
Submodules
rayoptics.parax.diagram module
light_or_dark(is_dark=True)
create_parax_design_commands(fig)
class Diagram(opt_model, parax_model, parax_model_key, dgm_type, seq_start=1,do_barrel_constraint=False, barrel_constraint=1.0, label=’paraxial’,bend_or_gap=’bend’, is_dark=True)
Bases: object
class for paraxial ray rendering/editing
setup_dgm_type(dgm_type)
get_label()
sync_light_or_dark(is_dark)
set_active_layer(layer_key)
update_data(fig, **kwargs)
apply_data(node, vertex)
assign_object_to_node(node, factory, **kwargs)
register_commands(*args, **inputs)
88 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
register_add_replace_element(*args, **inputs)
render_shape()render the diagram into a shape list
update_diagram_from_shape(shape)use the shape list to update the paraxial model
fit_axis_limits()define diagram axis limits as the extent of the shape polygon
compute_slide_line(shape, node, imode)compute a constraint line to keep the overall length of the airspaces surrounding node constant
constrain_to_line_action(pt0, pt2)
class DiagramNode(diagram, idx)Bases: object
update_shape(view)
get_label()
handle_actions()
class DiagramEdge(diagram, idx)Bases: object
update_shape(view)
render_color()
get_label()
handle_actions()
class BarrelConstraint(diagram)Bases: object
update_shape(view)
get_label()
handle_actions()
class ConjugateLine(diagram, line_type)Bases: object
update_shape(view)
get_label()
edit_conjugate_line_actions()
handle_actions()
class EditNodeAction(dgm_node, filter=None)Bases: object
Action to move a diagram node, using an input pt
class EditLensAction(dgm_edge)Bases: object
Action for diagram edge, using an input pt
This is a simple wrapper class to choose the correct action, i.e. bending or thickness change, depending on theUI setting.
13.1. Subpackages 89
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
class EditAreaAction(dgm_edge)Bases: object
Action for diagram area, placeholder for now
This is a simple wrapper class to choose the correct action, i.e. bending or thickness change, depending on theUI setting.
class EditThicknessAction(dgm_edge)Bases: object
Action to move a diagram edge, using an input pt
The movement is constrained to be parallel to the original edge. By doing this the power and bending of theelement remains constant, while the element thickness changes. Movement of the edge is limited to keep thethickness greater than zero and not to interfere with adjacent spaces.
class EditBendingAction(dgm_edge)Bases: object
Action to bend the lens element for diagram edge, using an input pt.
The movement is constrained to be along the object ray for the lens if the input point is closer to the leadingnode of the edge. Otherwise the movement is constrained to be along the image ray. The unconstrained point issolved to keep the element thickness constant and maintain the object-image properties of the lens.
class AddReplaceElementAction(diagram, **kwargs)Bases: object
insert or replace a node with a chunk from a factory fct
The do_command_action fct registered for this operation passes the shape being operated upon; these can be:
• DiagramEdge: insert/add the chunk returned by the factory fct
• DiagramNode: replace the selected node with the factory fct output
Inserting is done by splitting the corresponding gap in two. A new gap and an AirGap element are tackedon to the chunk returned from the factory fct. Replacing is done when a DiagramNode is selected. The gapssurrounding the node are retained, and modified as needed to accomodate the chunk.
class GlassDropActionBases: object
dragEnterEvent(view, event)
dragMoveEvent(view, event)
dragLeaveEvent(view, event)
dropEvent(view, event)
rayoptics.parax.etendue module
functions to calculate etendue and imager parameters
create_etendue_dict()Returns an empty dict2D(fld_ape_set, obj_img_set).
na2slp(na, n=1.0)convert numerical aperture to slope
slp2na(slp, n=1.0)convert a ray slope to numerical aperture
90 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
ang2slp(ang)convert an angle in degrees to a slope
slp2ang(slp)convert a slope to an angle in degrees
get_aperture_from_slope(imager, slope, n=1)
get_slope_from_aperture(imager, input_cell, n=1)
calc_aperture_from_input(conj_type, imager, input_cell, n=1)conj_type is for the io_input space
do_etendue_via_imager(conj_type, imager, etendue_inputs, etendue_grid, n_0=1, n_k=1)
do_field_via_imager(conj_type, imager, etendue_inputs, obj_img_key, etendue_grid, n_0=1, n_k=1)
do_aperture_via_imager(conj_type, imager, etendue_inputs, obj_img_key, etendue_grid, n_0=1,n_k=1)
do_etendue_to_imager(fld_ape_key, etendue_inputs, etendue_grid, n_0=1.0, n_k=1.0)
fill_in_etendue_data(conj_type, imager, fld_ape_key, inputs, values, n=1.0)
rayoptics.parax.firstorder module
Functions to support paraxial ray tracing a sequential optical model
class ParaxData(ax_ray, pr_ray, fod)Bases: tuple
ax_rayaxial marginal ray data, y, u, i
fodinstance of FirstOrderData
pr_raychief ray data, y, u, i
class FirstOrderDataBases: object
Container class for first order optical properties
All quantities are based on paraxial ray tracing. The last interface is the image-1 interface.
opt_invoptical invariant
efleffective focal length
pp1distance of front principle plane from 1st interface
ppkdistance of rear principle plane from last interface
fflfront focal length
bflback focal length
13.1. Subpackages 91
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
fnofocal ratio at working conjugates, f/#
redreduction ratio
n_objrefractive index at central wavelength in object space
n_imgrefractive index at central wavelength in image space
obj_distobject distance
img_distparaxial image distance
obj_angmaximum object angle (degrees)
img_htimage height
enp_distentrance pupil distance from 1st interface
enp_radiusentrance pupil radius
exp_distexit pupil distance from last interface
exp_radiusexit pupil radius
obj_nanumerical aperture in object space
img_nanumerical aperture in image space
list_first_order_data()list the first order properties
paraxial_trace(path, start, start_yu, start_yu_bar)perform a paraxial raytrace of 2 linearly independent rays
compute_first_order(opt_model, stop, wvl)Returns paraxial axial and chief rays, plus first order data.
compute_principle_points(path, n_0=1.0, n_k=1.0)Returns paraxial p and q rays, plus partial first order data.
Parameters
• path – an iterator containing interfaces and gaps to be traced. for each iteration, the se-quence or generator should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir
• n_0 – refractive index preceding the first interface
• n_k – refractive index following last interface
92 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Returns
(p_ray, q_ray, (efl, pp1, ppk, ffl, bfl))
• p_ray: [ht, slp, aoi], [1, 0, -]
• q_ray: [ht, slp, aoi], [0, 1, -]
• efl: effective focal length
• pp1: distance of front principle plane from 1st interface
• ppk: distance of rear principle plane from last interface
• ffl: front focal length
• bfl: back focal length
list_parax_trace(opt_model, reduced=False)list the paraxial axial and chief ray data
specsheet_from_parax_data(opt_model, specsheet)update specsheet to contents of opt_model, while preserving inputs
rayoptics.parax.idealimager module
module to setup an ideal imager
class IdealImager(m, s, sp, tt, f)Bases: tuple
ffocal length
m(lateral) magnification
sobject distance from first principal plane, P1->Obj
spimage distance from second principal plane, P2->Img
tttotal track length, tt = sp - s
ideal_imager_setup(**inputs)Calculate the ideal imaging properties given two independent parameters
Given 2 system parameters from the following list, this function calculates the remaining parameters.
Note that if specifying tt and f, their ratio, tt/f, must be greater than or equal to 4. A ValueError is raisedotherwise.
For a typical system, the value of s is negative, i.e. the object is to the left of the first principal plane.
Example:
In [3]: m1s1 = ideal_imager_setup(m=-0.5, s=-10.0); m1s1Out[3]: IdealImager(m=-0.5, s=-10.0, sp=5.0, tt=15.0, f=3.333333333333)
In [4]: s_inf_efl = ideal_imager_setup(s=-math.inf, f=25.0); s_inf_eflOut[4]: IdealImager(m=-0.0, s=-inf, sp=25.0, tt=inf, f=25.0)
13.1. Subpackages 93
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Parameters
• m – (lateral) magnification
• s – object distance from first principal plane, P1->Obj
• sp – image distance from second principal plane, P2->Img
• tt – total track length, tt = sp - s
• f – focal length
Returns IdealImager namedtuple
Raises ValueError – if tt/f < 4
rayoptics.parax.paraxialdesign module
First order paraxial design space
bbox_from_poly(poly)
class ParaxialModel(opt_model, opt_inv=1.0, ifcs_mapping=None, **kwargs)Bases: object
sync_to_restore(opt_model)
update_model(**kwargs)
build_lens()
init_from_nodes(nodes, rndx_and_imode=None)Construct a diagram using nodes, a list of diagram vertices.
parax_to_nodes(type_sel=0)render the paraxial model into a node list
nodes_to_parax(nodes, type_sel=0)Update the parax model from the node list, nodes.
get_pt(idx)
set_pt(idx, pt)
get_gap_for_node(node)
add_node(node, new_vertex, type_sel, interact_mode)Add a node in the paraxial data structures
assign_object_to_node(node, factory, **inputs)create a new element from factory and replace node with it
compute_signed_rindx()Reset the state of the refractive index array.
This method resets the signs of the refractive indices so that they are negative following an odd number ofreflections, but positive otherwise.
replace_node_with_seq(node, sys_seq, pp_info)replaces the data at node with sys_seq
get_object_for_node(node)basic 1:1 relationship between seq and parax model sequences
delete_node(surf)delete the node at position surf
94 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
apply_ht_dgm_data(surf, new_vertex=None)This routine calculates all data dependent on the input height coordinates (y,ybar) at surface surf.
apply_slope_dgm_data(surf, new_vertex=None)This routine calculates all data dependent on the input slope coordinates (nu,nubar) at surface surf.
update_composite_node(node, new_vertex=None)
update_rindex(surf)Update the refractive index using the gap at surf.
paraxial_trace()regenerate paraxial axial and chief rays from power and reduced distance
list_lens()list the paraxial axial and chief rays, and power, reduced distance
list_sys_seq()
first_order_data()List out the first order imaging properties of the model.
seq_path_to_paraxial_lens(path)returns lists of power, reduced thickness, signed index and refract mode
paraxial_lens_to_seq_model()Applies a paraxial lens spec (power, reduced distance) to the model
pwr_slope_solve(ray, surf, slp_new)
pwr_ht_solve(ray, surf, ht_new)
thi_ht_solve(ray, surf, ht_new)
compute_principle_points(seq)Returns paraxial p and q rays, plus partial first order data.
Parameters seq – a sequence containing interfaces and gaps to be traced. for each iteration,the sequence should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir
Returns
(p_ray, q_ray, (efl, pp1, ppk, ffl, bfl))
• p_ray: [ht, slp, aoi], [1, 0, -]
• q_ray: [ht, slp, aoi], [0, 1, -]
• efl: effective focal length
• pp1: distance of front principle plane from 1st interface
• ppk: distance of rear principle plane from last interface
• ffl: front focal length
• bfl: back focal length
apply_conjugate_shift(nodes, k, mat, line_type)
paraxial_vignetting(rel_fov=1)Calculate the vignetting factors using paraxial optics.
create_diagram_for_key(opm, key)
update_diagram_for_key(opm, key)
generate_mapping_for_key(opm, key)
13.1. Subpackages 95
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
air_gaps_to_node_defs(opm)generate the node defs for ‘eles’ layer, based on airgaps.
get_valid_nodes(parax_model, node_defs_in)given the input node defs, replace non-physical thin lenses as needed.
nodes_from_node_defs(parax_model, node_defs)produce a list of nodes given the parax_model and node_defs.
node_defs is a list of tuples, each with either one or two indices. if there is a single index, it is to a nodein parax_model. if there are 2 indices, the first is to the gap preceding the element; the second is to the gapfollowing the element (also the last interface of the element). The node is calculated from the intersection of thediagram edges corresponding to these gaps.
There is no guarentee that the nodes calculated here represent a physically realizable system, i.e. there may bevirtual airspaces.
scan_nodes(parax_model, node_defs, nodes)scan node defs for any invalid thin elements
Replace the first invalid thin element found with two 3 element tuples, signifying a thick node. The first tupleelement is the index to the node in the parax_model and the last two elements are the range of indices in theparax_model covered by the thick element.
Return the updated node_def list.
build_from_yybar(opm, nodes, ifcs_mapping)
gen_ifcs_node_mapping(parax_model, node_defs, nodes)Create mapping between composite diagram and interface based diagram.
Each node in the composite diagram is associated with one or a range of nodes in parax_model.layer[‘ifcs’].node_defs and nodes define the composite diagram.
node_defs is a list of tuples, one per composite node, of length 1, 2, or 3. The number of entries is as follows:
1) the composite node maps directly to node idx in the ‘ifcs’ layer
2) the composite node is generated from the previous and following gap indices
3) the composite node is part of a thick node
A thick node is what is used when reducing a range of interfaces to a single node requires virtual propagationdistances. In this case, the first and last nodes in the range are retained in the composite diagram; interior nodesare scaled according to how the thick edge is stretched.
Changes in the composite diagram are propagated to the underlying ‘ifcs’ layer by applying a 2D stretch to thenodes in the ‘ifcs’ layer. The ‘ifcs’ node is parameterized by the calculating the intersection of the compositeedge with the vector from the origin through the composite node. The scale factors are:
• t1: parametric distance of the intersection point along the composite edge
• t2: fractional distance of the composite node to the intersection point
The map_to_ifcs list connects the edge in the composite diagram to the ‘ifcs’ node and the scale factors neededto update the ‘ifcs’ node position when the composite diagram changes.
calc_ifcs_nodes(map_to_ifcs, nodes)Given a composite diagram, calculate the interface based diagram.
rayoptics.parax.specsheet module
module to facilitate first order definition of an optical model
96 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
create_specsheet(conjugate_type, **inputs)
create_specsheets()
create_specsheet_from_model(opt_model)Return a specsheet filled with the current data from opt_model.
class SpecSheet(conjugate_type, imager=None, imager_inputs=None, frozen_imager_inputs=None,etendue_inputs=None, etendue_values=None)
Bases: object
First order optical specification for OpticalModel
conjugate_typeone of infinite, finite
imagerinstance of IdealImager
imager_inputsdict of inputs to ideal_imager_setup
frozen_imager_inputslist of booleans, if True the parameter is frozen
etendue_inputsfield and aperture inputs used to define the etendue
etendue_valuesdict2D of aperture/field vs object/image
partitions‘imager’, ‘field’, and ‘aperture’; number of items in each
sync_to_restore(opt_model)
imager_defined()True if the imager is completely specified.
partition_defined()which partition defines the imager or None
generate_from_inputs(imgr_inputs, etendue_inputs)compute imager and etendue values given input dicts
get_etendue_inputs(ape_fld_key)returns key, value pair for ‘aperture’|’field’ ape_fld key.
get_parax_start_data(thi_0, n_0, n_k)
rayoptics.parax.thirdorder module
thirder order aberration calculation
compute_third_order(opt_model)Compute Seidel aberration coefficents.
calc_4th_order_aspheric_term(p)
aspheric_seidel_contribution(seq_model, parax_data, i, n_before, n_after)
seidel_to_wavefront(seidel, central_wvl)Convert Seidel coefficients to wavefront aberrations
13.1. Subpackages 97
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
seidel_to_transverse_aberration(seidel, ref_index, slope)Convert Seidel coefficients to transverse ray aberrations
seidel_to_field_curv(seidel, ref_index, opt_inv)Convert Seidel coefficients to astigmatic and Petzval curvatures
13.1.8 rayoptics.qtgui package
package supplying Qt5 desktop application and associated functional support
The qtgui subpackage provides a desktop app using the PyQt5 interface to the Qt GUI library. It also provides aseries of higher level interfaces used by rayoptics. These include:
• main program for rayopticsapp, rayopticsapp
• an interface that hosts matplotlib graphics, plotview
• a table grid for numeric model displays (template-based), pytablemodel
• docking panel support for python objects, dockpanels
• iPython console window (desktop app only), ipyconsole
• dialog box interface to idealimager and specsheet, idealimagerdialog
Submodules
rayoptics.qtgui.dockpanels module
class PanelInfo(dock, panel_widget, menu_action)Bases: tuple
dockAlias for field number 0
menu_actionAlias for field number 2
panel_widgetAlias for field number 1
create_dock_windows(gui_app)
create_dock_widget(gui_app, item_key, label, panel, state)
update_dock_windows(gui_app)
create_menu_action(gui_app, item_key, label, state=False)
togglePanel(gui_app, state, item_key)
class ModelBinding(gui_app, get_parent, field)Bases: object
ModelBinding the the base class for binding part of the optical model to a UI element. UI elements shouldextend this class.
When more getters/setters are needed, overwrite the get/set functions to directly get/set the model part
set(value)Updates the model with the new value
98 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
get()Retreives the model’s current value
class EnumChoiceWidget(gui_app, get_parent, field, combo_items)Bases: rayoptics.qtgui.dockpanels.ModelBinding
currentIndexChanged()
refresh()
class ListChoiceWidget(gui_app, get_parent, field, combo_items)Bases: rayoptics.qtgui.dockpanels.ModelBinding
currentIndexChanged()
refresh()
class TextFieldWidget(gui_app, get_parent, field, valueFormat=’{:s}’)Bases: rayoptics.qtgui.dockpanels.ModelBinding
editingFinished()
refresh()
class FloatFieldWidget(gui_app, root_fn, field, valueformat=’{:.7g}’)Bases: rayoptics.qtgui.dockpanels.TextFieldWidget
FloatFieldWidget is like a TextFieldWidget but only for floats
class SpectrumWavelengthsPanel(gui_app, parent=None)Bases: PyQt5.QtWidgets.QWidget
root()
update(opt_model)push backend data to widgets
class AperturePanel(gui_app, parent=None)Bases: PyQt5.QtWidgets.QWidget
comboItems = ['Ent Pupil Diam', 'Object NA', 'F/#', 'NA']
root()
update(opt_model)push backend data to widgets
class FieldOfViewPanel(gui_app, parent=None)Bases: PyQt5.QtWidgets.QWidget
comboItems = ['Object Angle', 'Object Height', 'Image Height']
root()
update(opt_model)push backend data to widgets
class SystemSpecPanel(gui_app, parent=None)Bases: PyQt5.QtWidgets.QWidget
root()
update(opt_model)push backend data to widgets
13.1. Subpackages 99
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.qtgui.idealimagerdialog module
Qt5 dialog box for ideal imager ui
value_to_text(value, fmt_str=’{:> #.5f}’)
class IdealImagerDialog(conjugate_type, specsheets, cmd_fct=None, **kwargs)Bases: PyQt5.QtWidgets.QWidget
createButtonBox(cmd_fct)
createConjugateBox(itype=’infinite’)
change_conjugate(conj_type)
update_conjugate(conj_type)
update_values()callback routine for any dialog value change
update_checkboxes()callback routine for any dialog checkbox change
class ImagerSpecGroupBox(parent, specsheet, keys=None, labels=None, **kwargs)Bases: PyQt5.QtWidgets.QGroupBox
value_change(imager_key)
chkbox_change(state, imager_key)
update_values()
update_checkboxes()
class EtendueGroupBox(parent, itype, specsheet, **kwargs)Bases: PyQt5.QtWidgets.QGroupBox
value_change(fld_ape, obj_img, key)callback routine for item value widget
chkbox_change(state, fld_ape, obj_img, key)callback routine for item checkbox
update_values()
update_checkboxes()update the enabled and checked state for the etendue groupbox
class SpaceGroupBox(parent, title, fld_ape, obj_img, keys, labels=None, **kwargs)Bases: PyQt5.QtWidgets.QGroupBox
update_values(inputs, values)update the display for the etendue cell being updated
update_checkboxes(inputs, values, partition_defined=False)update the display for the etendue cell being updated
A partition is an aperture or field pair of object/image inputs.
If it is defined, this means that all attrs can be supplied. In this case, the inputs will have editable valuesand (checked) checkboxes; the remaining attrs will have uneditable values and (unchecked) checkboxes.
If the partition is not defined, all values and checkboxes will be editable, the input attrs, if any, will bechecked.
100 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.qtgui.ipyconsole module
Support creation of an iPython console, with rayoptics environment
create_ipython_console(gui_parent, opt_model, title, view_width, view_ht)create a iPython console with a rayoptics environment
class ConsoleWidget(customBanner=None, *args, **kwargs)Bases: qtconsole.rich_jupyter_widget.RichJupyterWidget
push_vars(variableDict)Given a dictionary containing name / value pairs, push those variables to the Jupyter console widget
clear()Clears the terminal
print_text(text)Prints some plain text to the console
execute_command(command)Execute a command in the frame of the console widget
rayoptics.qtgui.plotview module
Support for fully featured QT windows for plotting/matplotlib
class PlotCanvas(parent, figure, accept_drops=True, drop_action=None)Bases: matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg
dragEnterEvent(self, QDragEnterEvent)
dragMoveEvent(self, QDragMoveEvent)
dragLeaveEvent(self, QDragLeaveEvent)
dropEvent(self, QDropEvent)
class NullDropActionBases: object
dragEnterEvent(view, event)
dragMoveEvent(view, event)
dragLeaveEvent(view, event)
dropEvent(view, event)
update_figure_view(plotFigure)
class CommandItem(parent, txt, cntxt)Bases: PyQt5.QtWidgets.QListWidgetItem
data(self, int)→ Any
setData(self, int, Any)
create_command_panel(fig, commands)
on_command_clicked(item)
create_plot_view(app, fig, title, view_width, view_ht, commands=None, add_panel_fcts=None,add_nav_toolbar=False, drop_action=None)
create a window hosting a (mpl) figure
13.1. Subpackages 101
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
create_glass_map_view(app, glass_db)
create_plot_scale_panel(app, pc)
create_multi_plot_scale_panel(app, pc)
on_plot_scale_toggled(cntxt, scale_type)
on_plot_scale_changed(cntxt)
get_icon(fig, icon_filepath, icon_size=48)
create_2d_figure_toolbar(app, pc)zoom, fit and pan commands for figures Pan Zoom Box Fit Zoom In, Out 1:1
create_draw_rays_groupbox(app, pc)
create_diagram_controls_groupbox(app, pc)
create_diagram_edge_actions_groupbox(app, pc)
create_diagram_layers_groupbox(app, pc)
on_barrel_constraint_toggled(cntxt, state)
on_barrel_constraint_changed(cntxt)
on_bend_or_gap_toggled(diagram, radio_btn_id)
on_active_diagram_toggled(fig, layer_key)
rayoptics.qtgui.pytablemodel module
Table model supporting data content via python eval() fct
class PyTableModel(root, rootEvalStr, colEvalStr, rowHeaders, colHeaders, colFormats,is_editable=False, get_num_rows=None, get_row_headers=None,drop_actions=None)
Bases: PyQt5.QtCore.QAbstractTableModel
Table model supporting data content via python eval() fct.
Model interface for table view of list structures.
rootobject or list at the root of the eval() string
rootEvalStrstring that is concatentated to the root name and passed to the eval() function. This will accomodatedynamic name changes.
colEvalStrstring that is concatentated to the root name and passed to the eval() function. There should be a replace-ment field, i.e. {} where the row value will be substituted using the str.format() function.
rowHeaderslist of strings, length defines number of rows in the table
colHeaderslist of strings, length defines number of columns in the table
colFormatsformat strings to be used to format data in each column
102 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
is_editableif true, items are editable
get_num_rowsif not None, a function that returns the number of rows in the table
get_row_headersif not None, a function that returns the row headers for the table
update
rowCount(self, parent: QModelIndex = QModelIndex())→ int
columnCount(self, parent: QModelIndex = QModelIndex())→ int
headerData(self, int, Qt.Orientation, role: int = Qt.DisplayRole)→ Any
flags(self, QModelIndex)→ Qt.ItemFlags
get_root_object()
data(self, QModelIndex, role: int = Qt.DisplayRole)→ Any
setData(self, QModelIndex, Any, role: int = Qt.EditRole)→ bool
rayoptics.qtgui.rayopticsapp module
Ray Optics GUI Application
Relies on PyQt5
class MainWindow(parent=None, qtapp=None)Bases: PyQt5.QtWidgets.QMainWindow
count = 0
add_subwindow(widget, model_info)
delete_subwindow(sub_wind)
add_ipython_subwindow(opt_model)
initial_window_offset()
do_file_action(q)
file_action(action)
new_model(**kwargs)
new_model_via_specsheet()
new_console_empty_model()
open_file(file_name, **kwargs)
save_file(file_name)
close_model()NOTE: this does not check to save a modified model
do_view_action(q)
view_action(action)
do_window_action(q)
window_action(action)
13.1. Subpackages 103
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
light_or_dark(is_dark)set the UI to a light or dark scheme.
Qt doesn’t seem to support controlling the MdiArea’s background from a style sheet. Set the widgetdirectly and save the original color to reset defaults.
create_lens_table()
create_ray_table(opt_model)
create_table_view(table_model, table_title, close_callback=None)
eventFilter(obj, event)Used by table_view in response to installEventFilter.
refresh_gui(**kwargs)
refresh_app_ui()
handle_ideal_imager_command(iid, command, specsheet)link Ideal Imager Dialog buttons to model actions iid: ideal imager dialog command: text field with theaction - same as button label specsheet: the input specsheet used to drive the actions
on_data_changed(rootObj, index)
main()
13.1.9 rayoptics.raytr package
Package for optical ray tracing and calculations
The raytr subpackage provides core classes and functions for optical ray tracing and analyses. These include:
• Primitive and higher level ray tracing, raytrace, trace
• Specification of aperture, field, wavelength and defocus, opticalspec
• Tracing of fans, lists and grids of rays, including refocusing of OPD values, analyses
• Sample generation for ray grids, sampler
The overall optical model is managed by the OpticalModel class
Submodules
rayoptics.raytr.analyses module
Aberration calculations for (fld, wvl, foc), including focus and image shift
This module refactors some existing ray trace and aberration calculations in other modules to be expressedfor a single field point and wavelength. The ability to apply focus and image shifts to an already acquireddata set is provided for use interactively and in other performance critical areas.
The following classes are implemented in this module:
• Ray: trace a single ray
• RayFan: trace a fan of rays in either the x or y meridian
• RayList: trace a list of rays from an object point
• RayGrid: trace a rectilinear grid of rays
104 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
All but the Ray class are supported by a group of functions to trace the rays, accumulate the data (trace_*),and refocus (focus_*) the data. A all-in-one function (eval_*) to trace and apply focus is supplied also.These are used in the update_data methods of the classes to generate the ray data.
This module also has functions to calculate chief ray and reference sphere information as well as functionsfor calculating the monochromatic PSF of the model.
get_chief_ray_pkg(opt_model, fld, wvl, foc)Get the chief ray package at fld, computing it if necessary.
Parameters
• opt_model – OpticalModel instance
• fld – Field point for wave aberration calculation
• wvl – wavelength of ray (nm)
• foc – defocus amount
Returns
tuple of chief_ray, cr_exp_seg
• chief_ray: chief_ray, chief_ray_op, wvl
• cr_exp_seg: chief ray exit pupil segment (pt, dir, dist)
– pt: chief ray intersection with exit pupil plane
– dir: direction cosine of the chief ray in exit pupil space
– dist: distance from interface to the exit pupil point
Return type chief_ray_pkg
setup_exit_pupil_coords(opt_model, fld, wvl, foc, chief_ray_pkg, image_pt_2d=None)Compute the reference sphere for a defocussed image point at fld.
Parameters
• opt_model – OpticalModel instance
• fld – Field point for wave aberration calculation
• wvl – wavelength of ray (nm)
• foc – defocus amount
• chief_ray_pkg – input tuple of chief_ray, cr_exp_seg
• image_pt_2d – x, y image point in (defocussed) image plane, if None, use the chief raycoordinate.
Returns tuple of image_pt, ref_dir, ref_sphere_radius
Return type ref_sphere
wave_abr_full_calc(fod, fld, wvl, foc, ray_pkg, chief_ray_pkg, ref_sphere)Given a ray, a chief ray and an image pt, evaluate the OPD.
The main references for the calculations are in the H. H. Hopkins paper Calculation of the Aberrations andImage Assessment for a General Optical System
Parameters
• fod – FirstOrderData for object and image space refractive indices
• fld – Field point for wave aberration calculation
13.1. Subpackages 105
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• wvl – wavelength of ray (nm)
• foc – defocus amount
• ray_pkg – input tuple of ray, ray_op, wvl
• chief_ray_pkg – input tuple of chief_ray, cr_exp_seg
• ref_sphere – input tuple of image_pt, ref_dir, ref_sphere_radius
Returns OPD of ray wrt chief ray at fld
Return type opd
wave_abr_pre_calc(fod, fld, wvl, foc, ray_pkg, chief_ray_pkg)Pre-calculate the part of the OPD calc independent of focus.
wave_abr_calc(fod, fld, wvl, foc, ray_pkg, chief_ray_pkg, pre_opd_pkg, ref_sphere)Given pre-calculated info and a ref. sphere, return the ray’s OPD.
trace_safe(opt_model, pupil, fld, wvl, ray_list, output_filter, rayerr_filter, **kwargs)Wrapper for trace_base that handles exceptions.
Parameters
• opt_model – OpticalModel instance
• pupil – 2d vector of relatice pupil coordinates
• fld – Field point for wave aberration calculation
• wvl – wavelength of ray (nm)
• ray_list – list to append the ray data
• output_filter –
• if None, append entire ray (-) –
• if 'last', append the last ray segment only (-) –
• else treat as callable and append the return value (-) –
• rayerr_filter –
• if None, on ray error append nothing (-) –
• if 'summary', append the exception without ray data (-) –
• if 'full', append the exception with ray data up to error (-) –
• else append nothing (-) –
retrieve_ray(ray_list_item)Retrieve the ray (the list of ray segs) from ray_list_item.
This function handles the normal case where the ray traces successfully and the case of a ray failure, whichreturns a TraceError instance.
class Ray(opt_model, p, f=0, wl=None, foc=None, image_pt_2d=None, srf_indx=-1, srf_save=’single’)Bases: object
A ray at the given field and wavelength.
opt_modelOpticalModel instance
prelative 2d pupil coordinates
106 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
findex into FieldSpec or a Field instance
wlwavelength (nm) to trace the fan, or central wavelength if None
focfocus shift to apply to the results
image_pt_2dimage offset to apply to the results
srf_save‘single’: save the ray data for surface srf_indx ‘all’: save all of the surface by surface ray data
srf_indxfor single surface retention, the surface index to save
update_data(**kwargs)Set the fan attribute to a list of (pupil coords), dx, dy, opd.
class RayFan(opt_model, f=0, wl=None, foc=None, image_pt_2d=None, num_rays=21, xyfan=’y’, out-put_filter=None, rayerr_filter=None, **kwargs)
Bases: object
A fan of rays across the pupil at the given field and wavelength.
opt_modelOpticalModel instance
findex into FieldSpec or a Field instance
wlwavelength (nm) to trace the fan, or central wavelength if None
focfocus shift to apply to the results
image_pt_2dimage offset to apply to the results
num_raysnumber of samples along the fan
xyfan‘x’ or ‘y’, specifies the axis the fan is sampled on
update_data(**kwargs)Set the fan attribute to a list of (pupil coords), dx, dy, opd.
select_plot_data(fan, xyfan, data_type)Given a fan of data, select the sample points and the resulting data.
smooth_plot_data(f_x, f_y, num_points=100)Interpolate fan data points and return a smoothed version.
trace_ray_fan(opt_model, fan_rng, fld, wvl, foc, output_filter=None, rayerr_filter=None, **kwargs)Trace a fan of rays, according to fan_rng.
eval_fan(opt_model, fld, wvl, foc, xy, image_pt_2d=None, num_rays=21, output_filter=None, ray-err_filter=None, **kwargs)
Trace a fan of rays and evaluate dx, dy, & OPD across the fan.
13.1. Subpackages 107
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
trace_fan(opt_model, fld, wvl, foc, xy, image_pt_2d=None, num_rays=21, output_filter=None, ray-err_filter=None, **kwargs)
Trace a fan of rays and precalculate data for rapid refocus later.
focus_fan(opt_model, fan_pkg, fld, wvl, foc, image_pt_2d=None, **kwargs)Refocus the fan of rays and return the tranverse abr. and OPD.
class RayList(opt_model, pupil_gen=None, pupil_coords=None, num_rays=21, f=0, wl=None,foc=None, image_pt_2d=None)
Bases: object
Container class for a list of rays produced from a list or generator
opt_modelOpticalModel instance
pupil_gen(fct, args, kwargs), where:
• fct: a function returning a generator returning a 2d coordinate
• args: passed to fct
• kwargs: passed to fct
pupil_coordslist of 2d coordinates. If None, filled in by calling pupil_gen.
num_raysnumber of samples side of grid. Used only if pupil_coords and pupil_gen are None.
findex into FieldSpec or a Field instance
wlwavelength (nm) to trace the fan, or central wavelength if None
focfocus shift to apply to the results
image_pt_2dimage offset to apply to the results
update_data(**kwargs)
trace_ray_list(opt_model, pupil_coords, fld, wvl, foc, append_if_none=False, output_filter=None, ray-err_filter=None, **kwargs)
Trace a list of rays at fld and wvl and return ray_pkgs in a list.
trace_list_of_rays(opt_model, rays, output_filter=None, rayerr_filter=None, **kwargs)Trace a list of rays (pt, dir, wvl) and return ray_pkgs in a list.
Parameters
• opt_model – OpticalModel instance
• rays – list of (pt0, dir0, wvl)
– pt0: starting point in coords of first interface
– dir0: starting direction cosines in coords of first interface
– wvl: wavelength in nm
• output_filter – None, “last”, or a callable. See below
• **kwargs – kwyword args passed to the trace function
108 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
The output_filter keyword argument controls what ray data is returned to the caller.
• if None, returns the entire traced ray
• if “last”, returns the ray data from the last interface
• if a callable, it must take a ray_pkg as an argument and return the desired data or None
Returns A list with an entry for each ray in rays
eval_pupil_coords(opt_model, fld, wvl, foc, image_pt_2d=None, num_rays=21)Trace a list of rays and return the transverse abr.
trace_pupil_coords(opt_model, pupil_coords, fld, wvl, foc, image_pt_2d=None)Trace a list of rays and return data needed for rapid refocus.
focus_pupil_coords(opt_model, ray_list, fld, wvl, foc, image_pt_2d=None)Given pre-traced rays and a ref. sphere, return the transverse abr.
class RayGrid(opt_model, f=0, wl=None, foc=None, image_pt_2d=None, num_rays=21,value_if_none=nan)
Bases: object
Container for a square grid of rays.
opt_modelOpticalModel instance
findex into FieldSpec or a Field instance
wlwavelength (nm) to trace the fan, or central wavelength if None
focfocus shift to apply to the results
image_pt_2dimage offset to apply to the results
num_raysnumber of samples along the side of the grid
update_data(**kwargs)
trace_ray_grid(opt_model, grid_rng, fld, wvl, foc, append_if_none=True, output_filter=None, ray-err_filter=None, **kwargs)
Trace a grid of rays at fld and wvl and return ray_pkgs in 2d list.
eval_wavefront(opt_model, fld, wvl, foc, image_pt_2d=None, num_rays=21, value_if_none=nan)Trace a grid of rays and evaluate the OPD across the wavefront.
trace_wavefront(opt_model, fld, wvl, foc, image_pt_2d=None, num_rays=21)Trace a grid of rays and pre-calculate data needed for rapid refocus.
focus_wavefront(opt_model, grid_pkg, fld, wvl, foc, image_pt_2d=None, value_if_none=nan)Given pre-traced rays and a ref. sphere, return the ray’s OPD.
psf_sampling(n=None, n_pupil=None, n_airy=None)Given 2 of 3 parameters, calculate the third.
Parameters
• n – The total width of the sampling grid
13.1. Subpackages 109
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• n_pupil – The sampling across the pupil
• n_airy – The sampling across the central peak of the Airy disk
Returns: (n, n_pupil, n_airy)
calc_psf_scaling(pupil_grid, ndim, maxdim)Calculate the input and output grid spacings.
Parameters
• pupil_grid – A RayGrid instance
• ndim – The sampling across the wavefront
• maxdim – The total width of the sampling grid
Returns The linear grid spacing on the entrance pupil delta_xp: The linear grid spacing on the imageplane
Return type delta_x
calc_psf(wavefront, ndim, maxdim)Calculate the point spread function of wavefront W.
Parameters
• wavefront – ndim x ndim Numpy array of wavefront errors. No data condition is indi-cated by nan
• ndim – The sampling across the wavefront
• maxdim – The total width of the sampling grid
Returns: AP, the PSF of the input wavefront
update_psf_data(pupil_grid, build=’rebuild’)
rayoptics.raytr.opticalspec module
Container class for optical usage information
class OpticalSpecs(opt_model, specsheet=None, **kwargs)Bases: object
Container class for optical usage information
Contains optical usage information to specify the aperture, field of view, spectrum and focal position. These canbe accessed via the mapping interface:
• self[‘wvls’]: instance of WvlSpec
• self[‘pupil’]: instance of PupilSpec
• self[‘fov’]: instance of FieldSpec
• self[‘focus’]: instance of FocusRange
It also maintains a repository of paraxial data.
parax_datatuple of ParaxData
do_aiming_default = True
spectral_region
110 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
pupil
field_of_view
defocus
set_from_list(dl)
set_from_specsheet(ss)
sync_to_restore(opt_model)
update_model(**kwargs)
lookup_fld_wvl_focus(fi, wl=None, fr=0.0)returns field, wavelength and defocus data
Parameters
• fi (int) – index into the field_of_view list of Fields
• wl (int) – index into the spectral_region list of wavelengths
• fr (float) – focus range parameter, -1.0 to 1.0
Returns
(fld, wvl, foc)
• fld - Field instance for field_of_view[fi]
• wvl - wavelength in nm
• foc - focus shift from image interface
obj_coords(fld)
list_first_order_data()
list_parax_trace(**kwargs)
class WvlSpec(wlwts=[(’d’, 1.0)], ref_wl=0, do_init=True, **kwargs)Bases: object
Class defining a spectral region
A spectral region is a list of wavelengths (in nm) and corresponding weights. The central wavelength of thespectral region is central_wvl. The index into the wavelength list for central_wvl is reference_wvl.
central_wvl
set_from_list(wlwts)
sync_to_restore(optical_spec)
set_from_specsheet(ss)
update_model(**kwargs)
add(wl, wt)
calc_colors()
class PupilSpec(parent, key=(’object’, ’pupil’), value=1.0)Bases: object
Aperture specification
key‘aperture’, ‘object’|’image’, ‘pupil’|’NA’|’f/#’
13.1. Subpackages 111
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
valuesize of the pupil
pupil_rayslist of relative pupil coordinates for pupil limiting rays
ray_labelslist of string labels for pupil_rays
default_pupil_rays = [[0.0, 0.0], [1.0, 0.0], [-1.0, 0.0], [0.0, 1.0], [0.0, -1.0]]
default_ray_labels = ['00', '+X', '-X', '+Y', '-Y']
sync_to_restore(optical_spec)
set_from_specsheet(ss)
get_input_for_specsheet()
update_model(**kwargs)
get_pupil_type()
mutate_pupil_type(new_pupil_type)
class FieldSpec(parent, key=(’object’, ’angle’), value=0.0, flds=[0.0], is_relative=False, do_init=True,**kwargs)
Bases: object
Field of view specification
key‘field’, ‘object’|’image’, ‘height’|’angle’
valuemaximum field, per the key
fieldslist of Field instances
is_relativeif True, fields are relative to max field
sync_to_restore(optical_spec)
set_from_list(flds)
set_from_specsheet(ss)
get_input_for_specsheet()
update_model(**kwargs)
get_field_type()
mutate_field_type(new_field_type)
obj_coords(fld)
max_field()calculates the maximum field of view
Returns magnitude of maximum field, maximum Field instance
class Field(x=0.0, y=0.0, wt=1.0)Bases: object
a single field point, largely a data container
112 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
xx field component
yy field component
vux+x vignetting factor
vuy+y vignetting factor
vlx-x vignetting factor
vly-y vignetting factor
wtfield weight
aim_ptx, y chief ray coords on the paraxial entrance pupil plane
chief_rayray package for the ray from the field point throught the center of the aperture stop, traced in the centralwavelength
ref_spherea tuple containing (image_pt, ref_dir, ref_sphere_radius)
update()
apply_vignetting(pupil)
class FocusRange(focus_shift=0.0, defocus_range=0.0)Bases: object
Focus range specification
focus_shiftfocus shift (z displacement) from nominal image interface
defocus_range+/- half the total focal range, from the focus_shift position
set_from_specsheet(ss)
update()
get_focus(fr=0.0)return focus position for input focus range parameter
Parameters fr (float) – focus range parameter, -1.0 to 1.0
Returns focus position for input focus range parameter
rayoptics.raytr.raytrace module
Functions to support ray tracing a sequential optical model
bend(d_in, normal, n_in, n_out)refract incoming direction, d_in, about normal
13.1. Subpackages 113
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
reflect(d_in, normal)reflect incoming direction, d_in, about normal
phase(ifc, inc_pt, d_in, normal, z_dir, wvl, n_in, n_out)apply phase shift to incoming direction, d_in, about normal
trace(seq_model, pt0, dir0, wvl, **kwargs)fundamental raytrace function
Parameters
• seq_model – the sequential model to be traced
• pt0 – starting point in coords of first interface
• dir0 – starting direction cosines in coords of first interface
• wvl – wavelength in nm
• eps – accuracy tolerance for surface intersection calculation
Returns
(ray, op_delta, wvl)
• ray is a list for each interface in path_pkg of these elements: [pt, after_dir, after_dst, nor-mal]
– pt: the intersection point of the ray
– after_dir: the ray direction cosine following the interface
– after_dst: after_dst: the geometric distance to the next interface
– normal: the surface normal at the intersection point
• op_delta - optical path wrt equally inclined chords to the optical axis
• wvl - wavelength (in nm) that the ray was traced in
trace_raw(path, pt0, dir0, wvl, eps=1e-12, **kwargs)fundamental raytrace function
Parameters
• path – an iterator containing interfaces and gaps to be traced. for each iteration, the se-quence or generator should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir
• pt0 – starting point in coords of first interface
• dir0 – starting direction cosines in coords of first interface
• wvl – wavelength in nm
• eps – accuracy tolerance for surface intersection calculation
Returns
(ray, op_delta, wvl)
• ray is a list for each interface in path of these elements: [pt, after_dir, after_dst, normal]
– pt: the intersection point of the ray
– after_dir: the ray direction cosine following the interface
– after_dst: the geometric distance to the next interface
– normal: the surface normal at the intersection point
114 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• op_delta - optical path wrt equally inclined chords to the optical axis
• wvl - wavelength (in nm) that the ray was traced in
calc_path_length(eic, offset=0)given eic array, compute path length between outer surfaces
Parameters
• eic – equally inclined chord array
• offset (int) – beginning index of eic array wrt the object interface
Returns path length
Return type float
eic_distance(r, r0)calculate equally inclined chord distance between 2 rays
Parameters
• r – (p, d), where p is a point on the ray r and d is the direction cosine of r
• r0 – (p0, d0), where p0 is a point on the ray r0 and d0 is the direction cosine of r0
Returns distance along r from equally inclined chord point to p
Return type float
eic_distance_from_axis(r, z_dir)calculate equally inclined chord distance between a ray and the axis
Parameters
• r – (p, d), where p is a point on the ray r and d is the direction cosine of r
• z_dir – direction of propagation of ray segment, +1 or -1
Returns distance along r from equally inclined chord point to p
Return type float
transfer_to_exit_pupil(interface, ray_seg, exp_dst_parax)Given the exiting interface and chief ray data, return exit pupil ray coords.
Parameters
• interface – the exiting :class:’~.Interface’ for the path sequence
• ray_seg – ray segment exiting from interface
• exp_dst_parax – z distance to the paraxial exit pupil
Returns
(exp_pt, exp_dir, exp_dst)
• exp_pt - ray intersection with exit pupil plane
• exp_dir - direction cosine of the ray in exit pupil space
• exp_dst - distance from interface to exit pupil pt
calc_optical_path(ray, path)computes equally inclined chords and path info for ray
Parameters
• ray – ray data for traced ray
13.1. Subpackages 115
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• path – an iterator containing interfaces and gaps to be traced. for each iteration, the se-quence or generator should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir
Returns
ray_op
• ray_op - the optical path between the first and last optical surfaces
calc_delta_op_via_eic(ray, path)computes equally inclined chords and path info for ray
Parameters
• ray – ray data for traced ray
• path – an iterator containing interfaces and gaps to be traced. for each iteration, the se-quence or generator should return a list containing: Intfc, Gap, Trfm, Index, Z_Dir
Returns
(eic, op_delta)
• eic - list of [n_before, eic_dst_before, n_after, eic_dst_after, dW]
• op_delta - optical path wrt equally inclined chords to the optical axis
eic_path_accumulation(ray, rndx, lcl_tfrms, z_dir)computes equally inclined chords and path info for ray
Parameters
• ray – ray data for traced ray
• rndx – refractive index array
• lcl_tfrms – local surface interface transformation data
• z_dir – z direction array
Returns
(eic, op_delta)
• eic - list of [n_before, eic_dst_before, n_after, eic_dst_after, dW]
• op_delta - optical path wrt equally inclined chords to the optical axis
rayoptics.raytr.sampler module
Various generators and utilities for producing 2d distributions
grid_ray_generator(grid_rng)Generator function to produce a 2d square regular grid.
Parameters
• grid_rng – start, stop, num
• start – 2d numpy array of lower left grid coords
• stop – 2d numpy array of upper right grid coords
• num – the number of samples along each axis
A sample input might be: grid_start = np.array([-1., -1.]) grid_stop = np.array([1., 1.]) grid_rng = grid_start,grid_stop, num_rays
116 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
csd_grid_ray_generator(grid_rng)
polar_grid_ray_generator(grid_rng)
phi(d)
R_2_quasi_random_generator(n)A 2d sequence based on a R**2 quasi-random sequence
See The Unreasonable Effectiveness of Quasirandom Sequences <http://extremelearning.com.au/unreasonable-effectiveness-of-quasirandom-sequences/ >
concentric_sample_disk(u, offset=True)Map a 2d unit square sample to the unit disk.
create_generator(sampler, *sampler_args, mapper=None, **kwargs)
rayoptics.raytr.trace module
Supports model ray tracing in terms of relative aperture and field.
class RayPkgBases: tuple
Ray and optical path length, plus wavelength
opoptical path length between pupils
raylist of RaySegs
wvlwavelength (in nm) that the ray was traced in
class RaySegBases: tuple
ray intersection and transfer data
dray direction cosine following the interface
dstgeometric distance to next point of incidence
nrmlsurface normal vector at the point of incidence
pthe point of incidence
ray_pkg(ray_pkg)return a pandas.Series containing a ray package (RayPkg)
ray_df(ray)return a pandas.DataFrame containing ray data
class RSeg(inc_pt, after_dir, after_dst, normal, phase=0.0)Bases: object
list_ray(ray_obj, tfrms=None, start=0)pretty print a ray either in local or global coordinates
13.1. Subpackages 117
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
trace(seq_model, pt0, dir0, wvl, **kwargs)returns (ray, ray_opl, wvl)
Parameters
• seq_model – the SequentialModel to be traced
• pt0 – starting coordinate at object interface
• dir0 – starting direction cosines following object interface
• wvl – ray trace wavelength in nm
• **kwargs – keyword arguments
Returns
(ray, op_delta, wvl)
• ray is a list for each interface in path_pkg of these elements: [pt, after_dir, after_dst, nor-mal]
– pt: the intersection point of the ray
– after_dir: the ray direction cosine following the interface
– after_dst: after_dst: the geometric distance to the next interface
– normal: the surface normal at the intersection point
• op_delta - optical path wrt equally inclined chords to the optical axis
• wvl - wavelength (in nm) that the ray was traced in
trace_base(opt_model, pupil, fld, wvl, **kwargs)Trace ray specified by relative aperture and field point.
Parameters
• opt_model – instance of OpticalModel to trace
• pupil – relative pupil coordinates of ray
• fld – instance of Field
• wvl – ray trace wavelength in nm
• **kwargs – keyword arguments
Returns
(ray, op_delta, wvl)
• ray is a list for each interface in path_pkg of these elements: [pt, after_dir, after_dst, nor-mal]
– pt: the intersection point of the ray
– after_dir: the ray direction cosine following the interface
– after_dst: after_dst: the geometric distance to the next interface
– normal: the surface normal at the intersection point
• op_delta - optical path wrt equally inclined chords to the optical axis
• wvl - wavelength (in nm) that the ray was traced in
118 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
iterate_ray(opt_model, ifcx, xy_target, fld, wvl, **kwargs)iterates a ray to xy_target on interface ifcx, returns aim points on the paraxial entrance pupil plane
If idcx is None, i.e. a floating stop surface, returns xy_target.
If the iteration fails, a TraceError will be raised
trace_with_opd(opt_model, pupil, fld, wvl, foc, **kwargs)returns (ray, ray_opl, wvl, opd)
trace_boundary_rays_at_field(opt_model, fld, wvl, use_named_tuples=False)returns a list of RayPkgs for the boundary rays for field fld
boundary_ray_dict(opt_model, rim_rays)
trace_boundary_rays(opt_model, **kwargs)
trace_ray_list_at_field(opt_model, ray_list, fld, wvl, foc)returns a list of ray pandas.DataFrame for the ray_list at field fld
trace_field(opt_model, fld, wvl, foc)returns a pandas.DataFrame with the boundary rays for field fld
trace_all_fields(opt_model)returns a pandas.DataFrame with the boundary rays for all fields
trace_chief_ray(opt_model, fld, wvl, foc)Trace a chief ray for fld and wvl, returning the ray_pkg and exit pupil segment.
trace_fan(opt_model, fan_rng, fld, wvl, foc, img_filter=None, **kwargs)
trace_grid(opt_model, grid_rng, fld, wvl, foc, img_filter=None, form=’grid’, append_if_none=True,**kwargs)
aim_chief_ray(opt_model, fld, wvl=None)aim chief ray at center of stop surface and save results on fld
apply_paraxial_vignetting(opt_model)
setup_pupil_coords(opt_model, fld, wvl, foc, image_pt=None)
setup_canonical_coords(opt_model, fld, wvl, image_pt=None)
trace_astigmatism_coddington_fan(opt_model, fld, wvl, foc)calculate astigmatism by Coddington trace at fld
trace_coddington_fan(opt_model, ray_pkg, foc=None)astigmatism calculation via Coddington trace
Note: spherical surfaces only
intersect_2_lines(P1, V1, P2, V2)intersect 2 non-parallel lines, returning distance from P1
s = ((P2 - P1) x V1).(V1 x V2)/|(V1 x V2)|**2
Weisstein, Eric W. “Line-Line Intersection.” From MathWorld–A Wolfram Web Resource.
trace_astigmatism(opt_model, fld, wvl, foc, dx=0.001, dy=0.001)calculate astigmatism by tracing close rays about the chief ray at fld
This function implicitly assumes that the fld point is on a plane of symmetry, i.e. the system is rotationallysymmetric, bilaterally symmetric, or quad symmetric. No check is done to ensure this.
Parameters
13.1. Subpackages 119
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• opt_model – the optical model
• fld – a Field object
• wvl – wavelength in nm
• foc – defocus amount
• dx – delta in pupil coordinates for x/sagittal direction
• dy – delta in pupil coordinates for y/tangential direction
Returns sagittal and tangential focus shifts at fld
Return type tuple
rayoptics.raytr.traceerror module
Support for ray trace exception handling
exception TraceErrorBases: Exception
Exception raised when ray tracing a model
exception TraceMissedSurfaceError(ifc=None, prev_seg=None)Bases: rayoptics.raytr.traceerror.TraceError
Exception raised when ray misses a surface
exception TraceTIRError(inc_dir, normal, prev_indx, follow_indx)Bases: rayoptics.raytr.traceerror.TraceError
Exception raised when ray TIRs on a surface
exception TraceEvanescentRayError(ifc, int_pt, inc_dir, normal, prev_indx, follow_indx)Bases: rayoptics.raytr.traceerror.TraceError
Exception raised when ray diffracts evanescently at a surface
exception TraceRayBlockedError(ifc, int_pt, inc_dir, prev_indx, follow_indx)Bases: rayoptics.raytr.traceerror.TraceError
Exception raised when ray is blocked by an aperture on a surface
13.1.10 rayoptics.seq package
Package for sequential modeling of optical systems
The seq subpackage provides core classes and functions for sequential optical modeling. A sequential optical modelis a sequence of surfaces and gaps.
The sequential model has this structure
IfcObj Ifc1 Ifc2 Ifc3 ... Ifci-1 IfcImg\ / \ / \ / \ /GObj G1 G2 Gi-1
where
• Ifc is a Interface instance
• G is a Gap instance
120 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
There are N interfaces and N-1 gaps. The initial configuration has an object and image Surface and an object gap.
The Interface API supports implementation of an optical action, such as refraction, reflection, scatter, diffraction, etc.The Interface may be realized as a physical profile separating the adjacent gaps or an idealized object, such as a thinlens or 2 point HOE.
The Gap class maintains a simple separation (z translation) and the medium filling the gap. More complex coordinatetransformations are handled through the Interface API.
Modules comprising the sequential optical modeling capability include:
• Sequential optical model: sequential
• Interface and gap modules: interface gap medium
• Modules for specialized optical behavior: twoconicmirrors
Submodules
rayoptics.seq.gap module
Gap container class
class Gap(t=0.0, med=Air())Bases: object
Gap container class.
The gap class represents the space between 2 surfaces. It contains the media definition for the space and a (z)displacement between the adjacent surfaces.
The most common use case is an optical system with surfaces centered on a common axis. The Gap structure im-plements this case in the simplest manner. More complicated transformations between surfaces are implementedusing transformations associated with the surfaces themselves.
thithe length (along z) of the gap
mediuma Medium or a catalog glass instance
sync_to_restore(seq_model)
apply_scale_factor(scale_factor)
rayoptics.seq.interface module
Base class for Interfaces
class Interface(interact_mode=’transmit’, delta_n=0.0, max_ap=1.0, decenter=None,phase_element=None, **kwargs)
Bases: object
Basic part of a sequential model
The SequentialModel is a sequence of Interfaces and Gaps. The Interface class is a boundary between twoadjacent Gaps and their associated media. It specifies several methods that must be implemented to model theoptical behavior of the interface.
The Interface class addresses the following use cases:
• support for ray intersection calculation during ray tracing
13.1. Subpackages 121
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
– interfaces can be tilted and decentered wrt the adjacent gaps
• support for getting and setting the optical power of the interface
• support for various optical properties, i.e. does it reflect or transmit
• supports a basic idea of size, the max_aperture
interact_mode‘transmit’ | ‘reflect’ | ‘dummy’
delta_nrefractive index difference across the interface
decenterDecenterData for the interface, if specified
max_aperturethe maximum aperture radius on the interface
update()
interface_type()
sync_to_restore(opt_model)
profile_cv
set_optical_power(pwr, n_before, n_after)
surface_od()
set_max_aperture(max_ap)max_ap is the max aperture radius
intersect(p0, d, eps=1e-12, z_dir=1)Intersect an Interface, starting from an arbitrary point.
Parameters
• p0 – start point of the ray in the interface’s coordinate system
• d – direction cosine of the ray in the interface’s coordinate system
• z_dir – +1 if propagation positive direction, -1 if otherwise
• eps – numeric tolerance for convergence of any iterative procedure
Returns distance to intersection point s1, intersection point p
Return type tuple
Raises TraceMissedSurfaceError
normal(p)Returns the unit normal of the interface at point p.
phase(pt, in_dir, srf_nrml, z_dir, wl, n_in, n_out)Returns a diffracted ray direction and phase increment.
Parameters
• pt – point of incidence in Interface coordinates
• in_dir – direction cosine of incident ray
• srf_nrml – Interface surface normal at pt
• z_dir – -1 if after an odd # of reflections, +1 otherwise
122 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
• wl – wavelength in nm for ray, defaults to ref_wl
• n_in – refractive index preceding the interface
• n_out – refractive index following the interface
Returns
(out_dir, dW)
• out_dir: direction cosine of the out going ray
• dW: phase added by diffractive interaction
apply_scale_factor(scale_factor)
rayoptics.seq.medium module
Module for simple optical media definitions
glass_encode(n, v)
glass_decode(gc)
class Medium(nd, lbl, cat=”)Bases: object
Constant refractive index medium.
name()
catalog_name()
rindex(wv_nm)returns the interpolated refractive index at wv_nm
Parameters wv_nm – the wavelength in nm for the refractive index query
Returns the refractive index at wv_nm
Return type float
class AirBases: rayoptics.seq.medium.Medium
Optical definition for air (low fidelity definition)
name()
catalog_name()
class Glass(nd=1.5168, vd=64.17, mat=”, cat=”)Bases: rayoptics.seq.medium.Medium
Optical medium defined by a glass code, i.e. index - V number pair
sync_to_restore()
glass_code()
name()
rindex(wv_nm)returns the interpolated refractive index at wv_nm
Parameters wv_nm – the wavelength in nm for the refractive index query
Returns the refractive index at wv_nm
13.1. Subpackages 123
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Return type float
update(nd, vd)
class InterpolatedGlass(label, pairs=None, rndx=None, wvls=None, cat=”)Bases: object
Optical medium defined by a list of wavelength/index pairs
labelrequired string identifier for the material
wvlslist of wavelenghts in nm, used as x axis
rndxlist of refractive indices corresponding to the values in wvls
rindex_interpthe interpolation function
sync_to_restore()rebuild interpolating function
update()
glass_code()
name()
catalog_name()returns the glass catalog name
rindex(wv_nm)returns the interpolated refractive index at wv_nm
Parameters wvl – either the wavelength in nm or a string with a spectral line identifier. for therefractive index query
Returns the refractive index at wv_nm
Return type float
Raises KeyError – if wvl is not in the spectra dictionary
class GlassHandlerBase(filename)Bases: object
Base class for glass matching capability.
This class is used to match catalog glasses to input glass names. It is implemented as a class for ease of use byfile importers. If the glass can be matched up with an existing opticalglass catalog, the glass is instantiatedand entered into the model. If the glass cannot be found, a search for a .smx file of the same name as the modelfile is made. If found, it is a JSON file with a dict that provides an eval() string to create an instance to replacethe missing glass name. If this file isn’t found, it is created and contains a JSON template of a dict that has themissing glass names as keys; the values are the number of times the glass occurs in the file. These values shouldbe replaced with the desired eval() string to create a replacement glass.
Subclasses, e.g. used for different importers, should implement a single method that can be called during theimport process to return a glass instance given an input string.
load_replacements(filename)
save_replacements()If unfound glasses, write smx template file.
124 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
find_glass(name, catalog, always=True)find name glass or a substitute or, if always is True, n=1.5
find_6_digit_code(name)process name as a 6 digit glass code
find_substitute_glass(name)Try to find a similar glass to name.
handle_glass_not_found(name)Record missing glasses or create new replacement glass instances.
rayoptics.seq.sequential module
Manager class for a sequential optical model
class SequentialModel(opt_model, do_init=True, **kwargs)Bases: object
Manager class for a sequential optical model
A sequential optical model is a sequence of surfaces and gaps.
The sequential model has this structure
IfcObj Ifc1 Ifc2 Ifc3 ... Ifci-1 IfcImg\ / \ / \ / \ /GObj G1 G2 Gi-1
where
• Ifc is a Interface instance
• G is a Gap instance
There are N interfaces and N-1 gaps. The initial configuration has an object and image Surface and an objectgap.
The Interface API supports implementation of an optical action, such as refraction, reflection, scatter, diffraction,etc. The Interface may be realized as a physical profile separating the adjacent gaps or an idealized object, suchas a thin lens or 2 point HOE.
The Gap class maintains a simple separation (z translation) and the medium filling the gap. More complexcoordinate transformations are handled through the Interface API.
opt_modelparent optical model
ifcslist of Interface
gapslist of Gap
lcl_tfrmsforward transform, interface to interface
rndxa list with refractive indices for all wvls
z_dir-1 if gap follows an odd number of reflections, otherwise +1
13.1. Subpackages 125
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
gbl_tfrmsglobal coordinates of each interface wrt the 1st interface
stop_surfaceindex of stop interface
Type int
cur_surfaceinsertion index for next interface
Type int
reset()
get_num_surfaces()
path(wl=None, start=None, stop=None, step=1)returns an iterable path tuple for a range in the sequential model
Parameters
• wl – wavelength in nm for path, defaults to central wavelength
• start – start of range
• stop – first value beyond the end of the range
• step – increment or stride of range
Returns (ifcs, gaps, lcl_tfrms, rndx, z_dir)
reverse_path(wl=None, start=None, stop=None, step=-1)returns an iterable path tuple for a range in the sequential model
Parameters
• wl – wavelength in nm for path, defaults to central wavelength
• start – start of range
• stop – first value beyond the end of the range
• step – increment or stride of range
Returns (ifcs, gaps, lcl_tfrms, rndx, z_dir)
calc_ref_indices_for_spectrum(wvls)returns a list with refractive indices for all wvls
Parameters wvls – list of wavelengths in nm
central_wavelength()returns the central wavelength in nm of the model’s WvlSpec
index_for_wavelength(wvl)returns index into rndx array for wavelength wvl in nm
central_rndx(i)returns the central refractive index of the model’s WvlSpec
get_surface_and_gap(srf=None)
set_cur_surface(s)
set_stop()sets the stop surface to the current surface
126 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
insert(ifc, gap, prev=False)insert surf and gap at the cur_gap edge of the sequential model graph
remove(*args, prev=False)Remove surf and gap at cur_surface or an input index argument.
To avoid invalid sequence states, both an interface and a gap must be removed at the same time. Theprev argument, if True, removes the gap preceding the interface. The default behavior is to remove thefollowing gap.
remove_node(e_node)
add_surface(surf_data, **kwargs)add a surface where surf_data is a list that contains:
[curvature, thickness, refractive_index, v-number, semi-diameter]
The curvature entry is interpreted as radius if radius_mode is True
The thickness is the signed thickness
The refractive_index, v-number entry can have several forms:
• refractive_index, v-number
• refractive_index only -> constant index model
• ‘REFL’ -> set interact_mode to ‘reflect’
• glass_name, catalog_name as 1 or 2 strings
• blank -> defaults to air
The semi-diameter entry is optional
sync_to_restore(opt_model)
update_model(**kwargs)
apply_scale_factor(scale_factor)
set_from_specsheet(specsheet)
insert_surface_and_gap()
update_reflections(start)update interfaces and gaps following insertion of a mirror
get_rndx_and_imode()get list of signed refractive index and interact mode for sequence.
surface_label_list()list of surface labels or surface number, if no label
list_model(path=None)
list_model_old()
list_gaps()
list_surfaces()
list_surface_and_gap(ifc, gp=None)Returns cvr, thi, med, imode, sd for input ifc and gap.
list_decenters(full=False)List decenter data and gap separations.
13.1. Subpackages 127
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Parameters full – lists all values if True, else only y offset and alpha tilt
list_sg()List decenter data and gap separations.
list_elements()
trace_fan(fct, fi, xy, num_rays=21, **kwargs)xy determines whether x (=0) or y (=1) fan
trace_grid(fct, fi, wl=None, num_rays=21, form=’grid’, append_if_none=True, **kwargs)fct is applied to the raw grid and returned as a grid
trace_wavefront(fld, wvl, foc, num_rays=32)
set_clear_apertures_paraxial()
set_clear_apertures()
trace(pt0, dir0, wvl, **kwargs)
compute_global_coords(glo=1)Return global surface coordinates (rot, t) wrt surface glo.
compute_local_transforms(seq=None, step=1)Return forward surface coordinates (r.T, t) for each interface.
find_matching_ifcs()
gen_sequence(surf_data_list, **kwargs)create a sequence iterator from the surf_data_list
Parameters
• surf_data_list – a list of lists containing: [curvature, thickness, refractive_index, v-number]
• **kwargs – keyword arguments
Returns (ifcs, gaps, rndx, lcl_tfrms, z_dir)
create_surface_and_gap(surf_data, radius_mode=False, prev_medium=None, wvl=550.0, **kwargs)create a surface and gap where surf_data is a list that contains:
[curvature, thickness, refractive_index, v-number, semi-diameter]
The curvature entry is interpreted as radius if radius_mode is True
The thickness is the signed thickness
The refractive_index, v-number entry can have several forms:
• refractive_index, v-number
• refractive_index only -> constant index model
• ‘REFL’ -> set interact_mode to ‘reflect’
• glass_name, catalog_name as 1 or 2 strings
• blank -> defaults to air
The semi-diameter entry is optional
128 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.seq.twoconicmirrors module
calculate conic constants for different 2 mirror configurations
cassegrain(lens_package)calculate the conic constants for a cassegrain telescope
Parameters lens_package – a tuple or a ParaxialModel. If it’s a tuple:
• the first element is a ParaxialModel
• the second element is a tuple with the begining and ending indicies into lens model lists
Returns the conic constants of the primary and secondary mirrors
dall_kirkham(lens_package)calculate the conic constants for a dall-kirkham telescope
Parameters lens_package – a tuple or a ParaxialModel. If it’s a tuple:
• the first element is a ParaxialModel
• the second element is a tuple with the begining and ending indicies into lens model lists
Returns the conic constants of the primary and secondary mirrors
ritchey_chretien(lens_package)calculate the conic constants for a ritchey-chretien telescope
Parameters lens_package – a tuple or a ParaxialModel. If it’s a tuple:
• the first element is a ParaxialModel
• the second element is a tuple with the begining and ending indicies into lens model lists
Returns the conic constants of the primary and secondary mirrors
spheres(lens_package)function to revert the conic constants to spherical surfaces
Parameters lens_package – a tuple or a ParaxialModel. If it’s a tuple:
• the first element is a ParaxialModel
• the second element is a tuple with the begining and ending indicies into lens model lists
Returns the conic constants of the primary and secondary mirrors
13.1.11 rayoptics.util package
package supplying utility functions for math and numpy support
The util subpackage provides miscellaneous functions for geometric calculations, color calculations and anythingelse that doesn’t have an obvious home. These include:
• miscellaneous math functions, misc_math line_intersection
• support for color handling, colors colour_system
• spectral line conversion with get_wavelength() in spectral_lines
• a 2D dict with M x N keys, dict2d
13.1. Subpackages 129
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Submodules
rayoptics.util.colors module
manage light and dark interface color schemes
accent_colors(is_dark=True)
foreground_background(is_dark=True)
rayoptics.util.colour_system module
converting a spectrum to a colour
code from the web blog: https://scipython.com/blog/converting-a-spectrum-to-a-colour/
@author: Christian Hill
xyz_from_xy(x, y)Return the vector (x, y, 1-x-y).
class ColourSystem(red, green, blue, white)Bases: object
A class representing a colour system.
A colour system defined by the CIE x, y and z=1-x-y coordinates of its three primary illuminants and its “whitepoint”.
TODO: Implement gamma correction
path = PosixPath('/home/docs/checkouts/readthedocs.org/user_builds/ray-optics/checkouts/latest/src/rayoptics/util')
cmf = array([[1.4000e-03, 0.0000e+00, 6.5000e-03], [2.2000e-03, 1.0000e-04, 1.0500e-02], [4.2000e-03, 1.0000e-04, 2.0100e-02], [7.6000e-03, 2.0000e-04, 3.6200e-02], [1.4300e-02, 4.0000e-04, 6.7900e-02], [2.3200e-02, 6.0000e-04, 1.1020e-01], [4.3500e-02, 1.2000e-03, 2.0740e-01], [7.7600e-02, 2.2000e-03, 3.7130e-01], [1.3440e-01, 4.0000e-03, 6.4560e-01], [2.1480e-01, 7.3000e-03, 1.0391e+00], [2.8390e-01, 1.1600e-02, 1.3856e+00], [3.2850e-01, 1.6800e-02, 1.6230e+00], [3.4830e-01, 2.3000e-02, 1.7471e+00], [3.4810e-01, 2.9800e-02, 1.7826e+00], [3.3620e-01, 3.8000e-02, 1.7721e+00], [3.1870e-01, 4.8000e-02, 1.7441e+00], [2.9080e-01, 6.0000e-02, 1.6692e+00], [2.5110e-01, 7.3900e-02, 1.5281e+00], [1.9540e-01, 9.1000e-02, 1.2876e+00], [1.4210e-01, 1.1260e-01, 1.0419e+00], [9.5600e-02, 1.3900e-01, 8.1300e-01], [5.8000e-02, 1.6930e-01, 6.1620e-01], [3.2000e-02, 2.0800e-01, 4.6520e-01], [1.4700e-02, 2.5860e-01, 3.5330e-01], [4.9000e-03, 3.2300e-01, 2.7200e-01], [2.4000e-03, 4.0730e-01, 2.1230e-01], [9.3000e-03, 5.0300e-01, 1.5820e-01], [2.9100e-02, 6.0820e-01, 1.1170e-01], [6.3300e-02, 7.1000e-01, 7.8200e-02], [1.0960e-01, 7.9320e-01, 5.7300e-02], [1.6550e-01, 8.6200e-01, 4.2200e-02], [2.2570e-01, 9.1490e-01, 2.9800e-02], [2.9040e-01, 9.5400e-01, 2.0300e-02], [3.5970e-01, 9.8030e-01, 1.3400e-02], [4.3340e-01, 9.9500e-01, 8.7000e-03], [5.1210e-01, 1.0000e+00, 5.7000e-03], [5.9450e-01, 9.9500e-01, 3.9000e-03], [6.7840e-01, 9.7860e-01, 2.7000e-03], [7.6210e-01, 9.5200e-01, 2.1000e-03], [8.4250e-01, 9.1540e-01, 1.8000e-03], [9.1630e-01, 8.7000e-01, 1.7000e-03], [9.7860e-01, 8.1630e-01, 1.4000e-03], [1.0263e+00, 7.5700e-01, 1.1000e-03], [1.0567e+00, 6.9490e-01, 1.0000e-03], [1.0622e+00, 6.3100e-01, 8.0000e-04], [1.0456e+00, 5.6680e-01, 6.0000e-04], [1.0026e+00, 5.0300e-01, 3.0000e-04], [9.3840e-01, 4.4120e-01, 2.0000e-04], [8.5440e-01, 3.8100e-01, 2.0000e-04], [7.5140e-01, 3.2100e-01, 1.0000e-04], [6.4240e-01, 2.6500e-01, 0.0000e+00], [5.4190e-01, 2.1700e-01, 0.0000e+00], [4.4790e-01, 1.7500e-01, 0.0000e+00], [3.6080e-01, 1.3820e-01, 0.0000e+00], [2.8350e-01, 1.0700e-01, 0.0000e+00], [2.1870e-01, 8.1600e-02, 0.0000e+00], [1.6490e-01, 6.1000e-02, 0.0000e+00], [1.2120e-01, 4.4600e-02, 0.0000e+00], [8.7400e-02, 3.2000e-02, 0.0000e+00], [6.3600e-02, 2.3200e-02, 0.0000e+00], [4.6800e-02, 1.7000e-02, 0.0000e+00], [3.2900e-02, 1.1900e-02, 0.0000e+00], [2.2700e-02, 8.2000e-03, 0.0000e+00], [1.5800e-02, 5.7000e-03, 0.0000e+00], [1.1400e-02, 4.1000e-03, 0.0000e+00], [8.1000e-03, 2.9000e-03, 0.0000e+00], [5.8000e-03, 2.1000e-03, 0.0000e+00], [4.1000e-03, 1.5000e-03, 0.0000e+00], [2.9000e-03, 1.0000e-03, 0.0000e+00], [2.0000e-03, 7.0000e-04, 0.0000e+00], [1.4000e-03, 5.0000e-04, 0.0000e+00], [1.0000e-03, 4.0000e-04, 0.0000e+00], [7.0000e-04, 2.0000e-04, 0.0000e+00], [5.0000e-04, 2.0000e-04, 0.0000e+00], [3.0000e-04, 1.0000e-04, 0.0000e+00], [2.0000e-04, 1.0000e-04, 0.0000e+00], [2.0000e-04, 1.0000e-04, 0.0000e+00], [1.0000e-04, 0.0000e+00, 0.0000e+00], [1.0000e-04, 0.0000e+00, 0.0000e+00], [1.0000e-04, 0.0000e+00, 0.0000e+00], [0.0000e+00, 0.0000e+00, 0.0000e+00]])
xyz_to_rgb(xyz, out_fmt=None)Transform from xyz to rgb representation of colour.
The output rgb components are normalized on their maximum value. If xyz is out the rgb gamut, it isdesaturated until it comes into gamut.
By default, fractional rgb components are returned; if out_fmt=’html’, the HTML hex string ‘#rrggbb’ isreturned.
rgb_to_hex(rgb)Convert from fractional rgb values to HTML-style hex string.
spec_to_xyz(spec)Convert a spectrum to an xyz point.
The spectrum must be on the same grid of points as the colour-matching function, self.cmf: 380-780 nmin 5 nm steps.
wvl_to_xyz(wv)Convert a wavelength (nm) to an xyz point.
The wavelength must be on the same grid of points as the colour-matching function, self.cmf: 380-780 nmin 5 nm steps.
spec_to_rgb(spec, out_fmt=None)Convert a spectrum to an rgb value.
wvl_to_rgb(wv, out_fmt=None)Convert a wavelength to an rgb value.
130 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
relative_colorimetric_gamut_mapping(xyz)Apply relative colorimetric gamut mapping to XYZ and return RGB
planck(lam, T)Returns the spectral radiance of a black body at temperature T.
Returns the spectral radiance, B(lam, T), in W.sr-1.m-2 of a black body at temperature T (in K) at a wavelengthlam (in nm), using Planck’s law.
rayoptics.util.dict2d module
dict2D constructs a M x N dict using row_keys and col_keys as keys
dict2D(row_keys, col_keys)returns a 2D dictionary with M row_keys and N col_keys
row(dict_2d, row_key)returns a dict of the contents of row row_key of dict_2d
col(dict_2d, col_key)returns a dict of the contents of column col_key of dict_2d
num_items_by_type(dict_2d, row_keys, col_keys)return a dict of the number of items in each row/col of dict_2d
num_items_by_cell(dict_2d, row_keys, col_keys)return a list of the number of items in each cell of dict_2d
rayoptics.util.line_intersection module
line(p1, p2)
intersection(L1, L2)
get_intersect(a1, a2, b1, b2)Returns the point of intersection of the lines passing through a2,a1 and b2,b1. a1: [x, y] a point on the first linea2: [x, y] another point on the first line b1: [x, y] a point on the second line b2: [x, y] another point on thesecond line
do_intersect(a1, a2, b1, b2, soln, delta)
intersect_with_3lines(pt, wht, bg, gr, rb)
rayoptics.util.misc_math module
miscellaneous functions for working with numpy vectors and floats
normalize(v)return normalized version of input vector v
distance_sqr_2d(pt0, pt1)return distance squared between 2d points pt0 and pt1
perpendicular_distance_2d(pt, pt1, pt2)return perpendicular distance of pt from the line between pt1 and pt2
perpendicular_to_radial(pt, pt2)return perpendicular distance of pt from the line between the origin and pt2
13.1. Subpackages 131
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
perpendicular_to_line(pt, pt1, pt2)return perpendicular distance of pt from the line between pt1 and pt2
perpendicular_from_origin(pt1, pt2)return perpendicular distance of the origin from the line between pt1 and pt2
projected_point_on_line(pt, pt1, pt2)
projected_point_on_radial_line(pt, radial_pt)
projected_point_on_radial_line_full(pt, radial_pt)
euler2opt(e)convert right-handed euler angles to optical design convention, i.e. alpha and beta are left-handed
isanumber(a)returns true if input a can be converted to floating point number
transpose(mat)transposes a m x n input list and returns the result
circle_intersection_area(ra, rb, d)return the area of the intersection of 2 circles
Parameters
• ra – radius of first circle
• rb – radius of second circle
• d – separation of the circles’ centers of curvature
Returns area of the circle intersection
Weisstein, Eric W. “Circle-Circle Intersection.” From MathWorld–A Wolfram Web Resource.
compute_tangent_point_to_circle(CofC, r, pt)return the area of the intersection of 2 circles
Parameters
• CofC – center of curvature of circle (2d numpy array)
• r – radius of circle
• pt – 2d numpy array of point outside of circle
Returns the 2 tangent points for lines from pt to circle
gboffi. “How to find the equation of a line, tangent to a circle, that passes through a given external point.”StackExchange (version: 2019-05-30)
rayoptics.util.rgb2mpl module
convert RGB data to matplotlib format
rgb2mpl(rgb)convert 8 bit RGB data to 0 to 1 range for mpl
rayoptics.util.rgbtable module
Created on Mon Feb 26 20:10:33 2018
@author: Mike
132 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
class RGBTable(filename=’sunset_rgb.csv’, data_range=[0.0, 100.0])Bases: object
data_list = [[230, 0, 0], [237, 8, 0], [244, 15, 0], [251, 24, 0], [255, 36, 4], [255, 50, 11], [255, 63, 18], [255, 77, 26], [255, 89, 33], [255, 101, 40], [255, 113, 47], [255, 125, 55], [255, 135, 62], [255, 146, 69], [255, 156, 77], [255, 165, 84], [255, 174, 91], [255, 183, 98], [255, 191, 106], [255, 199, 113], [255, 206, 120], [255, 212, 128], [255, 219, 135], [255, 225, 142], [255, 230, 149], [255, 235, 157], [255, 239, 164], [255, 243, 171], [255, 246, 178], [255, 250, 186], [255, 252, 193], [255, 254, 200], [200, 254, 255], [193, 252, 255], [186, 250, 255], [179, 247, 255], [171, 243, 255], [164, 239, 255], [157, 235, 255], [149, 230, 255], [142, 225, 255], [135, 219, 255], [128, 213, 255], [120, 206, 255], [113, 199, 255], [106, 191, 255], [98, 183, 255], [91, 174, 255], [84, 165, 255], [77, 156, 255], [69, 146, 255], [62, 135, 255], [55, 125, 255], [47, 113, 255], [40, 101, 255], [33, 89, 255], [26, 77, 255], [18, 63, 255], [11, 50, 255], [4, 36, 255], [0, 24, 251], [0, 15, 244], [0, 8, 237], [0, 0, 230]]
get_color(value)
13.1.12 rayoptics.zemax package
package to read a Zemax .zmx file and produce a rayoptics OpticalModel
Submodules
rayoptics.zemax.zmxread module
read_lens_file(filename, **kwargs)given a Zemax .zmx filename, return an OpticalModel
It appears that Zemax .zmx files are written in UTF-16 encoding. Test against what seem to be common encod-ings. If other encodings are used in ‘files in the wild’, please add them to the list.
Parameters
• filename (pathlib.Path) – a Zemax .zmx file path
• kwargs (dict) – keyword args passed to the reader functions
Returns an OpticalModel instance and a info tuple
read_lens_url(url, **kwargs)given a url to a Zemax file, return an OpticalModel
read_lens(filename, inpt, **kwargs)given inpt str of a Zemax .zmx file, return an OpticalModel
process_line(opt_model, line, line_no)
post_process_input(opt_model, filename, **kwargs)
log_cmd(label, cmd, inputs)
handle_types_and_params(optm, cur, cmd, inputs)
handle_aperture_data(optm, cur, cmd, inputs)
pupil_data(optm, cmd, inputs)
field_spec_data(optm, cmd, inputs)
class ZmxGlassHandler(filename)Bases: rayoptics.seq.medium.GlassHandlerBase
Handle glass restoration during Zemax zmx import.
This class relies on GlassHandlerBase to provide most of the functionality needed to find the requested glass ora substitute.
13.1. Subpackages 133
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.zemax.zmx2ro module
Post processing functions for Zemax import
apply_fct_to_sm(opt_model, fct, start=None, stop=None, step=None)Iterate in reverse over seq_model.ifcs. Override if needed.
convert_to_bend(opt_model, cur)Scan the zemax import for tilted mirrors and convert to BEND types.
convert_to_dar(opt_model, cur)Scan the zemax import for tilted surfs and convert to DAR types.
collapse_coordbrk(opt_model, cur)Attempt to apply the cur COORDBRK to an adjacent real interface.
remove_null_sg(opt_model, cur)Remove sg with planar profile and an adjacent zero thickness air gap.
is_null_ifc(ifc)
is_null_gap(gap)
13.2 Submodules
13.3 rayoptics.environment module
script file providing an environment for using rayoptics
134 Chapter 13. rayoptics package
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
136 Chapter 14. Contributors
CHAPTER 15
License
BSD 3-Clause License
Copyright (c) 2017-2021, Michael J. Hayford All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that thefollowing conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the followingdisclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the follow-ing disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promoteproducts derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANYEXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIESOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENTSHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, IN-CIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITEDTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSI-NESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CON-TRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANYWAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAM-AGE.
137
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
138 Chapter 15. License
CHAPTER 16
Changelog
16.1 Version 0.7.4
Pass 2 on the 𝑦−𝑦 diagram layer capability. Handle thick elements and include a top level ‘sys’ layer. Fix insertion ofsystem from file. Add support for models from the OpticalBenchHub portion of Bill Claff’s PhotonsToPhotos website.Support odd polynomial surfaces in Zemax import. Added additional control over the use of flats when drawing lenselements, see ray-optics notebook Cell Phone lens for an example. Thanks also to @wuffi for contributing 2 fixes tomake the interactive ray-optics app more robust.
16.2 Version 0.7.3
Miscellaneous bug fixes, see checkin comments.
16.3 Version 0.7.2
Add RayFans to interactive layout. Add a multiple layer 𝑦 − 𝑦 diagram capability. Works well for thin lens systems.Systems with thick lenses (e.g. Double Gauss) don’t work well. Fixes in the analyses module include gettingthe sign right for defocused transverse aberrations and using the image gap distance instead of parax img_dist forreference sphere definition. Miscellaneous fixes.
16.4 Version 0.7.1
Switch to use of strings for DecenterType and DimensionType. Use of the types is now deprecated. Add lis-tobj() methods to all profiles classes that lists all of the data for each profile type. Completed the fix of opticalglassissue #5 by using difflib to find better matches; seems to almost eliminate need for .smx files. Provided an alternativereplacement glass spec for .smx files that requires just the glass and catalog names. Miscellaneous other fixes.
139
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
16.5 Version 0.7.0
Add PartTree to OpticalModel. Many changes to get SequentialModel, ElementModel and PartTree to workin sync. Add CementedElement element to elements module. Fix paraxial image distance calculation. FixDOE implementation for DOE on exiting side of element. Add fractional field height specification to FieldSpec.Add a mapping interface to OpticalModel and OpticalSpecs; allows submodel access like opm[‘sm’] andopm[‘osp][‘fov’]. Add reverse_path() method to facilitate reverse ray tracing through the model. Add semi-diameter to list of items in add_surface() method. Add exception handling for ray trace errors in analysesmodule. Many miscellaneous fixes and improvements.
16.6 Version 0.6.5
Fixes for ray normal calculation in Even and Radial polynomial profiles, the ray trace was incorrect for these surfaces.Add do_aperture flag to SequentialModel to control aperture setting by update_model(). Miscellaneousother fixes and enhancements.
16.7 Version 0.6.4
Rework analysisfigure module to better separate axis vs figure functions. Simplify default layout options, butsupport more complicated layouts as needed. Correctly update the model when dropping a glass onto the 𝑦 − 𝑦diagram. Fix issue #18 and update documentation.
16.8 Version 0.6.3
Fixes for aspheric ray intersection calculation, implemented by reworking the profiles module. Generalize thecreate_mirror() fct to accept a SurfaceProfile instance in addition.
16.9 Version 0.6.2
Fixes for .zmx import. Refactor GlassHandler to allow CODEV import to use as well.
16.10 Version 0.6.1
Interpret Zemax .zmx files as having UTF-16 encoding, with a fallback to UTF-8. Push classes in medium towards acommon set of queries with opticalglass glass and catalog classes. Add trace_list_of_rays() specifiedby starting point, direction cosines and wavelength.
16.11 Version 0.6.0
Add import of Zemax .zmx files. Demonstrate access to lens-designs.com collection of zemax files and use that to testimport capability. Build a strong tie with opticalglass package, including drag and drop from a glassmap viewto the layout, yybar and lens table views. Add x, y-toroids. Add a paraxial-based set vig calculation to Tools menu.Set up a protocol for aperture checking in the ray trace. Add conda installation via conda-forge.
140 Chapter 16. Changelog
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
16.12 Version 0.5.0
Refactor/repackage the optical subpackage into more manageable chunks. New subpackages include seq ,raytr, parax, elem and oprops. The layout and diagram modules were moved from the gui subpackageto the elem and parax subpackages, respectively. The refactoring broke reading of existing .roa files; a preprocess-ing step was added in the roafile module to handle mapping the old structure to the new one. Documentation andJupyter notebooks were updated to reflect the changes.
16.13 Version 0.4.12
Misc bug fixes and improvements: draw mirror substrates consistently, old .roa files should be resaved. ConsolidateInteractiveFigure color and lw control in dicts, and retrofit layout usage to match diagrams.
16.14 Version 0.4.11
Add single field monochromatic PSF calc and display. Add dashboards for jupyter notebook usage for refocusing,etc. Revisions to app manager protocols for wider usage, esp. including matplotlib Figures. Use brute force OPD calcinstead of equally inclined chords until eic behavior with decentered systems is fixed.
16.15 Version 0.4.10
Add add_from_file() method to OpticalModel to enable importing pieces of optical models to a master model. Includea Jupyter notebook demonstration.
16.16 Version 0.4.9
Add single panel refactoring of ray fan, spot diagram and wavefront map plots that are designed for use in a scriptingenvironment.
16.17 Version 0.4.8
Bug fixes and doc improvements
16.18 Version 0.4.7
UI improvements. For Qt app, add light and dark mode, add zoom, and pan capabilities to InteractiveFigures, reworkmain menu bar. For Diagram, add object and stop shifts, lens thickness and bending, replace node with system option.Reorganize doc structure.
16.19 Version 0.4.6
Add SpecSheet capability. V2 of 𝑦 − 𝑦 diagram with more editing capability
16.12. Version 0.5.0 141
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
16.20 Version 0.4.0
Add initial version of Interactive Layout (Live Layout). Work in Progress. . .
16.21 Version 0.3.5
Update aperture import and layout rendering for y-z plane tilts and decenters
16.22 Version 0.3.0
Rework packaging using PyScaffold and Versioneer. Deploy documentation to ReadTheDocs
16.23 Version 0.2.0
first version of documentation support for rayoptics. continue refactoring
16.24 Version 0.1.5
separate qt gui files from mpl and generic ones. add rayoptics script to start qt version
16.25 Version 0.1.0
major update that reads CV files, supports Hoya, Ohara and Schott glass catalogs, computes paraxial and real rays,and has Qt UI for lens data table, 2D lens picture and glass map view.
142 Chapter 16. Changelog
CHAPTER 17
Indices and tables
• genindex
• modindex
• search
143
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
144 Chapter 17. Indices and tables
Python Module Index
crayoptics.codev, 49rayoptics.codev.cmdproc, 50rayoptics.codev.reader, 51rayoptics.codev.tla, 51
erayoptics.elem, 51rayoptics.elem.elements, 51rayoptics.elem.layout, 57rayoptics.elem.parttree, 59rayoptics.elem.profiles, 60rayoptics.elem.surface, 66rayoptics.elem.transform, 68rayoptics.environment, 134
grayoptics.gui, 69rayoptics.gui.actions, 69rayoptics.gui.appcmds, 70rayoptics.gui.appmanager, 71rayoptics.gui.dashboards, 72rayoptics.gui.roafile, 72rayoptics.gui.util, 73
mrayoptics.mpl, 73rayoptics.mpl.analysisfigure, 73rayoptics.mpl.analysisplots, 76rayoptics.mpl.axisarrayfigure, 77rayoptics.mpl.interactivediagram, 78rayoptics.mpl.interactivefigure, 78rayoptics.mpl.interactivelayout, 80rayoptics.mpl.styledfigure, 81
orayoptics.oprops, 81rayoptics.oprops.doe, 81rayoptics.oprops.thinlens, 83
rayoptics.optical, 84rayoptics.optical.model_constants, 84rayoptics.optical.model_enums, 84rayoptics.optical.obench, 88rayoptics.optical.opticalmodel, 86
prayoptics.parax, 88rayoptics.parax.diagram, 88rayoptics.parax.etendue, 90rayoptics.parax.firstorder, 91rayoptics.parax.idealimager, 93rayoptics.parax.paraxialdesign, 94rayoptics.parax.specsheet, 96rayoptics.parax.thirdorder, 97
qrayoptics.qtgui, 98rayoptics.qtgui.dockpanels, 98rayoptics.qtgui.idealimagerdialog, 100rayoptics.qtgui.ipyconsole, 101rayoptics.qtgui.plotview, 101rayoptics.qtgui.pytablemodel, 102rayoptics.qtgui.rayopticsapp, 103
rrayoptics, 49rayoptics.raytr, 104rayoptics.raytr.analyses, 104rayoptics.raytr.opticalspec, 110rayoptics.raytr.raytrace, 113rayoptics.raytr.sampler, 116rayoptics.raytr.trace, 117rayoptics.raytr.traceerror, 120
srayoptics.seq, 120rayoptics.seq.gap, 121rayoptics.seq.interface, 121rayoptics.seq.medium, 123
145
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.seq.sequential, 125rayoptics.seq.twoconicmirrors, 129
urayoptics.util, 129rayoptics.util.colors, 130rayoptics.util.colour_system, 130rayoptics.util.dict2d, 131rayoptics.util.line_intersection, 131rayoptics.util.misc_math, 131rayoptics.util.rgb2mpl, 132rayoptics.util.rgbtable, 132
zrayoptics.zemax, 133rayoptics.zemax.zmx2ro, 134rayoptics.zemax.zmxread, 133
146 Python Module Index
Index
Aaccent_colors() (in module rayoptics.util.colors),
130achromat() (in module rayoptics.elem.elements), 52Action (class in rayoptics.gui.actions), 69action_complete() (InteractiveDiagram method),
78action_complete() (InteractiveFigure method), 79action_complete() (InteractiveLayout method), 81actions (CementedElement attribute), 54actions (Element attribute), 53add() (WvlSpec method), 111add_conic() (in module rayoptics.elem.layout), 59add_doublet() (in module rayoptics.elem.layout), 59add_dummy_interface_at_image() (Element-
Model method), 56add_dummy_plane() (OpticalModel method), 87add_element() (ElementModel method), 56add_element_cmd_actions() (LensLayout
method), 58add_element_model_to_tree() (PartTree
method), 59add_element_to_tree() (PartTree method), 59add_elements() (in module rayoptics.elem.layout),
58add_figure() (AppManager method), 71add_from_file() (OpticalModel method), 87add_ipython_subwindow() (MainWindow
method), 103add_lens() (in module rayoptics.elem.layout), 59add_lens() (OpticalModel method), 87add_mirror() (in module rayoptics.elem.layout), 59add_mirror() (OpticalModel method), 87add_node() (ParaxialModel method), 94add_reflector() (in module rayoptics.elem.layout),
59add_subwindow() (MainWindow method), 103add_surface() (SequentialModel method), 127add_thinlens() (in module rayoptics.elem.layout),
59add_thinlens() (OpticalModel method), 87add_view() (AppManager method), 71AddReplaceElementAction (class in rayop-
tics.parax.diagram), 90aim_chief_ray() (in module rayoptics.raytr.trace),
119aim_pt (Field attribute), 113Air (class in rayoptics.seq.medium), 123air_gaps_to_node_defs() (in module rayop-
tics.parax.paraxialdesign), 95AirGap (class in rayoptics.elem.elements), 56airgaps_from_sequence() (ElementModel
method), 56All (Fit attribute), 77All_Same (Fit attribute), 77AnalysisFigure (class in rayop-
tics.mpl.analysisfigure), 74AnalysisPlot (class in rayoptics.mpl.analysisplots),
77ang2slp() (in module rayoptics.parax.etendue), 90Aperture (class in rayoptics.elem.surface), 67aperture_data() (in module rayop-
tics.codev.cmdproc), 50aperture_data_general() (in module rayop-
tics.codev.cmdproc), 50aperture_offset() (in module rayop-
tics.codev.cmdproc), 50AperturePanel (class in rayoptics.qtgui.dockpanels),
99append_pt_to_2d_profile() (in module rayop-
tics.elem.profiles), 63apply_conjugate_shift() (ParaxialModel
method), 95apply_data() (Diagram method), 88apply_data() (ParaxialRay method), 58apply_fct_to_sm() (in module rayop-
tics.zemax.zmx2ro), 134apply_ht_dgm_data() (ParaxialModel method), 95apply_paraxial_vignetting() (in module ray-
147
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
optics.raytr.trace), 119apply_scale_factor() (Aperture method), 67apply_scale_factor() (Circular method), 67apply_scale_factor() (Conic method), 63apply_scale_factor() (DecenterData method),
67apply_scale_factor() (Elliptical method), 68apply_scale_factor() (EvenPolynomial method),
63apply_scale_factor() (Gap method), 121apply_scale_factor() (Interface method), 123apply_scale_factor() (RadialPolynomial
method), 64apply_scale_factor() (Rectangular method), 68apply_scale_factor() (SequentialModel
method), 127apply_scale_factor() (Spherical method), 62apply_scale_factor() (Surface method), 66apply_scale_factor() (SurfaceProfile method),
61apply_scale_factor() (ThinLens method), 83apply_scale_factor() (YToroid method), 65apply_slope_dgm_data() (ParaxialModel
method), 95apply_style() (in module rayop-
tics.mpl.styledfigure), 81apply_vignetting() (Field method), 113AppManager (class in rayoptics.gui.appmanager), 71args (ModelInfo attribute), 71artist (SelectInfo attribute), 78artist_filter (InteractiveFigure attribute), 79aspect (InteractiveFigure attribute), 79aspheric_profile() (in module rayop-
tics.elem.profiles), 63aspheric_seidel_contribution() (in module
rayoptics.parax.thirdorder), 97assign_object_to_node() (Diagram method), 88assign_object_to_node() (ParaxialModel
method), 94AstigmatismCurvePlot (class in rayop-
tics.mpl.analysisplots), 77AttrAction (class in rayoptics.gui.actions), 69AttrChanger (class in rayoptics.gui.dashboards), 72ax_ray (ParaxData attribute), 91AxisArrayFigure (class in rayop-
tics.mpl.axisarrayfigure), 77
BBarrelConstraint (class in rayop-
tics.parax.diagram), 89bbox (GUIHandle attribute), 73bbox_from_poly() (in module rayoptics.gui.util), 73bbox_from_poly() (in module rayop-
tics.parax.paraxialdesign), 94
BEND (DecenterType attribute), 85bend() (in module rayoptics.raytr.raytrace), 113BendAction (class in rayoptics.gui.actions), 69bfl (FirstOrderData attribute), 91boundary_ray_dict() (in module rayop-
tics.raytr.trace), 119bounding_box() (Aperture method), 67build_from_yybar() (in module rayop-
tics.parax.paraxialdesign), 96build_lens() (ParaxialModel method), 94
Ccalc_4th_order_aspheric_term() (in module
rayoptics.parax.thirdorder), 97calc_aperture_from_input() (in module rayop-
tics.parax.etendue), 91calc_colors() (WvlSpec method), 111calc_cv_from_zsag() (Surface method), 66calc_delta_op_via_eic() (in module rayop-
tics.raytr.raytrace), 116calc_ifcs_nodes() (in module rayop-
tics.parax.paraxialdesign), 96calc_optical_path() (in module rayop-
tics.raytr.raytrace), 115calc_path_length() (in module rayop-
tics.raytr.raytrace), 115calc_psf() (in module rayoptics.raytr.analyses), 110calc_psf_scaling() (in module rayop-
tics.raytr.analyses), 110calc_ref_indices_for_spectrum() (Sequen-
tialModel method), 126calc_render_color_for_material() (in mod-
ule rayoptics.elem.elements), 52cascade_transform() (in module rayop-
tics.elem.transform), 68cassegrain() (in module rayop-
tics.seq.twoconicmirrors), 129catalog_name() (Air method), 123catalog_name() (InterpolatedGlass method), 124catalog_name() (Medium method), 123cc (RadialPolynomial attribute), 64CementedElement (class in rayoptics.elem.elements),
54central_rndx() (SequentialModel method), 126central_wavelength() (SequentialModel
method), 126central_wvl (WvlSpec attribute), 111change_conjugate() (IdealImagerDialog method),
100chief_ray (Field attribute), 113chkbox_change() (EtendueGroupBox method), 100chkbox_change() (ImagerSpecGroupBox method),
100
148 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
circle_intersection_area() (in module rayop-tics.util.misc_math), 132
Circular (class in rayoptics.elem.surface), 67clear() (ConsoleWidget method), 101clip_to_range() (in module rayop-
tics.mpl.axisarrayfigure), 77close_model() (AppManager method), 72close_model() (MainWindow method), 103clut (CementedElement attribute), 54clut (Element attribute), 53CM (DimensionType attribute), 85cmap (DiffractionPSF attribute), 76cmap (Wavefront attribute), 76cmf (ColourSystem attribute), 130coefficients (DiffractiveElement attribute), 82col() (in module rayoptics.util.dict2d), 131colEvalStr (PyTableModel attribute), 102colFormats (PyTableModel attribute), 102colHeaders (PyTableModel attribute), 102collapse_coordbrk() (in module rayop-
tics.zemax.zmx2ro), 134color (GraphicsHandle attribute), 51ColourSystem (class in rayoptics.util.colour_system),
130columnCount() (PyTableModel method), 103comboItems (AperturePanel attribute), 99comboItems (FieldOfViewPanel attribute), 99CommandItem (class in rayoptics.qtgui.plotview), 101compute_first_order() (in module rayop-
tics.parax.firstorder), 92compute_flat() (CementedElement method), 55compute_flat() (Element method), 53compute_global_coords() (SequentialModel
method), 128compute_local_transforms() (SequentialModel
method), 128compute_principle_points() (in module rayop-
tics.parax.firstorder), 92compute_principle_points() (ParaxialModel
method), 95compute_signed_rindx() (ParaxialModel
method), 94compute_slide_line() (in module rayop-
tics.parax.diagram), 89compute_tangent_point_to_circle() (in
module rayoptics.util.misc_math), 132compute_third_order() (in module rayop-
tics.parax.thirdorder), 97concentric_sample_disk() (in module rayop-
tics.raytr.sampler), 117Conic (class in rayoptics.elem.profiles), 62conjugate_type (SpecSheet attribute), 97ConjugateLine (class in rayoptics.parax.diagram),
89
connect_events() (InteractiveFigure method), 79ConsoleWidget (class in rayoptics.qtgui.ipyconsole),
101constrain_to_line_action() (in module rayop-
tics.parax.diagram), 89construct_plot_array() (AxisArrayFigure
method), 77convert_to_bend() (in module rayop-
tics.zemax.zmx2ro), 134convert_to_dar() (in module rayop-
tics.zemax.zmx2ro), 134copy_styles() (in module rayop-
tics.mpl.styledfigure), 81copyDataFrom() (Conic method), 63copyDataFrom() (EvenPolynomial method), 63copyDataFrom() (RadialPolynomial method), 64copyDataFrom() (Spherical method), 62copyDataFrom() (YToroid method), 65copyFrom() (Conic method), 63copyFrom() (EvenPolynomial method), 63copyFrom() (RadialPolynomial method), 64copyFrom() (Spherical method), 62copyFrom() (YToroid method), 65count (MainWindow attribute), 103create_2d_figure_toolbar() (in module rayop-
tics.qtgui.plotview), 102create_3rd_order_bar_chart() (in module
rayoptics.gui.appcmds), 70create_air_gap() (in module rayop-
tics.elem.elements), 52create_cemented_doublet() (in module rayop-
tics.elem.elements), 52create_command_panel() (in module rayop-
tics.qtgui.plotview), 101create_diagram_controls_groupbox() (in
module rayoptics.qtgui.plotview), 102create_diagram_edge_actions_groupbox()
(in module rayoptics.qtgui.plotview), 102create_diagram_for_key() (in module rayop-
tics.parax.paraxialdesign), 95create_diagram_layers_groupbox() (in mod-
ule rayoptics.qtgui.plotview), 102create_dock_widget() (in module rayop-
tics.qtgui.dockpanels), 98create_dock_windows() (in module rayop-
tics.qtgui.dockpanels), 98create_draw_rays_groupbox() (in module ray-
optics.qtgui.plotview), 102create_dummy_plane() (in module rayop-
tics.elem.elements), 52create_element_entities() (LensLayout
method), 58create_element_table_model() (in module
rayoptics.gui.appcmds), 70
Index 149
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
create_etendue_dict() (in module rayop-tics.parax.etendue), 90
create_field_curves() (in module rayop-tics.gui.appcmds), 70
create_focus_dashboard() (in module rayop-tics.gui.dashboards), 72
create_from_file() (in module rayop-tics.elem.elements), 52
create_generator() (in module rayop-tics.raytr.sampler), 117
create_glass_map_view() (in module rayop-tics.gui.appcmds), 70
create_glass_map_view() (in module rayop-tics.qtgui.plotview), 101
create_ipython_console() (in module rayop-tics.qtgui.ipyconsole), 101
create_lens() (in module rayoptics.elem.elements),52
create_lens_table() (MainWindow method), 104create_lens_table_model() (in module rayop-
tics.gui.appcmds), 70create_live_layout_commands() (in module
rayoptics.gui.appcmds), 70create_live_layout_view() (in module rayop-
tics.gui.appcmds), 70create_menu_action() (in module rayop-
tics.qtgui.dockpanels), 98create_mirror() (in module rayop-
tics.elem.elements), 52create_mirror_tilt_dashboard() (in module
rayoptics.gui.dashboards), 72create_multi_plot_scale_panel() (in mod-
ule rayoptics.qtgui.plotview), 102create_new_ideal_imager_dialog() (in mod-
ule rayoptics.gui.appcmds), 70create_new_model() (in module rayop-
tics.gui.appcmds), 70create_new_optical_model_from_specsheet()
(in module rayoptics.gui.appcmds), 70create_new_optical_system() (in module ray-
optics.gui.appcmds), 70create_optical_element() (in module rayop-
tics.elem.layout), 57create_parax_design_commands() (in module
rayoptics.parax.diagram), 88create_parax_model_table() (in module rayop-
tics.gui.appcmds), 70create_parax_table_model() (in module rayop-
tics.gui.appcmds), 70create_paraxial_design_view_v2() (in mod-
ule rayoptics.gui.appcmds), 70create_paraxial_ray_entities() (LensLay-
out method), 58create_patches() (InteractiveFigure method), 79
create_plot_scale_panel() (in module rayop-tics.qtgui.plotview), 102
create_plot_view() (in module rayop-tics.qtgui.plotview), 101
create_polygon() (InteractiveFigure method), 79create_polyline() (InteractiveFigure method), 79create_ray_entities() (LensLayout method), 58create_ray_fan_entities() (LensLayout
method), 58create_ray_fan_view() (in module rayop-
tics.gui.appcmds), 70create_ray_grid_view() (in module rayop-
tics.gui.appcmds), 70create_ray_table() (MainWindow method), 104create_ray_table_model() (in module rayop-
tics.gui.appcmds), 70create_specsheet() (in module rayop-
tics.parax.specsheet), 96create_specsheet_from_model() (in module
rayoptics.parax.specsheet), 97create_specsheets() (in module rayop-
tics.parax.specsheet), 97create_surface_and_gap() (in module rayop-
tics.seq.sequential), 128create_table_view() (MainWindow method), 104create_thinlens() (in module rayop-
tics.elem.elements), 51create_vertex() (InteractiveFigure method), 80create_wavefront_view() (in module rayop-
tics.gui.appcmds), 70create_yybar_model() (in module rayop-
tics.gui.appcmds), 70createButtonBox() (IdealImagerDialog method),
100createConjugateBox() (IdealImagerDialog
method), 100csd_grid_ray_generator() (in module rayop-
tics.raytr.sampler), 117cur_surface (SequentialModel attribute), 126currentIndexChanged() (EnumChoiceWidget
method), 99currentIndexChanged() (ListChoiceWidget
method), 99CVGlassHandler (class in rayoptics.codev.cmdproc),
50
Dd (RaySeg attribute), 117dall_kirkham() (in module rayop-
tics.seq.twoconicmirrors), 129DAR (DecenterType attribute), 85data() (CommandItem method), 101data() (PyTableModel method), 103data_list (RGBTable attribute), 133
150 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
data_objs (AnalysisFigure attribute), 74decenter (Interface attribute), 122decenter_data() (in module rayop-
tics.codev.cmdproc), 50DecenterData (class in rayoptics.elem.surface), 67DecenterType (class in rayop-
tics.optical.model_enums), 85default_pupil_rays (PupilSpec attribute), 112default_ray_labels (PupilSpec attribute), 112defocus (OpticalSpecs attribute), 111defocus_range (FocusRange attribute), 113delete_node() (ParaxialModel method), 94delete_subwindow() (MainWindow method), 103delete_view() (AppManager method), 72delta_n (Interface attribute), 122df() (Conic method), 63df() (EvenPolynomial method), 64df() (RadialPolynomial method), 64df() (Spherical method), 62df() (SurfaceProfile method), 60df() (XToroid method), 65df() (YToroid method), 65dgm_type (InteractiveDiagram attribute), 78Diagram (class in rayoptics.parax.diagram), 88DiagramEdge (class in rayoptics.parax.diagram), 89DiagramNode (class in rayoptics.parax.diagram), 89dict2D() (in module rayoptics.util.dict2d), 131DiffractionPSF (class in rayop-
tics.mpl.analysisfigure), 76diffractive_optic() (in module rayop-
tics.codev.cmdproc), 50DiffractiveElement (class in rayop-
tics.oprops.doe), 82dimension() (Aperture method), 67dimension() (Circular method), 67dimension() (Elliptical method), 68dimension() (Rectangular method), 67dimensions (SystemSpec attribute), 86DimensionType (class in rayop-
tics.optical.model_enums), 85disconnect_events() (InteractiveFigure method),
79display_artist_and_event() (in module rayop-
tics.mpl.interactivefigure), 79display_event() (InteractiveFigure method), 80distance_sqr_2d() (in module rayop-
tics.util.misc_math), 131do_aiming_default (OpticalSpecs attribute), 110do_aperture_via_imager() (in module rayop-
tics.parax.etendue), 91do_contours (Wavefront attribute), 75do_draw_axes (InteractiveFigure attribute), 79do_draw_frame (InteractiveFigure attribute), 79do_draw_rays (InteractiveLayout attribute), 81
do_etendue_to_imager() (in module rayop-tics.parax.etendue), 91
do_etendue_via_imager() (in module rayop-tics.parax.etendue), 91
do_field_via_imager() (in module rayop-tics.parax.etendue), 91
do_file_action() (MainWindow method), 103do_intersect() (in module rayop-
tics.util.line_intersection), 131do_paraxial_layout (InteractiveLayout attribute),
81do_shape_action() (InteractiveFigure method), 80do_view_action() (MainWindow method), 103do_window_action() (MainWindow method), 103dock (PanelInfo attribute), 98dragEnterEvent() (GlassDropAction method), 59,
90dragEnterEvent() (NullDropAction method), 101dragEnterEvent() (PlotCanvas method), 101dragLeaveEvent() (GlassDropAction method), 59,
90dragLeaveEvent() (NullDropAction method), 101dragLeaveEvent() (PlotCanvas method), 101dragMoveEvent() (GlassDropAction method), 59, 90dragMoveEvent() (NullDropAction method), 101dragMoveEvent() (PlotCanvas method), 101draw_axes() (InteractiveFigure method), 80draw_frame() (InteractiveFigure method), 80dropEvent() (GlassDropAction method), 59, 90dropEvent() (NullDropAction method), 101dropEvent() (PlotCanvas method), 101dsp_type (RayGeoPSF attribute), 75dst (RaySeg attribute), 117dtype (DecenterData attribute), 67DummyInterface (class in rayoptics.elem.elements),
55
Eec (Conic attribute), 63ec (EvenPolynomial attribute), 63ec (YToroid attribute), 65edit_conjugate_line_actions() (Conjugate-
Line method), 89edit_paraxial_layout_actions() (Paraxial-
Ray method), 58edit_ray_bundle_actions() (RayBundle
method), 58edit_shape_actions() (OpticalElement method),
57EditAreaAction (class in rayoptics.parax.diagram),
89EditBendingAction (class in rayop-
tics.parax.diagram), 90editingFinished() (TextFieldWidget method), 99
Index 151
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
EditLensAction (class in rayoptics.parax.diagram),89
EditNodeAction (class in rayoptics.parax.diagram),89
EditThicknessAction (class in rayop-tics.parax.diagram), 90
efl (FirstOrderData attribute), 91eic_distance() (in module rayop-
tics.raytr.raytrace), 115eic_distance_from_axis() (in module rayop-
tics.raytr.raytrace), 115eic_path_accumulation() (in module rayop-
tics.raytr.raytrace), 116ele_model (OpticalModel attribute), 87Element (class in rayoptics.elem.elements), 52element_list() (CementedElement method), 54element_type() (ElementModel method), 57ElementModel (class in rayoptics.elem.elements), 56elements (ElementModel attribute), 56elements_from_sequence() (in module rayop-
tics.elem.parttree), 60Elliptical (class in rayoptics.elem.surface), 68enp_dist (FirstOrderData attribute), 92enp_radius (FirstOrderData attribute), 92EnumChoiceWidget (class in rayop-
tics.qtgui.dockpanels), 99EPD (PupilType attribute), 84etendue_inputs (SpecSheet attribute), 97etendue_values (SpecSheet attribute), 97EtendueGroupBox (class in rayop-
tics.qtgui.idealimagerdialog), 100euler2opt() (in module rayoptics.util.misc_math),
132eval_fan() (in module rayoptics.raytr.analyses), 107eval_pupil_coords() (in module rayop-
tics.raytr.analyses), 109eval_wavefront() (in module rayop-
tics.raytr.analyses), 109EvenPolynomial (class in rayoptics.elem.profiles), 63eventFilter() (MainWindow method), 104execute_command() (ConsoleWidget method), 101exp_dist (FirstOrderData attribute), 92exp_radius (FirstOrderData attribute), 92extent() (CementedElement method), 55extent() (Element method), 53extent() (Mirror method), 54
Ff (IdealImager attribute), 93f (Ray attribute), 106f (RayFan attribute), 107f (RayGrid attribute), 109f (RayList attribute), 108f() (Conic method), 63
f() (EvenPolynomial method), 64f() (RadialPolynomial method), 64f() (Spherical method), 62f() (SurfaceProfile method), 60f() (XToroid method), 65f() (YToroid method), 65fan_list (RayFanPlot attribute), 74fct (ModelInfo attribute), 71ffl (FirstOrderData attribute), 91fictitious_glass_decode() (in module rayop-
tics.codev.cmdproc), 50Field (class in rayoptics.raytr.opticalspec), 112field_of_view (OpticalSpecs attribute), 111field_spec_data() (in module rayop-
tics.codev.cmdproc), 50field_spec_data() (in module rayop-
tics.zemax.zmxread), 133FieldCurveFigure (class in rayop-
tics.mpl.analysisplots), 76FieldOfViewPanel (class in rayop-
tics.qtgui.dockpanels), 99fields (FieldSpec attribute), 112FieldSpec (class in rayoptics.raytr.opticalspec), 112FieldType (class in rayoptics.optical.model_enums),
85file_action() (MainWindow method), 103fill_in_etendue_data() (in module rayop-
tics.parax.etendue), 91find() (MapTLA method), 51find_6_digit_code() (GlassHandlerBase
method), 125find_artists_at_location() (InteractiveFig-
ure method), 80find_glass() (GlassHandlerBase method), 124find_matching_ifcs() (SequentialModel
method), 128find_substitute_glass() (GlassHandlerBase
method), 125first_order_data() (ParaxialModel method), 95FirstOrderData (class in rayoptics.parax.firstorder),
91Fit (class in rayoptics.mpl.axisarrayfigure), 77fit() (InteractiveFigure method), 80fit_axis_limits() (Diagram method), 89fit_axis_limits() (InteractiveDiagram method),
78fit_axis_limits() (InteractiveFigure method), 80fit_axis_limits() (InteractiveLayout method), 81fit_data_range() (in module rayoptics.gui.util), 73flags() (PyTableModel method), 103flats (CementedElement attribute), 54FloatFieldWidget (class in rayop-
tics.qtgui.dockpanels), 99fno (FirstOrderData attribute), 91
152 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
FNO (PupilType attribute), 84foc (Ray attribute), 107foc (RayFan attribute), 107foc (RayGrid attribute), 109foc (RayList attribute), 108focus_fan() (in module rayoptics.raytr.analyses),
108focus_pupil_coords() (in module rayop-
tics.raytr.analyses), 109focus_shift (FocusRange attribute), 113focus_wavefront() (in module rayop-
tics.raytr.analyses), 109FocusRange (class in rayoptics.raytr.opticalspec), 113fod (ParaxData attribute), 91foreground_background() (in module rayop-
tics.util.colors), 130forward_transform() (in module rayop-
tics.elem.transform), 68from_first_order() (Surface method), 66from_first_order() (ThinLens method), 83frozen_imager_inputs (SpecSheet attribute), 97FT (DimensionType attribute), 85full_profile() (Surface method), 66full_profile() (ThinLens method), 83fY() (YToroid method), 65
GGap (class in rayoptics.seq.gap), 121gap (Element attribute), 52gap_list() (AirGap method), 56gap_list() (CementedElement method), 55gap_list() (DummyInterface method), 55gap_list() (Element method), 53gap_list() (Mirror method), 54gap_list() (ThinElement method), 55gaps (CementedElement attribute), 54gaps (SequentialModel attribute), 125gbl_tfrms (SequentialModel attribute), 125gen_coef_list() (EvenPolynomial method), 63gen_coef_list() (RadialPolynomial method), 64gen_coef_list() (YToroid method), 65gen_ifcs_node_mapping() (in module rayop-
tics.parax.paraxialdesign), 96gen_sequence() (in module rayop-
tics.seq.sequential), 128generate_from_inputs() (SpecSheet method), 97generate_mapping_for_key() (in module rayop-
tics.parax.paraxialdesign), 95get() (AttrChanger method), 72get() (ModelBinding method), 98get_ape_key_for_type() (in module rayop-
tics.optical.model_enums), 85get_ape_type_for_key() (in module rayop-
tics.optical.model_enums), 85
get_aperture_from_slope() (in module rayop-tics.parax.etendue), 91
get_bending() (Element method), 53get_chief_ray_pkg() (in module rayop-
tics.raytr.analyses), 105get_coef() (RadialPolynomial method), 64get_color() (RGBTable method), 133get_decenter_for_type() (in module rayop-
tics.optical.model_enums), 85get_defaults_from_gui_parent() (in module
rayoptics.gui.appcmds), 70get_dimension_for_type() (in module rayop-
tics.optical.model_enums), 85get_etendue_inputs() (SpecSheet method), 97get_field_type() (FieldSpec method), 112get_fld_key_for_type() (in module rayop-
tics.optical.model_enums), 85get_fld_type_for_key() (in module rayop-
tics.optical.model_enums), 85get_focus() (FocusRange method), 113get_gap_for_node() (ParaxialModel method), 94get_icon() (in module rayoptics.qtgui.plotview), 102get_index_qualifier() (in module rayop-
tics.codev.cmdproc), 50get_input_for_specsheet() (FieldSpec
method), 112get_input_for_specsheet() (PupilSpec
method), 112get_intersect() (in module rayop-
tics.util.line_intersection), 131get_label() (BarrelConstraint method), 89get_label() (ConjugateLine method), 89get_label() (Diagram method), 88get_label() (DiagramEdge method), 89get_label() (DiagramNode method), 89get_label() (OpticalElement method), 57get_label() (ParaxialRay method), 58get_label() (RayBundle method), 58get_label() (RayFanBundle method), 58get_num_elements() (ElementModel method), 57get_num_rows (PyTableModel attribute), 103get_num_surfaces() (SequentialModel method),
126get_object_for_node() (ParaxialModel method),
94get_parax_start_data() (SpecSheet method), 97get_pt() (ParaxialModel method), 94get_pupil_type() (PupilSpec method), 112get_ray_table() (LensLayout method), 58get_rndx_and_imode() (SequentialModel
method), 127get_root_object() (PyTableModel method), 103get_row_headers (PyTableModel attribute), 103
Index 153
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
get_slope_from_aperture() (in module rayop-tics.parax.etendue), 91
get_surface_and_gap() (SequentialModelmethod), 126
get_thi() (Mirror method), 53get_valid_nodes() (in module rayop-
tics.parax.paraxialdesign), 96get_y_aperture_extent() (Surface method), 66Glass (class in rayoptics.seq.medium), 123glass_code() (Glass method), 123glass_code() (InterpolatedGlass method), 124glass_decode() (in module rayoptics.seq.medium),
123glass_encode() (in module rayoptics.seq.medium),
123GlassDropAction (class in rayoptics.elem.layout),
59GlassDropAction (class in rayop-
tics.parax.diagram), 90GlassHandlerBase (class in rayoptics.seq.medium),
124GraphicsHandle (class in rayoptics.elem.elements),
51grid (AnalysisFigure attribute), 74grid_ray_generator() (in module rayop-
tics.raytr.sampler), 116gridspecs (AnalysisFigure attribute), 74gs (AnalysisFigure attribute), 74gui_parent (AppManager attribute), 71GUIHandle (class in rayoptics.gui.util), 73
Hhandle_actions() (AirGap method), 56handle_actions() (BarrelConstraint method), 89handle_actions() (CementedElement method), 55handle_actions() (ConjugateLine method), 89handle_actions() (DiagramEdge method), 89handle_actions() (DiagramNode method), 89handle_actions() (DummyInterface method), 56handle_actions() (Element method), 53handle_actions() (Mirror method), 54handle_actions() (ThinElement method), 55handle_aperture_data() (in module rayop-
tics.zemax.zmxread), 133handle_glass_not_found() (GlassHandlerBase
method), 125handle_ideal_imager_command() (MainWin-
dow method), 104handle_types_and_params() (in module rayop-
tics.zemax.zmxread), 133handles (CementedElement attribute), 54handles (Element attribute), 53headerData() (PyTableModel method), 103
HolographicElement (class in rayop-tics.oprops.doe), 83
Iideal_imager_setup() (in module rayop-
tics.parax.idealimager), 93IdealImager (class in rayoptics.parax.idealimager),
93IdealImagerDialog (class in rayop-
tics.qtgui.idealimagerdialog), 100idxs (CementedElement attribute), 54ifcs (CementedElement attribute), 54ifcs (SequentialModel attribute), 125image (Wavefront attribute), 75image_pt_2d (Ray attribute), 107image_pt_2d (RayFan attribute), 107image_pt_2d (RayGrid attribute), 109image_pt_2d (RayList attribute), 108imager (SpecSheet attribute), 97imager_defined() (SpecSheet method), 97imager_inputs (SpecSheet attribute), 97ImagerSpecGroupBox (class in rayop-
tics.qtgui.idealimagerdialog), 100IMG_ANG (FieldType attribute), 85img_dist (FirstOrderData attribute), 92IMG_HT (FieldType attribute), 85img_ht (FirstOrderData attribute), 92img_na (FirstOrderData attribute), 92IN (DimensionType attribute), 85index_for_wavelength() (SequentialModel
method), 126info (SelectInfo attribute), 78init_axis() (AxisArrayFigure method), 77init_axis() (DiffractionPSF method), 76init_axis() (RayFanPlot method), 75init_axis() (RayGeoPSF method), 75init_axis() (SpotDiagramFigure method), 78init_axis() (Wavefront method), 76init_axis() (WavefrontFigure method), 78init_from_nodes() (ParaxialModel method), 94init_from_sequence() (PartTree method), 59initial_size (RadialPolynomial attribute), 64initial_window_offset() (MainWindow
method), 103initials (SystemSpec attribute), 86insert() (SequentialModel method), 126insert_ifc_gp_ele() (OpticalModel method), 87insert_surface_and_gap() (SequentialModel
method), 127interact_mode (Interface attribute), 122InteractiveDiagram (class in rayop-
tics.mpl.interactivediagram), 78InteractiveFigure (class in rayop-
tics.mpl.interactivefigure), 79
154 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
InteractiveLayout (class in rayop-tics.mpl.interactivelayout), 80
Interface (class in rayoptics.seq.interface), 121interface_list() (AirGap method), 56interface_list() (CementedElement method), 55interface_list() (DummyInterface method), 55interface_list() (Element method), 53interface_list() (Mirror method), 54interface_list() (ThinElement method), 55interface_type() (Interface method), 122interface_type() (Surface method), 66InterpolatedGlass (class in rayop-
tics.seq.medium), 124intersect() (Conic method), 63intersect() (Interface method), 122intersect() (Spherical method), 62intersect() (Surface method), 66intersect() (SurfaceProfile method), 61intersect() (ThinLens method), 83intersect_2_lines() (in module rayop-
tics.raytr.trace), 119intersect_parabola() (in module rayop-
tics.elem.profiles), 60intersect_scipy() (SurfaceProfile method), 61intersect_spencer() (SurfaceProfile method), 61intersect_tangent_plane() (Conic method), 63intersect_tangent_plane() (Spherical
method), 62intersect_welford() (SurfaceProfile method), 61intersect_with_3lines() (in module rayop-
tics.util.line_intersection), 131intersection() (in module rayop-
tics.util.line_intersection), 131inv_transform_poly() (in module rayop-
tics.gui.util), 73is_editable (PyTableModel attribute), 102is_null_gap() (in module rayoptics.zemax.zmx2ro),
134is_null_ifc() (in module rayoptics.zemax.zmx2ro),
134is_relative (FieldSpec attribute), 112is_unit_aspect_ratio (InteractiveFigure at-
tribute), 79isanumber() (in module rayoptics.util.misc_math),
132iterate_ray() (in module rayoptics.raytr.trace), 118
Kkey (FieldSpec attribute), 112key (PupilSpec attribute), 111kwargs (AnalysisFigure attribute), 74kwargs (DiffractionPSF attribute), 76kwargs (ModelInfo attribute), 71kwargs (RayFanPlot attribute), 75
kwargs (RayGeoPSF attribute), 75kwargs (Wavefront attribute), 76
Llabel (CementedElement attribute), 54label (DiffractiveElement attribute), 82label (Element attribute), 52label (InterpolatedGlass attribute), 124label_format (AirGap attribute), 56label_format (CementedElement attribute), 54label_format (DummyInterface attribute), 55label_format (Element attribute), 53label_format (Mirror attribute), 53label_format (ThinElement attribute), 55lcl_tfrms (SequentialModel attribute), 125lens_from_power() (in module rayop-
tics.elem.elements), 52LensLayout (class in rayoptics.elem.layout), 58light_or_dark() (in module rayoptics.elem.layout),
57light_or_dark() (in module rayop-
tics.parax.diagram), 88light_or_dark() (MainWindow method), 103line() (in module rayoptics.util.line_intersection), 131list_decenters() (SequentialModel method), 127list_elements() (ElementModel method), 57list_elements() (SequentialModel method), 128list_first_order_data() (FirstOrderData
method), 92list_first_order_data() (OpticalSpecs
method), 111list_gaps() (SequentialModel method), 127list_lens() (ParaxialModel method), 95list_model() (ElementModel method), 57list_model() (PartTree method), 60list_model() (SequentialModel method), 127list_model_old() (SequentialModel method), 127list_parax_trace() (in module rayop-
tics.parax.firstorder), 93list_parax_trace() (OpticalSpecs method), 111list_ray() (in module rayoptics.raytr.trace), 117list_sg() (SequentialModel method), 128list_surface_and_gap() (SequentialModel
method), 127list_surfaces() (SequentialModel method), 127list_sys_seq() (ParaxialModel method), 95list_thinlens() (ThinLens method), 83list_tree() (PartTree method), 59list_tree_full() (PartTree method), 59ListChoiceWidget (class in rayop-
tics.qtgui.dockpanels), 99listobj() (Conic method), 63listobj() (DecenterData method), 67listobj() (DiffractiveElement method), 82
Index 155
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
listobj() (EvenPolynomial method), 63listobj() (HolographicElement method), 83listobj() (RadialPolynomial method), 64listobj() (Spherical method), 62listobj() (YToroid method), 65load_replacements() (GlassHandlerBase
method), 124LOCAL (DecenterType attribute), 85log_cmd() (in module rayoptics.codev.cmdproc), 50log_cmd() (in module rayoptics.zemax.zmxread), 133lookup_fld_wvl_focus() (OpticalSpecs method),
111
MM (DimensionType attribute), 85m (IdealImager attribute), 93main() (in module rayoptics.qtgui.rayopticsapp), 104MainWindow (class in rayoptics.qtgui.rayopticsapp),
103map_submodels() (OpticalModel method), 87MapTLA (class in rayoptics.codev.tla), 51max_aperture (Interface attribute), 122max_dimension() (Aperture method), 67max_dimension() (Circular method), 67max_field() (FieldSpec method), 112maxdim (DiffractionPSF attribute), 76Medium (class in rayoptics.seq.medium), 123medium (Gap attribute), 121medium_name (CementedElement attribute), 54medium_name (Element attribute), 52menu_action (PanelInfo attribute), 98Mirror (class in rayoptics.elem.elements), 53MM (DimensionType attribute), 85model (AppManager attribute), 71model (ModelInfo attribute), 71ModelBinding (class in rayoptics.qtgui.dockpanels),
98ModelInfo (class in rayoptics.gui.appmanager), 71mutate() (Spherical method), 62mutate_field_type() (FieldSpec method), 112mutate_profile() (in module rayop-
tics.elem.profiles), 65mutate_pupil_type() (PupilSpec method), 112
Nn_img (FirstOrderData attribute), 92n_obj (FirstOrderData attribute), 92NA (PupilType attribute), 84na2slp() (in module rayoptics.parax.etendue), 90name() (Air method), 123name() (Glass method), 123name() (InterpolatedGlass method), 124name() (Medium method), 123name() (OpticalModel method), 87
NAO (PupilType attribute), 84new_console_empty_model() (MainWindow
method), 103new_model() (MainWindow method), 103new_model_via_specsheet() (MainWindow
method), 103next_line() (in module rayoptics.codev.reader), 51nm_to_sys_units() (OpticalModel method), 87nm_to_sys_units() (SystemSpec method), 86node() (PartTree method), 59nodes_from_node_defs() (in module rayop-
tics.parax.paraxialdesign), 96nodes_to_parax() (ParaxialModel method), 94nodes_with_tag() (PartTree method), 60normal() (Interface method), 122normal() (Surface method), 67normal() (SurfaceProfile method), 60normal() (ThinLens method), 83normal() (XToroid method), 65normalize() (in module rayoptics.util.misc_math),
131nrml (RaySeg attribute), 117NullDropAction (class in rayoptics.qtgui.plotview),
101num_items_by_cell() (in module rayop-
tics.util.dict2d), 131num_items_by_type() (in module rayop-
tics.util.dict2d), 131num_rays (RayFan attribute), 107num_rays (RayGrid attribute), 109num_rays (RayList attribute), 108
OOBJ_ANG (FieldType attribute), 85obj_ang (FirstOrderData attribute), 92obj_coords() (FieldSpec method), 112obj_coords() (OpticalSpecs method), 111obj_dist (FirstOrderData attribute), 92OBJ_HT (FieldType attribute), 85obj_na (FirstOrderData attribute), 92offset_factor (InteractiveLayout attribute), 81on_active_diagram_toggled() (in module ray-
optics.qtgui.plotview), 102on_barrel_constraint_changed() (in module
rayoptics.qtgui.plotview), 102on_barrel_constraint_toggled() (in module
rayoptics.qtgui.plotview), 102on_bend_or_gap_toggled() (in module rayop-
tics.qtgui.plotview), 102on_command_clicked() (in module rayop-
tics.qtgui.plotview), 101on_data_changed() (MainWindow method), 104on_motion() (InteractiveFigure method), 80
156 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
on_plot_scale_changed() (in module rayop-tics.qtgui.plotview), 102
on_plot_scale_toggled() (in module rayop-tics.qtgui.plotview), 102
on_press() (InteractiveFigure method), 80on_release() (InteractiveFigure method), 80on_select() (InteractiveFigure method), 80on_view_activated() (AppManager method), 72op (RayPkg attribute), 117open_file() (MainWindow method), 103open_model() (in module rayoptics.gui.appcmds), 70open_roa() (in module rayoptics.gui.roafile), 72opt_inv (FirstOrderData attribute), 91opt_model (ElementModel attribute), 56opt_model (InteractiveDiagram attribute), 78opt_model (InteractiveLayout attribute), 80opt_model (Ray attribute), 106opt_model (RayFan attribute), 107opt_model (RayGrid attribute), 109opt_model (RayList attribute), 108opt_model (SequentialModel attribute), 125optical_power (Surface attribute), 66optical_power (ThinLens attribute), 83optical_spec (OpticalModel attribute), 87OpticalElement (class in rayoptics.elem.layout), 57OpticalModel (class in rayop-
tics.optical.opticalmodel), 86OpticalSpecs (class in rayoptics.raytr.opticalspec),
110order (DiffractiveElement attribute), 82oversize_factor (InteractiveFigure attribute), 79
Pp (Ray attribute), 106p (RaySeg attribute), 117PanAction (class in rayoptics.mpl.interactivefigure),
80panel_widget (PanelInfo attribute), 98PanelInfo (class in rayoptics.qtgui.dockpanels), 98parax_data (OpticalSpecs attribute), 110parax_model (OpticalModel attribute), 87parax_to_nodes() (ParaxialModel method), 94ParaxData (class in rayoptics.parax.firstorder), 91paraxial_lens_to_seq_model() (Paraxi-
alModel method), 95paraxial_trace() (in module rayop-
tics.parax.firstorder), 92paraxial_trace() (ParaxialModel method), 95paraxial_vignetting() (ParaxialModel method),
95ParaxialModel (class in rayop-
tics.parax.paraxialdesign), 94ParaxialRay (class in rayoptics.elem.layout), 58parent (CementedElement attribute), 54
parent (Element attribute), 52parent_node() (PartTree method), 59parent_object() (PartTree method), 59partition_defined() (SpecSheet method), 97partitions (SpecSheet attribute), 97PartTree (class in rayoptics.elem.parttree), 59path (ColourSystem attribute), 130path() (SequentialModel method), 126perpendicular_distance_2d() (in module ray-
optics.util.misc_math), 131perpendicular_from_origin() (in module ray-
optics.util.misc_math), 132perpendicular_to_line() (in module rayop-
tics.util.misc_math), 131perpendicular_to_radial() (in module rayop-
tics.util.misc_math), 131phase() (DiffractiveElement method), 82phase() (HolographicElement method), 83phase() (in module rayoptics.raytr.raytrace), 114phase() (Interface method), 122phase() (ThinLens method), 83phase_fct (DiffractiveElement attribute), 82phi() (in module rayoptics.raytr.sampler), 117planck() (in module rayoptics.util.colour_system),
131plot() (AnalysisFigure method), 74plot() (AnalysisPlot method), 77plot() (AstigmatismCurvePlot method), 77plot() (AxisArrayFigure method), 77plot() (DiffractionPSF method), 76plot() (FieldCurveFigure method), 77plot() (InteractiveFigure method), 80plot() (RayFanFigure method), 78plot() (RayFanPlot method), 75plot() (RayGeoPSF method), 75plot() (SpotDiagramFigure method), 78plot() (ThirdOrderBarChart method), 77plot() (Wavefront method), 76plot() (WavefrontFigure method), 78PlotCanvas (class in rayoptics.qtgui.plotview), 101point_inside() (Aperture method), 67point_inside() (Circular method), 67point_inside() (Rectangular method), 68polar_grid_ray_generator() (in module rayop-
tics.raytr.sampler), 117poly (GUIHandle attribute), 73polydata (GraphicsHandle attribute), 51polytype (GraphicsHandle attribute), 51post_process_input() (in module rayop-
tics.codev.cmdproc), 50post_process_input() (in module rayop-
tics.zemax.zmxread), 133postprocess_roa() (in module rayop-
tics.gui.roafile), 72
Index 157
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
pp1 (FirstOrderData attribute), 91ppk (FirstOrderData attribute), 91pr_ray (ParaxData attribute), 91preprocess_roa() (in module rayoptics.gui.roafile),
72pressure (SystemSpec attribute), 86print_text() (ConsoleWidget method), 101private_catalog() (in module rayop-
tics.codev.cmdproc), 50process_airgap() (in module rayop-
tics.elem.parttree), 60process_command() (in module rayop-
tics.codev.cmdproc), 50process_glass_data() (CVGlassHandler
method), 50process_line() (in module rayop-
tics.zemax.zmxread), 133profile() (Conic method), 63profile() (EvenPolynomial method), 64profile() (RadialPolynomial method), 64profile() (Spherical method), 62profile() (SurfaceProfile method), 60profile() (YToroid method), 65profile_cv (Interface attribute), 122profile_cv (Surface attribute), 66profile_cv (ThinLens attribute), 83profile_data() (in module rayop-
tics.codev.cmdproc), 50projected_point_on_line() (in module rayop-
tics.util.misc_math), 132projected_point_on_radial_line() (in mod-
ule rayoptics.util.misc_math), 132projected_point_on_radial_line_full()
(in module rayoptics.util.misc_math), 132psf_sampling() (in module rayop-
tics.raytr.analyses), 109pupil (OpticalSpecs attribute), 110pupil_coords (RayList attribute), 108pupil_data() (in module rayoptics.zemax.zmxread),
133pupil_gen (RayList attribute), 108pupil_grid (DiffractionPSF attribute), 76pupil_rays (PupilSpec attribute), 112pupil_spec_data() (in module rayop-
tics.codev.cmdproc), 50PupilSpec (class in rayoptics.raytr.opticalspec), 111PupilType (class in rayoptics.optical.model_enums),
84push_vars() (ConsoleWidget method), 101pwr_ht_solve() (ParaxialModel method), 95pwr_slope_solve() (ParaxialModel method), 95PyTableModel (class in rayop-
tics.qtgui.pytablemodel), 102
Rr (Conic attribute), 63r (EvenPolynomial attribute), 63r (RadialPolynomial attribute), 64r (Spherical attribute), 62r (YToroid attribute), 65R_2_quasi_random_generator() (in module
rayoptics.raytr.sampler), 117radial_phase_fct() (in module rayop-
tics.oprops.doe), 82RadialPolynomial (class in rayoptics.elem.profiles),
64radius_mode (OpticalModel attribute), 86Ray (class in rayoptics.raytr.analyses), 106ray (RayPkg attribute), 117ray_data_bounds() (RayGeoPSF method), 75ray_df() (in module rayoptics.raytr.trace), 117ray_grid (Wavefront attribute), 75ray_labels (PupilSpec attribute), 112ray_list (RayGeoPSF attribute), 75ray_pkg() (in module rayoptics.raytr.trace), 117RayBundle (class in rayoptics.elem.layout), 58RayFan (class in rayoptics.raytr.analyses), 107RayFanBundle (class in rayoptics.elem.layout), 58RayFanFigure (class in rayop-
tics.mpl.axisarrayfigure), 77RayFanPlot (class in rayoptics.mpl.analysisfigure), 74RayGeoPSF (class in rayoptics.mpl.analysisfigure), 75RayGrid (class in rayoptics.raytr.analyses), 109RayList (class in rayoptics.raytr.analyses), 108rayoptics (module), 49rayoptics.codev (module), 49rayoptics.codev.cmdproc (module), 50rayoptics.codev.reader (module), 51rayoptics.codev.tla (module), 51rayoptics.elem (module), 51rayoptics.elem.elements (module), 51rayoptics.elem.layout (module), 57rayoptics.elem.parttree (module), 59rayoptics.elem.profiles (module), 60rayoptics.elem.surface (module), 66rayoptics.elem.transform (module), 68rayoptics.environment (module), 134rayoptics.gui (module), 69rayoptics.gui.actions (module), 69rayoptics.gui.appcmds (module), 70rayoptics.gui.appmanager (module), 71rayoptics.gui.dashboards (module), 72rayoptics.gui.roafile (module), 72rayoptics.gui.util (module), 73rayoptics.mpl (module), 73rayoptics.mpl.analysisfigure (module), 73rayoptics.mpl.analysisplots (module), 76rayoptics.mpl.axisarrayfigure (module), 77
158 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
rayoptics.mpl.interactivediagram (mod-ule), 78
rayoptics.mpl.interactivefigure (module),78
rayoptics.mpl.interactivelayout (module),80
rayoptics.mpl.styledfigure (module), 81rayoptics.oprops (module), 81rayoptics.oprops.doe (module), 81rayoptics.oprops.thinlens (module), 83rayoptics.optical (module), 84rayoptics.optical.model_constants (mod-
ule), 84rayoptics.optical.model_enums (module), 84rayoptics.optical.obench (module), 88rayoptics.optical.opticalmodel (module),
86rayoptics.parax (module), 88rayoptics.parax.diagram (module), 88rayoptics.parax.etendue (module), 90rayoptics.parax.firstorder (module), 91rayoptics.parax.idealimager (module), 93rayoptics.parax.paraxialdesign (module),
94rayoptics.parax.specsheet (module), 96rayoptics.parax.thirdorder (module), 97rayoptics.qtgui (module), 98rayoptics.qtgui.dockpanels (module), 98rayoptics.qtgui.idealimagerdialog (mod-
ule), 100rayoptics.qtgui.ipyconsole (module), 101rayoptics.qtgui.plotview (module), 101rayoptics.qtgui.pytablemodel (module), 102rayoptics.qtgui.rayopticsapp (module), 103rayoptics.raytr (module), 104rayoptics.raytr.analyses (module), 104rayoptics.raytr.opticalspec (module), 110rayoptics.raytr.raytrace (module), 113rayoptics.raytr.sampler (module), 116rayoptics.raytr.trace (module), 117rayoptics.raytr.traceerror (module), 120rayoptics.seq (module), 120rayoptics.seq.gap (module), 121rayoptics.seq.interface (module), 121rayoptics.seq.medium (module), 123rayoptics.seq.sequential (module), 125rayoptics.seq.twoconicmirrors (module),
129rayoptics.util (module), 129rayoptics.util.colors (module), 130rayoptics.util.colour_system (module), 130rayoptics.util.dict2d (module), 131rayoptics.util.line_intersection (mod-
ule), 131
rayoptics.util.misc_math (module), 131rayoptics.util.rgb2mpl (module), 132rayoptics.util.rgbtable (module), 132rayoptics.zemax (module), 133rayoptics.zemax.zmx2ro (module), 134rayoptics.zemax.zmxread (module), 133RayPkg (class in rayoptics.raytr.trace), 117RaySeg (class in rayoptics.raytr.trace), 117read_lens() (in module rayoptics.codev.cmdproc), 50read_lens() (in module rayoptics.optical.obench), 88read_lens() (in module rayoptics.zemax.zmxread),
133read_lens_file() (in module rayop-
tics.zemax.zmxread), 133read_lens_url() (in module rayop-
tics.zemax.zmxread), 133read_obench_url() (in module rayop-
tics.optical.obench), 88read_seq_buffer() (in module rayop-
tics.codev.reader), 51read_seq_file() (in module rayop-
tics.codev.reader), 51rebuild_from_seq() (OpticalModel method), 87Rectangular (class in rayoptics.elem.surface), 67red (FirstOrderData attribute), 92ref_sphere (Field attribute), 113ref_wl (DiffractiveElement attribute), 82reference_idx() (AirGap method), 56reference_idx() (CementedElement method), 55reference_idx() (DummyInterface method), 55reference_idx() (Element method), 53reference_idx() (Mirror method), 53reference_idx() (ThinElement method), 55reference_interface() (AirGap method), 56reference_interface() (CementedElement
method), 55reference_interface() (DummyInterface
method), 55reference_interface() (Element method), 53reference_interface() (Mirror method), 53reference_interface() (ThinElement method),
55reflect() (in module rayoptics.raytr.raytrace), 113refresh() (AnalysisFigure method), 74refresh() (AnalysisPlot method), 77refresh() (AxisArrayFigure method), 77refresh() (DiffractionPSF method), 76refresh() (EnumChoiceWidget method), 99refresh() (FieldCurveFigure method), 76refresh() (InteractiveFigure method), 79refresh() (ListChoiceWidget method), 99refresh() (RayFanPlot method), 75refresh() (RayGeoPSF method), 75refresh() (TextFieldWidget method), 99
Index 159
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
refresh() (ThirdOrderBarChart method), 77refresh() (Wavefront method), 76refresh_app_ui() (MainWindow method), 104refresh_figures() (AppManager method), 72refresh_gui (InteractiveDiagram attribute), 78refresh_gui (InteractiveLayout attribute), 81refresh_gui() (AppManager method), 72refresh_gui() (MainWindow method), 104refresh_views() (AppManager method), 72register_action() (InteractiveFigure method), 79register_add_replace_element() (Diagram
method), 88register_commands() (Diagram method), 88register_commands() (LensLayout method), 58register_pan() (InteractiveFigure method), 79register_zoom_box() (InteractiveFigure method),
79relabel_airgaps() (ElementModel method), 56relative_colorimetric_gamut_mapping()
(ColourSystem method), 131remove() (SequentialModel method), 127remove_element() (ElementModel method), 56remove_ifc_gp_ele() (OpticalModel method), 87remove_node() (ElementModel method), 56remove_node() (OpticalModel method), 87remove_node() (SequentialModel method), 127remove_null_sg() (in module rayop-
tics.zemax.zmx2ro), 134render_color() (DiagramEdge method), 89render_color() (OpticalElement method), 57render_handles() (AirGap method), 56render_handles() (CementedElement method), 55render_handles() (DummyInterface method), 56render_handles() (Element method), 53render_handles() (Mirror method), 54render_handles() (ThinElement method), 55render_ray() (ParaxialRay method), 58render_ray() (RayBundle method), 58render_ray() (RayFanBundle method), 58render_shape() (CementedElement method), 55render_shape() (Diagram method), 89render_shape() (DummyInterface method), 56render_shape() (Element method), 53render_shape() (Mirror method), 54render_shape() (RayBundle method), 58render_shape() (ThinElement method), 55replace_node_with_seq() (ParaxialModel
method), 94ReplaceGlassAction (class in rayop-
tics.gui.actions), 69reset() (ElementModel method), 56reset() (OpticalModel method), 87reset() (SequentialModel method), 126
reset_serial_numbers() (ElementModelmethod), 56
resize_list() (in module rayoptics.elem.profiles),60
retrieve_ray() (in module rayop-tics.raytr.analyses), 106
REV (DecenterType attribute), 85reverse_path() (SequentialModel method), 126reverse_transform() (in module rayop-
tics.elem.transform), 68rgb2mpl() (in module rayoptics.util.rgb2mpl), 132rgb_to_hex() (ColourSystem method), 130RGBTable (class in rayoptics.util.rgbtable), 132rindex() (Glass method), 123rindex() (InterpolatedGlass method), 124rindex() (Medium method), 123rindex_interp (InterpolatedGlass attribute), 124ritchey_chretien() (in module rayop-
tics.seq.twoconicmirrors), 129rndx (InterpolatedGlass attribute), 124rndx (SequentialModel attribute), 125ro_version (OpticalModel attribute), 86root (PyTableModel attribute), 102root() (AperturePanel method), 99root() (FieldOfViewPanel method), 99root() (SpectrumWavelengthsPanel method), 99root() (SystemSpecPanel method), 99rootEvalStr (PyTableModel attribute), 102row() (in module rayoptics.util.dict2d), 131rowCount() (PyTableModel method), 103rowHeaders (PyTableModel attribute), 102rR (YToroid attribute), 65RSeg (class in rayoptics.raytr.trace), 117
Ss (IdealImager attribute), 93s1 (Element attribute), 52s2 (Element attribute), 52sag() (Conic method), 63sag() (EvenPolynomial method), 63sag() (RadialPolynomial method), 64sag() (Spherical method), 62sag() (SurfaceProfile method), 60sag() (XToroid method), 65sag() (YToroid method), 65SagAction (class in rayoptics.gui.actions), 69save_file() (MainWindow method), 103save_model() (OpticalModel method), 87save_replacements() (GlassHandlerBase
method), 124scale_bounds() (in module rayoptics.gui.util), 73scale_type (RayFanPlot attribute), 74scale_type (RayGeoPSF attribute), 75scale_type (Wavefront attribute), 75
160 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
scan_nodes() (in module rayop-tics.parax.paraxialdesign), 96
sd (CementedElement attribute), 54sd (Element attribute), 53seidel_to_field_curv() (in module rayop-
tics.parax.thirdorder), 98seidel_to_transverse_aberration() (in
module rayoptics.parax.thirdorder), 97seidel_to_wavefront() (in module rayop-
tics.parax.thirdorder), 97select_plot_data() (in module rayop-
tics.raytr.analyses), 107SelectInfo (class in rayoptics.mpl.interactivefigure),
78seq_model (OpticalModel attribute), 86seq_path_to_paraxial_lens() (ParaxialModel
method), 95sequence_elements() (ElementModel method), 56SequentialModel (class in rayoptics.seq.sequential),
125serial_number (AirGap attribute), 56serial_number (CementedElement attribute), 54serial_number (DummyInterface attribute), 55serial_number (Element attribute), 53serial_number (Mirror attribute), 53serial_number (ThinElement attribute), 55set() (AttrChanger method), 72set() (ModelBinding method), 98set_active_layer() (Diagram method), 88set_bending() (Element method), 53set_clear_apertures() (SequentialModel
method), 128set_clear_apertures_paraxial() (Sequen-
tialModel method), 128set_coef() (RadialPolynomial method), 64set_cur_surface() (SequentialModel method), 126set_dimension() (Aperture method), 67set_dimension() (Circular method), 67set_dimension() (Elliptical method), 68set_dimension() (Rectangular method), 67set_from_list() (FieldSpec method), 112set_from_list() (OpticalSpecs method), 111set_from_list() (WvlSpec method), 111set_from_specsheet() (FieldSpec method), 112set_from_specsheet() (FocusRange method), 113set_from_specsheet() (OpticalModel method),
87set_from_specsheet() (OpticalSpecs method),
111set_from_specsheet() (PupilSpec method), 112set_from_specsheet() (SequentialModel
method), 127set_from_specsheet() (WvlSpec method), 111set_max_aperture() (Interface method), 122
set_max_aperture() (ThinLens method), 83set_model() (AppManager method), 71set_optical_power() (Interface method), 122set_optical_power() (Surface method), 66set_optical_power() (ThinLens method), 83set_pt() (ParaxialModel method), 94set_stop() (SequentialModel method), 126set_view_bbox() (InteractiveFigure method), 80set_z_sag() (Surface method), 66setData() (CommandItem method), 101setData() (PyTableModel method), 103setup_canonical_coords() (in module rayop-
tics.raytr.trace), 119setup_dgm_type() (Diagram method), 88setup_dgm_type() (InteractiveDiagram method), 78setup_exit_pupil_coords() (in module rayop-
tics.raytr.analyses), 105setup_pupil_coords() (in module rayop-
tics.raytr.trace), 119setup_shift_of_ray_bundle() (in module ray-
optics.elem.layout), 57shift_start_of_ray_bundle() (in module ray-
optics.elem.layout), 57slp2ang() (in module rayoptics.parax.etendue), 91slp2na() (in module rayoptics.parax.etendue), 90smooth_plot_data() (in module rayop-
tics.raytr.analyses), 107sort_using_sequence() (PartTree method), 59sp (IdealImager attribute), 93SpaceGroupBox (class in rayop-
tics.qtgui.idealimagerdialog), 100spec_data() (in module rayoptics.codev.cmdproc), 50spec_to_rgb() (ColourSystem method), 130spec_to_xyz() (ColourSystem method), 130SpecSheet (class in rayoptics.parax.specsheet), 97specsheet (OpticalModel attribute), 86specsheet_from_parax_data() (in module ray-
optics.parax.firstorder), 93spectral_region (OpticalSpecs attribute), 110SpectrumWavelengthsPanel (class in rayop-
tics.qtgui.dockpanels), 99spheres() (in module rayoptics.seq.twoconicmirrors),
129Spherical (class in rayoptics.elem.profiles), 62split_gap() (in module rayoptics.elem.layout), 58SpotDiagramFigure (class in rayop-
tics.mpl.axisarrayfigure), 78srf_indx (Ray attribute), 107srf_save (Ray attribute), 107stop_surface (SequentialModel attribute), 126strip_comments() (in module rayop-
tics.codev.reader), 51StyledFigure (class in rayoptics.mpl.styledfigure),
81
Index 161
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
subplots (AnalysisFigure attribute), 74substrate_offset() (Mirror method), 54Surface (class in rayoptics.elem.surface), 66surface_cmd() (in module rayoptics.codev.cmdproc),
50surface_data() (in module rayop-
tics.codev.cmdproc), 50surface_label_list() (SequentialModel
method), 127surface_od() (Interface method), 122surface_od() (Surface method), 66surface_od() (ThinLens method), 83SurfaceProfile (class in rayoptics.elem.profiles), 60sync_light_or_dark() (AppManager method), 72sync_light_or_dark() (Diagram method), 88sync_light_or_dark() (InteractiveDiagram
method), 78sync_light_or_dark() (InteractiveLayout
method), 81sync_light_or_dark() (LensLayout method), 58sync_light_or_dark() (StyledFigure method), 81sync_part_tree_on_restore() (in module ray-
optics.elem.parttree), 60sync_part_tree_on_update() (in module rayop-
tics.elem.parttree), 60sync_to_restore() (AirGap method), 56sync_to_restore() (Aperture method), 67sync_to_restore() (CementedElement method), 54sync_to_restore() (DummyInterface method), 55sync_to_restore() (Element method), 53sync_to_restore() (ElementModel method), 56sync_to_restore() (FieldSpec method), 112sync_to_restore() (Gap method), 121sync_to_restore() (Glass method), 123sync_to_restore() (Interface method), 122sync_to_restore() (InterpolatedGlass method),
124sync_to_restore() (Mirror method), 53sync_to_restore() (OpticalModel method), 87sync_to_restore() (OpticalSpecs method), 111sync_to_restore() (ParaxialModel method), 94sync_to_restore() (PartTree method), 59sync_to_restore() (PupilSpec method), 112sync_to_restore() (SequentialModel method), 127sync_to_restore() (SpecSheet method), 97sync_to_restore() (Surface method), 66sync_to_restore() (ThinElement method), 55sync_to_restore() (WvlSpec method), 111sync_to_update() (AirGap method), 56sync_to_update() (CementedElement method), 54sync_to_update() (DummyInterface method), 55sync_to_update() (Element method), 53sync_to_update() (Mirror method), 53sync_to_update() (ThinElement method), 55
system_length() (LensLayout method), 58system_spec (OpticalModel attribute), 86SystemSpec (class in rayoptics.optical.opticalmodel),
86SystemSpecPanel (class in rayop-
tics.qtgui.dockpanels), 99
Ttemperature (SystemSpec attribute), 86test() (in module rayoptics.elem.profiles), 65TextFieldWidget (class in rayop-
tics.qtgui.dockpanels), 99tform() (Aperture method), 67tform_after_surf() (DecenterData method), 67tform_before_surf() (DecenterData method), 67tfrm (CementedElement attribute), 54tfrm (Element attribute), 52tfrm (GraphicsHandle attribute), 51thi (Gap attribute), 121thi_ht_solve() (ParaxialModel method), 95ThinElement (class in rayoptics.elem.elements), 55ThinLens (class in rayoptics.oprops.thinlens), 83ThirdOrderBarChart (class in rayop-
tics.mpl.analysisplots), 77title (DiffractionPSF attribute), 76title (RayFanPlot attribute), 74title (RayGeoPSF attribute), 75title (SystemSpec attribute), 86title (Wavefront attribute), 76togglePanel() (in module rayop-
tics.qtgui.dockpanels), 98tokenize_command() (in module rayop-
tics.codev.reader), 51trace() (in module rayoptics.raytr.raytrace), 114trace() (in module rayoptics.raytr.trace), 117trace() (SequentialModel method), 128trace_all_fields() (in module rayop-
tics.raytr.trace), 119trace_astigmatism() (in module rayop-
tics.raytr.trace), 119trace_astigmatism_coddington_fan() (in
module rayoptics.raytr.trace), 119trace_base() (in module rayoptics.raytr.trace), 118trace_boundary_rays() (in module rayop-
tics.raytr.trace), 119trace_boundary_rays_at_field() (in module
rayoptics.raytr.trace), 119trace_chief_ray() (in module rayop-
tics.raytr.trace), 119trace_coddington_fan() (in module rayop-
tics.raytr.trace), 119trace_fan() (in module rayoptics.raytr.analyses),
107trace_fan() (in module rayoptics.raytr.trace), 119
162 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
trace_fan() (SequentialModel method), 128trace_field() (in module rayoptics.raytr.trace), 119trace_grid() (in module rayoptics.raytr.trace), 119trace_grid() (SequentialModel method), 128trace_list_of_rays() (in module rayop-
tics.raytr.analyses), 108trace_pupil_coords() (in module rayop-
tics.raytr.analyses), 109trace_raw() (in module rayoptics.raytr.raytrace), 114trace_ray_fan() (in module rayop-
tics.raytr.analyses), 107trace_ray_grid() (in module rayop-
tics.raytr.analyses), 109trace_ray_list() (in module rayop-
tics.raytr.analyses), 108trace_ray_list_at_field() (in module rayop-
tics.raytr.trace), 119trace_safe() (in module rayoptics.raytr.analyses),
106trace_wavefront() (in module rayop-
tics.raytr.analyses), 109trace_wavefront() (SequentialModel method), 128trace_with_opd() (in module rayoptics.raytr.trace),
119TraceError, 120TraceEvanescentRayError, 120TraceMissedSurfaceError, 120TraceRayBlockedError, 120TraceTIRError, 120transfer_coords() (in module rayop-
tics.elem.transform), 68transfer_to_exit_pupil() (in module rayop-
tics.raytr.raytrace), 115transform_after_surface() (in module rayop-
tics.elem.transform), 68transform_before_surface() (in module rayop-
tics.elem.transform), 68transform_poly() (in module rayoptics.gui.util), 73transform_ray_seg() (in module rayop-
tics.gui.util), 73transpose() (in module rayoptics.util.misc_math),
132tree() (AirGap method), 56tree() (CementedElement method), 55tree() (DummyInterface method), 55tree() (Element method), 53tree() (Mirror method), 53tree() (ThinElement method), 55trim_node() (PartTree method), 59tt (IdealImager attribute), 93
Uupdate (PyTableModel attribute), 103update() (AperturePanel method), 99
update() (DecenterData method), 67update() (EvenPolynomial method), 63update() (Field method), 113update() (FieldOfViewPanel method), 99update() (FocusRange method), 113update() (Glass method), 124update() (Interface method), 122update() (InterpolatedGlass method), 124update() (RadialPolynomial method), 64update() (SpectrumWavelengthsPanel method), 99update() (Surface method), 66update() (SurfaceProfile method), 60update() (SystemSpecPanel method), 99update() (ThinLens method), 83update() (YToroid method), 65update_axis_limits() (InteractiveFigure
method), 80update_checkboxes() (EtendueGroupBox
method), 100update_checkboxes() (IdealImagerDialog
method), 100update_checkboxes() (ImagerSpecGroupBox
method), 100update_checkboxes() (SpaceGroupBox method),
100update_composite_node() (ParaxialModel
method), 95update_conjugate() (IdealImagerDialog method),
100update_data() (AnalysisFigure method), 74update_data() (AnalysisPlot method), 77update_data() (AstigmatismCurvePlot method), 77update_data() (AxisArrayFigure method), 77update_data() (Diagram method), 88update_data() (DiffractionPSF method), 76update_data() (FieldCurveFigure method), 76update_data() (InteractiveDiagram method), 78update_data() (InteractiveFigure method), 79update_data() (InteractiveLayout method), 81update_data() (Ray method), 107update_data() (RayFan method), 107update_data() (RayFanFigure method), 78update_data() (RayFanPlot method), 75update_data() (RayGeoPSF method), 75update_data() (RayGrid method), 109update_data() (RayList method), 108update_data() (SpotDiagramFigure method), 78update_data() (ThirdOrderBarChart method), 77update_data() (Wavefront method), 76update_data() (WavefrontFigure method), 78update_diagram_for_key() (in module rayop-
tics.parax.paraxialdesign), 95update_diagram_from_shape() (Diagram
method), 89
Index 163
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
update_dock_windows() (in module rayop-tics.qtgui.dockpanels), 98
update_figure_view() (in module rayop-tics.qtgui.plotview), 101
update_model() (ElementModel method), 56update_model() (FieldSpec method), 112update_model() (OpticalModel method), 87update_model() (OpticalSpecs method), 111update_model() (ParaxialModel method), 94update_model() (PartTree method), 59update_model() (PupilSpec method), 112update_model() (SequentialModel method), 127update_model() (WvlSpec method), 111update_patches() (InteractiveFigure method), 79update_psf_data() (in module rayop-
tics.raytr.analyses), 110update_reflections() (SequentialModel
method), 127update_rindex() (ParaxialModel method), 95update_shape() (BarrelConstraint method), 89update_shape() (ConjugateLine method), 89update_shape() (DiagramEdge method), 89update_shape() (DiagramNode method), 89update_shape() (OpticalElement method), 57update_shape() (ParaxialRay method), 58update_shape() (RayBundle method), 58update_shape() (RayFanBundle method), 58update_size() (AirGap method), 56update_size() (CementedElement method), 55update_size() (DummyInterface method), 56update_size() (Element method), 53update_size() (Mirror method), 54update_size() (ThinElement method), 55update_specsheet() (in module rayop-
tics.gui.appcmds), 70update_surface_and_gap() (in module rayop-
tics.codev.cmdproc), 50update_surface_profile() (in module rayop-
tics.codev.cmdproc), 50update_table_view() (in module rayop-
tics.gui.appcmds), 70update_values() (EtendueGroupBox method), 100update_values() (IdealImagerDialog method), 100update_values() (ImagerSpecGroupBox method),
100update_values() (SpaceGroupBox method), 100User_Scale (Fit attribute), 77user_scale_value (RayFanPlot attribute), 74user_scale_value (RayGeoPSF attribute), 75user_scale_value (Wavefront attribute), 75
Vvalue (FieldSpec attribute), 112value (PupilSpec attribute), 111
value_change() (EtendueGroupBox method), 100value_change() (ImagerSpecGroupBox method),
100value_to_text() (in module rayop-
tics.qtgui.idealimagerdialog), 100view_action() (MainWindow method), 103view_dict (AppManager attribute), 71vlx (Field attribute), 113vly (Field attribute), 113vux (Field attribute), 113vuy (Field attribute), 113
Wwave_abr_calc() (in module rayop-
tics.raytr.analyses), 106wave_abr_full_calc() (in module rayop-
tics.raytr.analyses), 105wave_abr_pre_calc() (in module rayop-
tics.raytr.analyses), 106Wavefront (class in rayoptics.mpl.analysisfigure), 75WavefrontFigure (class in rayop-
tics.mpl.axisarrayfigure), 78window_action() (MainWindow method), 103wl (Ray attribute), 107wl (RayFan attribute), 107wl (RayGrid attribute), 109wl (RayList attribute), 108wt (Field attribute), 113wvl (RayPkg attribute), 117wvl_spec_data() (in module rayop-
tics.codev.cmdproc), 50wvl_to_rgb() (ColourSystem method), 130wvl_to_sys_units() (AxisArrayFigure method), 77wvl_to_xyz() (ColourSystem method), 130wvls (InterpolatedGlass attribute), 124WvlSpec (class in rayoptics.raytr.opticalspec), 111
Xx (Field attribute), 112XToroid (class in rayoptics.elem.profiles), 65xyfan (RayFan attribute), 107xyz_from_xy() (in module rayop-
tics.util.colour_system), 130xyz_to_rgb() (ColourSystem method), 130
Yy (Field attribute), 113yaxis_ticks_position (DiffractionPSF attribute),
76yaxis_ticks_position (RayFanPlot attribute), 74yaxis_ticks_position (RayGeoPSF attribute), 75yaxis_ticks_position (Wavefront attribute), 76YToroid (class in rayoptics.elem.profiles), 65
164 Index
ray-optics, Release 0.7.4+1.g3b2c9ab.dirty
Zz_dir (SequentialModel attribute), 125z_sag() (Surface method), 66ZmxGlassHandler (class in rayop-
tics.zemax.zmxread), 133zoom() (InteractiveFigure method), 80zoom_in() (InteractiveFigure method), 80zoom_out() (InteractiveFigure method), 80ZoomBoxAction (class in rayop-
tics.mpl.interactivefigure), 80
Index 165