rayoptics.raytr.opticalspec module

Container class for optical usage information

class OpticalSpecs(opt_model, specsheet=None, **kwargs)[source]

Bases: object

Container class for optical usage information

Contains optical usage information to specify the aperture, field of view, spectrum and focal position. These can be accessed via the mapping interface:

It also maintains a repository of paraxial data.

do_aiming

if True, iterate chief rays to stop center, else entrance pupil

do_aiming_default = True
listobj_str()[source]
property spectral_region
property pupil
property field_of_view
property defocus
set_from_list(dl)[source]
set_from_specsheet(ss)[source]
sync_to_parax(parax_model)[source]

Use the parax_model database to update the optical specs.

conjugate_type(space: str = 'object') str[source]

Returns if object or image space is finite or infinite conjugates.

is_afocal() bool[source]

Returns True if the system is afocal.

setup_specs_using_dgms(pm)[source]

Use the parax_model database to update the pupil specs.

sync_to_restore(opt_model)[source]
update_model(**kwargs)[source]
update_optical_properties(**kwargs)[source]
apply_scale_factor(scale_factor)[source]
ray_start_from_osp(pupil, fld, pupil_type: str)[source]

turn pupil and field specs into ray start specification.

Parameters:
  • pupil – aperture coordinates of ray

  • fld – instance of Field

  • pupil_type – controls how pupil data is interpreted - ‘rel pupil’: relative pupil coordinates - ‘aim pt’: aim point on pupil plane - ‘aim dir’: aim direction in object space

lookup_fld_wvl_focus(fi, wl=None, fr=0.0)[source]

returns field, wavelength and defocus data

Parameters:
  • fi (int) – index into the field_of_view list of Fields

  • wl (int) – index into the spectral_region list of wavelengths

  • fr (float) – focus range parameter, -1.0 to 1.0

Returns:

(fld, wvl, foc)

  • fld - Field instance for field_of_view[fi]

  • wvl - wavelength in nm

  • foc - focus shift from image interface

obj_coords(fld)[source]
list_first_order_data()[source]
list_parax_trace(**kwargs)[source]
class WvlSpec(wlwts=[('d', 1.0)], ref_wl=0, do_init=True, **kwargs)[source]

Bases: object

Class defining a spectral region

A spectral region is a list of wavelengths (in nm) and corresponding weights. The central wavelength of the spectral region is central_wvl. The index into the wavelength list for central_wvl is reference_wvl.

listobj_str()[source]
property central_wvl
set_from_list(wlwts)[source]
sync_to_restore(optical_spec)[source]
set_from_specsheet(ss)[source]
update_model(**kwargs)[source]
apply_scale_factor(scale_factor)[source]
add(wl, wt)[source]
sort_spectrum()[source]
calc_colors()[source]
class PupilSpec(parent, key=('object', 'epd'), value=1.0)[source]

Bases: object

Aperture specification

key

‘object’|’image’, ‘epd’|’NA’|’f/#’

value

size of the pupil

pupil_rays

list of relative pupil coordinates for pupil limiting rays

ray_labels

list of string labels for pupil_rays

‘pupil’ is a deprecated literal pupil_value_type; use ‘epd’ instead.

default_pupil_rays = [[0.0, 0.0], [1.0, 0.0], [-1.0, 0.0], [0.0, 1.0], [0.0, -1.0]]
default_ray_labels = ['00', '+X', '-X', '+Y', '-Y']
listobj_str()[source]
property key

