rayoptics.elem.elements module

Module for element modeling

class GraphicsHandle(polydata, tfrm, polytype, color)

Bases: tuple

color

RGBA for the polydata or None for default

polydata

poly data in local coordinates

polytype

‘polygon’ (for filled) or ‘polyline’

tfrm

global transformation for polydata

create_thinlens(power=0.0, indx=1.5, sd=None, **kwargs)[source]
create_mirror(c=0.0, r=None, cc=0.0, ec=None, power=None, profile=None, sd=None, **kwargs)[source]

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')[source]
create_lens(power=0.0, bending=0.0, th=None, sd=1.0, med=None, lens=None, **kwargs)[source]

Create a lens element chunk of sm, em, pt tree, and \(y-\overline{y}\) entry

Parameters:

kwargs

keyword arguments including:

  • idx: insertion point in the sequential model

  • t: the thickness following a chunk when inserting

  • lens: tuple of cv1, cv2, th, glass_name_catalog, sd where:

    • cv1: front curvature

    • cv2: rear curvature

    • th: lens thickness

    • glass_input: a str, e.g. ‘N-BK7, Schott’ or index (+V-number)

    • sd: lens semi-diameter

create_lens_from_dgm(prx=None, **kwargs)[source]

Use diagram points to create a lens.

Adds a \(y-\overline{y}\) component to the descriptor tuple. dgm = prx, dgm_pkg

prx = parax_model, node_idx, type_sel dgm_pkg = node_list, sys_data

sys_data = list([rndx, ‘transmit’|’reflect’])

achromat(power, Va, Vb)[source]

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)[source]
create_dummy_plane(sd=1.0, **kwargs)[source]
create_air_gap(t=0.0, **kwargs)[source]
create_from_file(filename, **kwargs)[source]
create_assembly_from_seq(opt_model, idx1, idx2, **kwargs)[source]
render_lens_shape(s1, profile1, s2, profile2, thi, extent, sd, is_flipped, hole_sd=None, apply_tfrm=True, flat1_pkg=None, flat2_pkg=None)[source]
render_surf_shape(srf, profile, extent, sd, is_flipped, hole_sd=None, flat_pkg=None)[source]
full_profile(profile, is_flipped, edge_extent, flat_id=None, hole_id=None, dir=1, steps=6)[source]

Produce a 2d segmented approximation to the profile.

In the case of a hole, 2 polyline segments are returned. Otherwise, a single polyline is returned (as a tuple of len=1)

Parameters:
  • profile – optical profile to be sampled

  • is_flipped – the flipped state of the profile

  • edge_extent – tuple with symmetric or asymetric bounds

  • flat_id – if not None, inside diameter of flat zone

  • hole_id – if not None, inside diameter of centered surface hole

  • dir – sampling direction, +1 for up, -1 for down

  • steps – number of profile curve samples

Returns:

a tuple of 2d coord lists. a tuple is returned even in the case of a single coord list

use_flat(do_flat, is_concave)[source]
compute_flat(ifc, sd, under_fract=0.05)[source]
encode_obj_reference(obj, obj_attr_str, attrs)[source]
sync_obj_reference(obj, obj_attr_str, obj_dict, alt_attr_value)[source]
class Part(*args, **kwargs)[source]

Bases: Protocol

Abstract base class for all types of elements.

label_format: ClassVar[str]
label: str
parent: Any
is_flipped: bool = False
ele_token: str
flip()[source]

Called by opt_model.flip when a Part is flipped.

abstract do_flip()[source]

Subclass action when it is flipped.

abstract sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
abstract sync_to_seq(seq_model: SequentialModel)[source]
abstract sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

abstract tree(**kwargs) Node[source]
abstract idx_list() List[int][source]
abstract reference_idx() int[source]
abstract reference_interface() Interface[source]
abstract profile_list() List[SurfaceProfile][source]
abstract gap_list() List[Gap][source]
abstract update_size() None[source]
abstract render_shape() List[GraphicsHandle][source]

return a polyline that is representative of the Part.

abstract render_handles(opt_model) Dict[str, GraphicsHandle][source]
abstract handle_actions() Dict[str, Any][source]
do_flip_with_part_list(part_list: List[Part], flip_pt_tfrm) None[source]

Flip a list of parts around a flip_pt.

class Element(sg_def=None, ele_def_pkg=None, tfrm=None, idx=0, idx2=1, sd=1.0, label=None)[source]

Bases: Part

Lens element domain model. Manage rendering and selection/editing.

An Element consists of 2 Surfaces, 1 Gap, and edge_extent information.

s1

first/origin Interface

s2

second/last Interface

gap

element thickness and material Gap

tfrm

global transform to element origin, (Rot3, trans3)

medium_name

the material filling the gap

flat1, flat2

semi-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’

handles

dict of graphical entities

actions

dict of actions associated with the graphical handles

clut = <rayoptics.util.rgbtable.RGBTable object>
label_format: ClassVar[str] = 'E{}'
serial_number = 0
default_ele_token = 'lens'
property sd

Semi-diameter

