rayoptics.seq.sequential module

Manager class for a sequential optical model

class SequentialModel(opt_model, do_init=True, **kwargs)[source]

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

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 thin lens or 2 point HOE.

The Gap class maintains a simple separation (z translation) and the medium filling the gap. More complex coordinate transformations are handled through the Interface API.

opt_model

parent optical model

ifcs

list of Interface

gaps

list of Gap

lcl_tfrms

forward transform, interface to interface

rndx

a list with refractive indices for all wvls

z_dir

-1 if gap follows an odd number of reflections, otherwise +1

gbl_tfrms

global coordinates of each interface wrt the 1st interface

stop_surface

index of stop interface

Type:

int

cur_surface

insertion index for next interface

Type:

int

reset()[source]
get_num_surfaces()[source]
path(wl=None, start=None, stop=None, step=1)[source]

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)[source]

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)

seq_str()[source]

return a character encoding of ifcs and gaps

calc_ref_indices_for_spectrum(wvls)[source]

returns a list with refractive indices for all wvls

Parameters:

wvls – list of wavelengths in nm

central_wavelength()[source]

returns the central wavelength in nm of the model’s WvlSpec

index_for_wavelength(wvl)[source]

returns index into rndx array for wavelength wvl in nm

central_rndx(i)[source]

returns the central refractive index of the model’s WvlSpec

get_surface_and_gap(srf=None)[source]
set_cur_surface(s)[source]
set_stop()[source]

sets the stop surface to the current surface

insert(ifc, gap, z_dir=1, idx=None)[source]

insert ifc and gap after cur_surface in seq_model lists

remove(*args, prev=False)[source]

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. The prev argument, if True, removes the gap preceding the interface. The default behavior is to remove the following gap.

replace_node_with_seq(e_node, seq, **kwargs)[source]

Replace a sub-sequence of e_node with seq.

remove_node(e_node)[source]

Remove the ifcs/gaps connected to e_node.

Return the first and last ifc indices.

scan_for_reflections(start=0)[source]

Rectify any inconsistent z_dir setting due to insertions.

add_surface(surf_data, **kwargs)[source]

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 (numeric)

  • refractive_index only -> constant index model

  • glass_name, catalog_name as 1 or 2 strings

  • an instance with a rindex attribute

  • air, str -> om.Air

  • blank -> defaults to om.Air

  • ‘REFL’ -> set interact_mode to ‘reflect’

The semi-diameter entry is optional. It may also be entered using the sd keyword argument.

sync_to_restore(opt_model)[source]
update_model(**kwargs)[source]
update_optical_properties(**kwargs)[source]
apply_scale_factor(scale_factor)[source]
flip(idx1: int, idx2: int) None[source]

Flip interfaces and gaps from idx1 thru idx2.

set_from_specsheet(specsheet)[source]
insert_surface_and_gap()[source]
update_reflections(start)[source]

update interfaces and gaps following insertion of a mirror

get_rndx_and_imode()[source]

get list of signed refractive index and interact mode for sequence.

overall_length(os_idx=1, is_idx=-1)[source]

Sum gap thicknesses from os_idx to is_idx

The default arguments return the thickness sum between the 1st and last surfaces.

To include the image surface, is_idx=len(sm.gaps)

Parameters:
  • os_idx – starting gap index

  • is_idx – final gap index

Returns:

float, overal length of gap range

Return type:

oal

total_track()[source]

Total track length, distance from object to image.

surface_label_list()[source]

list of surface labels or surface number, if no label

list_model(path=None)[source]
list_model_old()[source]
list_gaps()[source]
list_surfaces()[source]
list_surface_and_gap(ifc, gp=None)[source]

Returns cvr, thi, med, imode, sd for input ifc and gap.

list_decenters(full=False)[source]

List decenter data and gap separations.

Parameters:

full – lists all values if True, else only y offset and alpha tilt

list_sg()[source]

List decenter data and gap separations.

list_elements()[source]
list_sg_ele(part_tree)[source]
listobj_str()[source]
trace_fan(fct, fi, xy, num_rays=21, **kwargs)[source]

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)[source]

fct is applied to the raw grid and returned as a grid

trace_wavefront(fld, wvl, foc, num_rays=32)[source]
set_clear_apertures_paraxial()[source]
set_clear_apertures()[source]
trace(pt0, dir0, wvl, **kwargs)[source]
compute_global_coords(glo=1)[source]

Return global surface coordinates (rot, t) wrt surface glo.

compute_local_transforms(seq=None, step=1)[source]

Return forward surface coordinates (r.T, t) for each interface.

list_lcl_tfrms(*args)[source]
list_gbl_tfrms(*args)[source]
list_tfrms(tfrms, sel: str = 'r+t', *args)[source]
find_matching_ifcs()[source]
gen_sequence(surf_data_list, **kwargs)[source]

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)[source]

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 (numeric)

  • refractive_index only -> constant index model

  • glass_name, catalog_name as 1 or 2 strings

  • an instance with a rindex attribute

  • air, str -> om.Air

  • blank -> defaults to om.Air

  • ‘REFL’ -> set interact_mode to ‘reflect’

The semi-diameter entry is optional. It may also be entered using the sd keyword argument.