(‘object’|’image’, ‘epd’|’NA’|’f/#’)

set_key_value(key, value)[source]

Set aperture keys and value for the pupil specification.

sync_to_parax(parax_model)[source]

Use the parax_model database to update the pupil specs.

derive_parax_params()[source]

return pupil spec as paraxial height or slope value.

get_aperture_from_slope(slope, n=1)[source]
sync_to_restore(optical_spec)[source]
set_from_specsheet(ss)[source]
get_input_for_specsheet()[source]
update_model(**kwargs)[source]
apply_scale_factor(scale_factor)[source]
mutate_pupil_type(ape_key)[source]
class FieldSpec(parent, key=('object', 'angle'), value=0, flds=None, index_labels=None, is_relative=False, is_wide_angle=False, do_init=True, **kwargs)[source]

Bases: object

Field of view specification

key

‘object’|’image’, ‘height’|’angle’

value

maximum field, per the key

fields

list of Field instances

is_relative

if True, fields are relative to max field

is_wide_angle

if True, aim at real entrance pupil

listobj_str()[source]
property key

(‘object’|’image’, ‘height’|’angle’)

property value
set_key_value(key, value)[source]

Set field keys and value for the fov specification.

sync_to_parax(parax_model)[source]

Use the parax_model database to update the field specs.

derive_parax_params()[source]

return field spec as paraxial height or slope value.

sync_to_restore(optical_spec)[source]
set_from_list(flds)[source]
set_from_specsheet(ss)[source]
get_input_for_specsheet()[source]
check_is_wide_angle(angle_threshold=45.0) bool[source]

Checks for object angles greater than the threshold.

update_model(**kwargs)[source]
apply_scale_factor(scale_factor)[source]
mutate_field_type(fld_key)[source]
obj_coords(fld)[source]

Return a pt, direction pair characterizing fld.

If a field point is defined in image space, the paraxial object space data is used to calculate the field coordinates.

max_field()[source]

calculates the maximum field of view

Returns:

magnitude of maximum field, maximum Field instance

clear_vignetting()[source]

Reset the vignetting to 0 for all fields.

class Field(x: float = 0.0, y: float = 0.0, wt: float = 1.0, fov=None, max_field=None)[source]

Bases: object

a single field point, chief ray pkg and pupil limits

The Field class manages several types of data:

  • the field coordinates, unscaled and fractional

  • aim info for tracing through the stop surface

  • the vignetting factors for the pupil definition

  • pkgs for the chief ray and reference sphere

The Field can have a reference to a fov/FieldSpec (recommended!) which is used to support the fractional and value interfaces simultaneously. If no fov is given, a max_field may be specified, with the default being unit field size.

vux

+x vignetting factor

vuy

+y vignetting factor

vlx

-x vignetting factor

vly

-y vignetting factor

wt

field weight

aim_info

x, y chief ray coords on the paraxial entrance pupil plane, or z_enp for wide angle fovs

chief_ray

ray package for the ray from the field point throught the center of the aperture stop, traced in the central wavelength

ref_sphere

a tuple containing (image_pt, ref_dir, ref_sphere_radius)

fov

FieldSpec to be used as reference or None

property x: float

the x field value.

property y: float

the y field value.

property xv: float

the unscaled x field value.

property yv: float

the unscaled y field value.

property xf: float

the fractional x field value.

property yf: float

the fractional y field value.

property max_field: float

the maximum field value used for the fractional field calculation.

property is_relative

if True, x and y are normalized by max_field, else they are unscaled.

listobj_str(format='xy')[source]
update()[source]
apply_scale_factor(scale_factor: float)[source]
vignetting_bbox(pupil_spec: PupilSpec, oversize=1.02)[source]

returns a bbox of the vignetted pupil ray extents.

clear_vignetting()[source]

Resets vignetting values to 0.

apply_vignetting(pupil)[source]
class FocusRange(focus_shift=0.0, defocus_range=0.0)[source]

Bases: object

Focus range specification

focus_shift

focus shift (z displacement) from nominal image interface

defocus_range

+/- half the total focal range, from the focus_shift position

listobj_str()[source]
set_from_specsheet(ss)[source]
update()[source]
apply_scale_factor(scale_factor)[source]
get_focus(fr=0.0)[source]

return focus position for input focus range parameter

Parameters:

fr (float) – focus range parameter, -1.0 to 1.0

Returns:

focus position for input focus range parameter