rayoptics.optical.opticalmodel module

Top level model classes

class SystemSpec(opt_model, **kwargs)[source]

Bases: object

Container for units and other system level constants

title

a short description of the model

Type:

str

initials

user initials or other id

Type:

str

temperature

model temperature in degrees Celsius

Type:

float

pressure

model pressure in mm/Hg

Type:

float

listobj_str()[source]
property dimensions

the model linear units (str).

nm_to_sys_units(nm)[source]

convert nm to system units

Parameters:

nm (float) – value in nm

Returns:

value converted to system units

Return type:

float

class OpticalModel(radius_mode=False, specsheet=None, **kwargs)[source]

Bases: object

Top level container for optical model.

The OpticalModel serves as a top level container of model properties. Key aspects are built-in element and surface based repesentations of the optical surfaces. A sequential optical model is a sequence of surfaces and gaps. Additionally, it includes optical usage information to specify the aperture, field of view, spectrum and focus.

ro_version

current version of rayoptics

radius_mode

if True output radius, else output curvature

specsheet

SpecSheet

system_spec

SystemSpec

seq_model

SequentialModel

optical_spec

OpticalSpecs

parax_model

ParaxialModel

ele_model

ElementModel

map_submodels(**kwargs)[source]

Setup machinery for model mapping api.

This function performs two tasks:

  • populating the submodel dict either with attributes or creating a new instance as needed.

  • populate a submodel alias dict with short versions of the wordy defining names

The first task must handle these use cases:

  • opt_model populated by importing a .roa file

  • an opt_model created interactively

  • an opt_model initialized by a lens file importer

name()[source]
reset()[source]
listobj_str()[source]
set_from_specsheet(specsheet=None)[source]
save_model(file_name, version=None)[source]

Save the optical_model in a ray-optics JSON file.

Parameters:
  • file_name – str or Path

  • version – optional override for rayoptics version number

sync_to_restore()[source]
update_model(**kwargs)[source]

Model and its constituents are updated.

Parameters:

kwargs

possible keyword arguments including:

  • build:

    • ’rebuild’: rebuild the model “from scratch”, e.g number of nodes changes

    • ’update’: number of nodes unchanged, just the parameters

  • src_model: model that originated the modification

update_optical_properties(**kwargs)[source]

Compute first order and other optical properties.

nm_to_sys_units(nm)[source]

convert nm to system units

Parameters:

nm (float) – value in nm

Returns:

value converted to system units

Return type:

float

add_part(factory_fct, *args, **kwargs)[source]

Use a factory_fct to create a new part and insert into optical model.

add_lens(**kwargs)[source]

Add a lens into the optical model

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

      refractive index or index/V-number pair

    • sd: lens semi-diameter

add_mirror(**kwargs)[source]
add_thinlens(**kwargs)[source]
add_dummy_plane(**kwargs)[source]
add_from_file(filename, **kwargs)[source]
add_assembly_from_seq(idx1, idx2, **kwargs)[source]

Create an Assembly from the elements in the sequence range.

rebuild_from_seq()[source]

Rebuild ele_model and part_tree from seq_model.

When in doubt about whether there is a problem with bad data in an OpticalModel, this function can be used to rebuild everything from the sequential model.

flip(*args, **kwargs)[source]

Flip a Part or an Interface range in the optical model.

The flip operation supports several different ways of specifying what is to be flipped.

Args:

  • None: This flips the model from ifc 1 to ifc image-1

  • idx1, idx2: This flips the model between interfaces idx1 and idx2. Flipping from object to image is disallowed.

  • part: This flips the corresponding part in the model

  • list: This flips a list of parts in the model

insert_ifc_gp_ele(*descriptor, **kwargs)[source]

insert interfaces and gaps into seq_model and eles into ele_model

Parameters:
  • descriptor – a tuple of additions for the sequential, element and part tree models

  • kwargs – keyword arguments including idx: insertion point in the sequential model insert: if True, insert the chunk, otherwise replace it t: the thickness following a chunk when inserting

remove_ifc_gp_ele(*descriptor, **kwargs)[source]

remove interfaces and gaps from seq_model and eles from ele_model

remove_node(e_node)[source]