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, and pt tree

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

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]
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.

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

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
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 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 cemented element.

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(s1, s2, g, 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
label: str
property sd

Semi-diameter

sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
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_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 cemented element.

render_handles(opt_model)[source]
handle_actions()[source]
parent: Any
class Mirror(ifc, tfrm=None, idx=0, sd=1.0, thi=None, z_dir=1.0, label=None)[source]

Bases: Part

label_format: ClassVar[str] = 'M{}'
serial_number = 0
label: str
get_thi()[source]
listobj_str()[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
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]
substrate_offset()[source]
render_shape()[source]

return a polyline that is representative of the cemented element.

render_handles(opt_model)[source]
handle_actions()[source]
parent: Any
class CementedElement(ifc_list, 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
label: str
property sd

Semi-diameter

sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
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)[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

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

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

return a polyline that is representative of the cemented element.

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

Bases: Part

label_format: ClassVar[str] = 'TL{}'
serial_number = 0
label: str
tree(**kwargs)[source]
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[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]
render_shape()[source]

return a polyline that is representative of the cemented element.

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

Bases: Part

label_format: ClassVar[str] = 'D{}'
serial_number = 0
label: str
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
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 cemented element.

render_handles(opt_model)[source]
handle_actions()[source]
parent: Any
class AirGap(g, idx=0, tfrm=None, label=None, z_dir=1, **kwargs)[source]

Bases: Part

label_format: ClassVar[str] = 'AG{}'
serial_number = 0
label: str
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
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]
render_shape()[source]

return a polyline that is representative of the cemented element.

render_handles(opt_model)[source]
handle_actions()[source]
parent: Any
class Assembly(part_list, idx=0, tfrm=None, label=None)[source]

Bases: Part

label_format: ClassVar[str] = 'ASM{}'
serial_number = 0
label: str
sync_to_restore(ele_model, surfs, gaps, tfrms, profile_dict, parts_dict)[source]
sync_to_seq(seq_model)[source]
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 cemented element.

render_handles(opt_model)[source]
handle_actions()[source]
parent: Any
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]
airgaps_from_sequence(seq_model, tfrms)[source]

add airgaps and dummy interfaces to an older version model

add_dummy_interface_at_image(seq_model, tfrms)[source]
update_model(**kwargs)[source]
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

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