def test_zemax_to_elements(): train0 = zemax.read_train( os.path.join(DESIGNS_DIR, 'aspheric_telecentric_lens.zmx'), encoding='ascii', glass_catalog_paths=zemax.SUPPLIED_GLASS_CATALOG_PATHS) train1 = train0.crop_to_finite() # Convert to a sequence of axisymemtric singlet lenses. sequence = trains.SingletSequence.from_train2(train1, 'max') # Convert to rt2 Elements. elements = rt2.make_elements(sequence, 'circle') assert len(elements) == 3
def test_read_train_conic_aspheric_telecentric_lens(): # Ensure we use the supplied glass catalogs. train = zemax.read_train(os.path.join(DESIGNS_DIR, 'aspheric_telecentric_lens.zmx'), encoding='ascii', glass_catalog_paths=zemax.SUPPLIED_GLASS_CATALOG_PATHS) assert len(train.interfaces) == 9 assert_allclose(train.spaces, (0., np.inf, 10e-3, 20e-3, 6.757645743585563e-2, 20e-3, 2.868233931997107e-2, 20e-3, 7.045493144939738e-2, 0)) bk7 = agf.load_catalog(zemax.SUPPLIED_GLASS_CATALOG_PATHS['SCHOTT'])['N-BK7'].fix_temperature() radius0 = 2.859595844931864e-2 radius1 = 3.398390496818528e-2 - radius0 surface0 = trains.ConicSurface(-3.399643783726705e-2, radius0, 1 - 2.667544379512378E+000, (0, 0, -1.899747134198353e3, 0, 2.093291560636944e5)) surface1 = trains.SphericalSurface(np.inf, radius1) interface = train.interfaces[4] assert isinstance(interface, trains.SegmentedInterface) assert interface.n1 == ri.air assert interface.n2 == bk7 assert interface.segments[0].isclose(surface0) assert interface.segments[1].isclose(surface1) assert_allclose(interface.sags, (0, surface0.calc_sag(surface0.radius)))
import os import itertools import numpy as np from matplotlib import colors as mcolors import mathx from PyQt5 import QtWidgets from otk.sdb import lookat, projection from otk import zemax, trains, ri, sdb, DESIGNS_DIR from otk.rt2 import rt2_scalar_qt as rt2 # Load Zemax file. train_full = zemax.read_train(os.path.join(DESIGNS_DIR, 'aspheric_telecentric_lens.zmx'), encoding='ascii') # Remove object, stop and image surfaces. train = train_full.subset(2, -1) # Convert to a sequence of axisymemtric singlet lenses. singlet_sequence = trains.SingletSequence.from_train(train) # Convert to rt2 Elements. For fun make the lenses square. elements = rt2.make_elements(singlet_sequence, 'square') # Create assembly object for ray tracing. assembly = rt2.Assembly.make(elements, ri.air) lamb = 850e-9 # Get paraxial focal length. f = train.get_effective_focal_length(lamb) stop_half_width = train_full.interfaces[1].radius / 2**0.5 field_half_angle = np.radians(10) traced_rays = [] colors = []
import os import time import itertools import numpy as np from matplotlib import colors as mcolors from PyQt5 import QtWidgets from otk.sdb import lookat, projection from otk import zemax, trains from otk import ri from otk.sdb import npscalar from otk.sdb import numba as sdb_numba from otk.rt2 import rt2_scalar_qt as rt2 # Load Zemax file. train_full = zemax.read_train(os.path.join(os.path.dirname(__file__), 'conic_telecentric_lens.zmx'), encoding='ascii') # Remove object, stop and image surfaces. train = train_full.subset(2, -1) # Convert to a sequence of axisymemtric singlet lenses. singlet_sequence = trains.SingletSequence.from_train(train) # Convert to rt2 Elements. For fun make the lenses square. elements = rt2.make_elements(singlet_sequence, 'square') # Create assembly object for ray tracing. assembly = rt2.Assembly.make(elements, ri.air) lamb = 850e-9 # Get paraxial focal length. f = train.get_effective_focal_length(lamb) stop_half_width = train_full.interfaces[1].radius/2**0.5 field_half_width = train_full.interfaces[-1].radius/2**0.5 traced_rays = []
import logging from otk import zemax, trains, sdb from otk.rt2 import rt2_scalar_qt as rt2 logging.getLogger('otk.rt2.qt').setLevel(logging.DEBUG) logging.basicConfig() train0 = zemax.read_train('US08934179-4.zmx') train1 = train0.crop_to_finite() sequence0 = trains.SingletSequence.from_train2(train1, 'max') sequence1 = sequence0 #.split(4)[1].split(1)[0] # Convert to rt2 Elements. elements = rt2.make_elements(sequence1, 'circle') # Create assembly object for ray tracing. assembly = rt2.Assembly.make(elements, sequence1.n_external) view_surface = sdb.IntersectionOp((assembly.surface, sdb.Plane((-1, 0, 0), 0)), assembly.surface).scale(1e3) with rt2.application(): viewer = rt2.view_assembly(assembly, surface=view_surface) viewer.max_steps = 1000