listobj_str()[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

tree(**kwargs)[source]

Build tree linking sequence to element model.

idx_list()[source]
reference_idx()[source]
reference_interface()[source]
profile_list()[source]
gap_list()[source]
get_power(nom_wvl='d')[source]
get_bending()[source]
set_bending(bending)[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
extent()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
handle_actions()[source]
class SurfaceInterface(ifc=None, ele_def_pkg=None, tfrm=None, idx=0, sd=1.0, z_dir=1.0, label=None)[source]

Bases: Part

label_format: ClassVar[str] = 'S{}'
serial_number = 0
default_ele_token = 'surface'
listobj_str()[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

tree(**kwargs)[source]
reference_interface()[source]
reference_idx()[source]
idx_list()[source]
profile_list()[source]
gap_list()[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
extent()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
handle_actions()[source]
class Mirror(ifc=None, ele_def_pkg=None, thi=None, label=None, **kwargs)[source]

Bases: SurfaceInterface

label_format: ClassVar[str] = 'M{}'
serial_number = 0
default_ele_token = 'mirror'
listobj_str()[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
get_thi()[source]
tree(**kwargs)[source]
substrate_offset()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
class CementedElement(ifc_list=None, ele_def_pkg=None, label=None)[source]

Bases: Part

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.

idxs

list of seq_model interface indices (depends on is_flipped)

ifcs

list of Interface

gaps

list of thickness and material Gap

tfrm

global transform to element origin, (Rot3, trans3)

medium_name

the material filling the gap

flats

semi-diameter of flat if ifc is concave, or None

handles

dict of graphical entities

actions

dict of actions associated with the graphical handles

clut = <rayoptics.util.rgbtable.RGBTable object>
label_format: ClassVar[str] = 'CE{}'
serial_number = 0
default_ele_token = 'cemented'
property sd

Semi-diameter

listobj_str()[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

tree(**kwargs)[source]
idx_list()[source]
reference_idx()[source]
reference_interface()[source]
profile_list()[source]
gap_list()[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
compute_inner_flat(idx, sd, k)[source]

compute flats, if needed, for the inner cemented surfaces.

Parameters:
  • idx – index of inner surface in profile list

  • sd – the semi-diameter of the cemented element

  • k – final, k-th, profile index

This function is needed to handle the cases where one of the outer surfaces has a flat and the inner surface would intersect this flat. All inner cemented surfaces are assumed to be spherical. See model US007277232_Example04P.roa See also cv_fisheye.roa

extent()[source]
render_shape()[source]

return a tuple of polylines of the lenses of the cemented element.

Flats on the outer surfaces of the cemented assembly are checked for intersections with the internal surfaces. The first outer surface is the zeroth interface; the other outer surface is interface k. In the case of the mangin assembly, the k-th surface is in the middle of the interface list.

render_as_surfs()[source]

return a tuple of polylines of the surfaces of the cemented element.

render_handles(opt_model)[source]
handle_actions()[source]
class ThinElement(ifc=None, ele_def_pkg=None, tfrm=None, idx=0, sd=None, label=None)[source]

Bases: Part

label_format: ClassVar[str] = 'TL{}'
serial_number = 0
default_ele_token = 'thin_lens'
tree(**kwargs)[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

reference_interface()[source]
reference_idx()[source]
profile_list()[source]
idx_list()[source]
gap_list()[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
handle_actions()[source]
class DummyInterface(ifc=None, ele_def_pkg=None, idx=0, sd=None, tfrm=None, label=None)[source]

Bases: Part

label_format: ClassVar[str] = 'D{}'
serial_number = 0
default_ele_token = 'dummy'
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

tree(**kwargs)[source]
reference_interface()[source]
reference_idx()[source]
interface_list()[source]
profile_list()[source]
idx_list()[source]
gap_list()[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
handle_actions()[source]
class Space(label=None, g=None, ele_def_pkg=None, idx=0, tfrm=None, z_dir=1, **kwargs)[source]

Bases: Part

label_format: ClassVar[str] = 'SP{}'
serial_number = 0
default_ele_token = 'space'
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

tree(**kwargs)[source]
reference_interface()[source]
reference_idx()[source]
profile_list()[source]
idx_list()[source]
gap_list()[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
extent()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
apply_decenter_to_tfrm(decenter)[source]

Modify the tfrm using any decenters following the reference ifc.

handle_actions()[source]
class AirGap(g=None, ele_def_pkg=None, label=None, **kwargs)[source]

Bases: Space

label_format: ClassVar[str] = 'AG{}'
serial_number = 0
default_ele_token = 'air'
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
tree(**kwargs)[source]
render_handles(opt_model)[source]
class Assembly(part_list, idx=0, tfrm=None, label=None)[source]

Bases: Part

label_format: ClassVar[str] = 'ASM{}'
serial_number = 0
default_ele_token = 'asm'
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
sync_to_ele_def(seq_model, ele_def)[source]

Update idx_list and gap_list according to ele_def.

ele_def: (ele_type, idx_list, gap_list)

tree(**kwargs)[source]
idx_list()[source]
reference_idx()[source]
reference_interface()[source]
profile_list()[source]
gap_list()[source]
do_flip()[source]

Subclass action when it is flipped.

update_size()[source]
render_shape()[source]

return a polyline that is representative of the Part.

render_handles(opt_model)[source]
handle_actions()[source]
class ElementModel(opt_model, **kwargs)[source]

Bases: object

Maintain the element based representation of the optical model

opt_model

the OpticalModel

elements

list of element type things

reset()[source]
sync_to_restore(opt_model)[source]
reset_serial_numbers()[source]
save_serial_numbers() dict[source]
restore_serial_numbers(serial_numbers)[source]
update_model(**kwargs)[source]

dynamically build element list from part_tree.

apply_scale_factor(scale_factor)[source]

Apply scale factor by resyncing with the sequential model.

sync_to_seq(seq_model)[source]

Update element positions and ref_idx using the sequential model.

sequence_elements()[source]

Sort elements in order of reference interfaces in seq_model

add_element(e: Part)[source]
remove_element(e: Part)[source]
remove_node(e_node)[source]
get_num_elements()[source]
list_model(tag: str = '#element#assembly#dummyifc')[source]
list_elements()[source]
element_type(i)[source]
build_ele_sg_lists()[source]
list_ele_sg(part_tree, seq_model)[source]
build_ele_def(e, seq_model)[source]

Package defining element info, including effect of flipping.