Replies: 1 comment
|
Hello @khoroshyy, Start your file with: When you then create a lens layout and mouse over the figure, you get icons in the upper left corner, including one for a zoom box. If this environment isn't available to you, you can manipulate the figure bounding box through the InteractiveFigure api. Here is a notebook to demonstrate the options. Zoom example - Telescope with reducerUse interactive matplotlib figures# use widget to enable interactive figures.
%matplotlib widgetfrom rayoptics.environment import *isdark = Falseopm = OpticalModel()
opm['system_spec'].title = 'RC w/0.75x reducer, 200mm, f/8, Fig 14.11'
sm = opm['seq_model']
osp = opm['optical_spec']
pm = opm['parax_model']
em = opm['ele_model']
pt = opm['part_tree']
### Define first order aperture and field for system
osp['pupil'] = PupilSpec(osp, key=['object', 'epd'], value=200.0)
osp['fov'] = FieldSpec(osp, key=['object', 'angle'], value=0.75, flds=[0., .707, 1.], is_relative=True)
osp['wvls'] = WvlSpec([('F', 0.5), ('d', 1.0), ('C', 0.5)], ref_wl=1)
### Define interface and gap data for the sequential model
opm.radius_mode = True
sm.do_apertures = False
sm.gaps[0].thi=1e10
sm.add_surface([-1200, -395.4545, 'REFL', '', 100.055])
sm.ifcs[sm.cur_surface].profile = Conic(r=-1200, cc=-1.146871)
sm.add_surface([-654.5455, 395.4545, 'REFL', '', 78.83/2])
sm.ifcs[sm.cur_surface].profile = Conic(r=-654.5455, cc=-6.606556)
sm.add_surface([0, 7.968605], sd=30)
sm.ifcs[sm.cur_surface].interact_mode = 'dummy'
sm.add_surface([44.70335, 7, 'N-BK7', 'Schott', 23])
sm.add_surface([58.1758, 6, 'F2', 'Schott', 23])
sm.add_surface([38.91634, 5.316244, '', '', 23])
sm.add_surface([99.03769, 7, 'N-BK7', 'Schott', 23])
sm.add_surface([234.9394, 80, '', '', 23])
### Update the model
opm.update_model()
## add a hole to the primary mirror
M1 = pt.obj_by_name('M1')
M1.hole_sd = 30.0
opm.update_model()
## create assemblies for the OTA and the reducer
opm.add_assembly_from_seq(1, 3, label='R-C Telescope')
opm.add_assembly_from_seq(4, 8, label='Reducer')
opm.update_model()
## set the image at the paraxial focus
pimd = -pm.ax[-2][mc.ht]/pm.ax[-1][mc.slp]
sm.gaps[-1].thi = pimd
opm.update_model()
set_vignetting(opm)layout_plt = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, is_dark=False).plot()Zooming by setting the view_bboxThis is the brute force way to zoom into the model. The view_bbox coordinates are expressed in model global coordinates. There are no rotations in this exmple. The element semi-diameters can be obtained using sm.list_model(). The surface interface global coordinates can be obtained using list_gbl_tfrms() sm.list_model()sm.list_gbl_tfrms('t')The bounding box is set on the InteractiveLayoutThe bounding box is defined with the lower left and upper right corner coordinates being specified layout_plt.set_view_bbox([[0, -25], [35, 25]])
layout_plt.plot()You can also set the bounding box in the Figure constructor.layout_plt1 = plt.figure(FigureClass=InteractiveLayout, opt_model=opm, is_dark=False, view_bbox=[[0, -25], [35, 25]]).plot()If you have any suggestions to make this easier to do in a scripting environment, like specifying a range of surfaces, please let me know. Thanks Mike Hayford |




Uh oh!
There was an error while loading. Please reload this page.
Hi.
I am plotting a system (compound microscope), and want to zoom in onto some parts.
I tried plt.xlim plt.ylim but they have no effect.
Any idea how I can do it?
Thanks.
Petro.
All reactions