-
Dear Micheal Hayford, Is there a possibility to easily save an optical model as a sequential model and import it into another optical model? Kind regards, Joost ter Haar |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hello @Joostth98, Issue #128 - Combining files exampleThis example uses the add_from_file method of the OpticalModel to insert the lens in the file into the optical model. Any file type that can be imported by ray-optics (e.g. .zmx, .seq, .roa) can be used. The example is in 3 parts:
The lens prescriptions are from the book Telescopes, Eyepieces and Astrographs. %matplotlib inline isdark = False from rayoptics.environment import * Create an Apochromatic tripletopm = OpticalModel()
opm['system_spec'].title = 'Apo-Triplet, 150mm, f/8, Fig 6.22'
sm = opm['seq_model']
osp = opm['optical_spec']
pm = opm['parax_model']
em = opm['ele_model']
pt = opm['part_tree'] osp['pupil'] = PupilSpec(osp, key=['object', 'pupil'], value=150.0)
osp['fov'] = FieldSpec(osp, key=['object', 'angle'], value=0.35, flds=[0., 1.], is_relative=True)
osp['wvls'] = WvlSpec([("F", 0.5), ('d', 1.0), ('C', 0.5)], ref_wl=2) opm.radius_mode = True
sm.do_apertures = False
sm.gaps[0].thi=1e10
sm.add_surface([591.0786, 12, 'N-BK7', 'Schott', 80])
sm.add_surface([292.7895, 2, '', '', 80])
sm.add_surface([286.5319, 25, 'S-FPL53', 'Ohara', 80])
sm.add_surface([-469.3911, 2, '', '', 80])
sm.add_surface([-461.4804, 12, 'N-SK5', 'Schott', 80])
sm.add_surface([-1106.461, 1123.698, '', '', 80]) opm.update_model() sm.gaps[-1].thi += pm.thi_ht_solve(pm.ax, -1, 0.)
opm.update_model() sm.list_model()
pm.list_model()
layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, is_dark=isdark).plot() opm.save_model('Apo-Triplet.roa') Define an Orthoscopic eyepiece, 10mmopm = OpticalModel()
sm = opm['seq_model']
osp = opm['optical_spec']
pm = opm['parax_model']
em = opm['ele_model']
pt = opm['part_tree']
ar = opm['analysis_results'] osp['pupil'] = PupilSpec(osp, key=['object', 'pupil'], value=1.0)
osp['fov'] = FieldSpec(osp, key=['object', 'angle'], value=22.5, flds=[0., 0.707, 1.], is_relative=True)
osp['wvls'] = WvlSpec([('F', 0.5), ('d', 1.0), ('C', 0.5)], ref_wl=1) opm.radius_mode = True
sm.gaps[0].thi=1e10
sm.add_surface([0, 7.244451])
sm.set_stop()
sm.add_surface([0, 3., 'N-SK16', 'Schott'])
sm.add_surface([-11.92452, .25])
sm.add_surface([11.29189, 4, 'N-SK16,Schott'])
sm.add_surface([-11.92452, 1, 'N-SF1,Schott'])
sm.add_surface([11.92452, 3, 'N-SK16,Schott'])
sm.add_surface([-60.94443, 4.864743]) opm.update_model() sm.list_model()
listobj(osp)
pm.first_order_data()
pm.list_model()
layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, is_dark=isdark).plot() opm.save_model('orthoscopic eyepiece') Combine Objective and Eyepieceopm = OpticalModel()
sm = opm['seq_model']
osp = opm['optical_spec']
pm = opm['parax_model']
em = opm['ele_model']
pt = opm['part_tree']
ar = opm['analysis_results'] osp['pupil'] = PupilSpec(osp, key=['object', 'pupil'], value=100.0)
osp['fov'] = FieldSpec(osp, key=['object', 'angle'], value=0.35, flds=[0., 0.707, 1.], is_relative=True)
osp['wvls'] = WvlSpec([('F', 0.5), ('d', 1.0), ('C', 0.5)], ref_wl=1) opm.radius_mode = True
sm.gaps[0].thi=1e10 Restore the objective using add_from_file()First restore the objective and set the paraxial focal distance opm.add_from_file('Apo-Triplet.roa', t=1173.91) sm.gaps[-1].thi += pm.thi_ht_solve(pm.ax, -1, 0.)
opm.update_model() Restore the eyepieceopm.add_from_file('orthoscopic eyepiece.roa', t=7.24445) opm.update_model() sm.list_model()
Flip the eyepiece so that the pupil follows the eyepieceSet the final distance to be at the paraxial exit pupil opm.flip(8,13)
sm.gaps[7].thi = 4.864743
sm.gaps[-1].thi += pm.thi_ht_solve(pm.pr, -1, 0.)
opm.update_model() sm.list_model()
listobj(osp)
pm.first_order_data()
pm.list_model()
layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, is_dark=isdark).plot() |
Beta Was this translation helpful? Give feedback.
Hello @Joostth98,
Thank you for posting this question. I've put together an example below to show how to save and combine lens models in ray-optics. Please let me know if you have further questions.
Thank you!
Mike Hayford
Issue #128 - Combining files example
This example uses the add_from_file method of the OpticalModel to insert the lens in the file into the optical model. Any file type that can be imported by ray-optics (e.g. .zmx, .seq, .roa) can be used.
The example is in 3 parts:
The lens prescription…