AbstractSequentialSystem#

class optika.systems.AbstractSequentialSystem[source]#

Bases: AbstractSystem

An interface describing a sequential optical system.

A sequential optical system is a system where the ordering of the optical surfaces is known in advance.

Attributes

axis_surface

The name of the logical axis representing the sequence of surfaces.

field_max

The upper right corner of this optical system's field of view.

field_min

The lower left corner of this optical system's field of view.

field_stop

The field stop surface.

grid_input

The input grid to sample with rays.

index_field_stop

The index of the field stop in surfaces_all.

index_pupil_stop

The index of the pupil stop in surfaces_all.

kwargs_plot

Extra keyword arguments that will be used in the call to named_arrays.plt.plot() within the plot() method.

object

The external object being imaged or illuminated by this system.

object_is_at_infinity

A boolean flag indicating if the object is at infinity.

pupil_max

The upper right corner of this optical system's entrance pupil in physical units.

pupil_min

The lower left corner of this optical system's entrance pupil in physical units.

pupil_stop

The pupil stop surface.

rayfunction_default

Computes the rays in local coordinates at the last surface in the system as a function of input wavelength and position using grid_input.

rayfunction_stops

A rayfunction defined on the input surface of the optical system, which is designed to exactly strike the borders of both the field stop and the pupil stop.

sensor

The imaging sensor that measures the light captured by this system.

shape

The array shape of this object.

surfaces

A sequence of surfaces representing this optical system.

surfaces_all

Concatenate object with surfaces into a single list of surfaces.

transformation

the coordinate transformation between the global coordinate system and this object's local coordinate system

Methods

__init__()

image(scene[, wavelength, pupil, ...])

Forward model of the optical system.

plot([ax, transformation, components, ...])

Plot the surfaces of the system and the default raytrace.

rayfunction([intensity, wavelength, field, ...])

Given the wavelength, field position, and pupil position of some input rays, trace those rays through the system and return the resulting rays in local coordinates at the last surface.

raytrace([intensity, wavelength, field, ...])

Given the wavelength, field position, and pupil position of some input rays, trace those rays through the system and return the result in global coordinates, including all intermediate rays.

spot_diagram([figsize, s, cmap])

Create a spot diagram of the rays at each field point to inspect the performance of this optical system.

to_dxf(file, unit[, transformation])

to_string([prefix])

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Inheritance Diagram

Inheritance diagram of optika.systems.AbstractSequentialSystem
image(scene, wavelength=None, pupil=None, axis_wavelength=None, axis_field=None, axis_pupil=None, noise=True, **kwargs)[source]#

Forward model of the optical system. Maps the given spectral radiance of a scene to detector counts.

Parameters:
  • scene (FunctionArray[SpectralPositionalVectorArray, AbstractScalar]) – The spectral radiance of the scene as a function of wavelength and field position. The inputs must be cell vertices.

  • wavelength (None | AbstractScalar) – The vertices of the final wavelength grid on the image plane. If None (the default), scene.inputs.wavelength is used.

  • pupil (None | AbstractCartesian2dVectorArray) – The vertices of the pupil grid in either normalized or physical coordinates. If None, self.grid_input.pupil is used.

  • axis_wavelength (None | str) – The logical axis corresponding to changing wavelength coordinate. If None, set(scene.inputs.wavelength.shape) - set(self.shape), should have only one element.

  • axis_field (None | tuple[str, str]) – The two logical axes corresponding to changing field coordinate. If None, set(scene.inputs.position.shape) - set(self.shape) - {axis_wavelength}, should have exactly two elements.

  • axis_pupil (None | tuple[str, str]) – The two logical axes corresponding to changing pupil coordinate. If None, set(pupil.shape) - set(self.shape) - {axis_wavelength,} - set(axis_field), should have exactly two elements.

  • noise (bool) – Whether to add noise to the result.

  • kwargs – Additional keyword arguments used by subclass implementations of this method.

Return type:

FunctionArray[SpectralPositionalVectorArray, AbstractScalar]

plot(ax=None, transformation=None, components=None, plot_rays=True, plot_rays_vignetted=False, kwargs_rays=None, **kwargs)[source]#

Plot the surfaces of the system and the default raytrace.

Parameters:
  • ax (None | Axes | ScalarArray[ndarray[tuple[Any, ...], dtype[_ScalarT]]]) – The matplotlib axes on which to plot the system

  • transformation (None | AbstractTransformation) – Any additional transformation to apply to the system before plotting.

  • components (None | tuple[str, ...]) – The vector components to plot if ax is 2-dimensional.

  • plot_rays (bool) – Boolean flag indicating whether to plot the rays.

  • plot_rays_vignetted (bool) – Boolean flag indicating whether to plot the vignetted rays.

  • kwargs_rays (None | dict[str, Any]) – Any additional keyword arguments to use when plotting the rays.

  • kwargs – Any additional keyword arguments to use when plotting the surfaces.

Return type:

AbstractScalar | dict[str, AbstractScalar]

rayfunction(intensity=None, wavelength=None, field=None, pupil=None, normalized_field=True, normalized_pupil=True)[source]#

Given the wavelength, field position, and pupil position of some input rays, trace those rays through the system and return the resulting rays in local coordinates at the last surface.

Parameters:
  • intensity (None | float | Quantity | AbstractScalar) – The energy density of the input rays.

  • wavelength (None | Quantity | AbstractScalar) – The wavelengths of the input rays. If None (the default), self.grid_input.wavelength will be used.

  • field (None | AbstractCartesian2dVectorArray) – The field positions of the input rays, in either normalized or physical units. If None (the default), self.grid_input.field will be used.

  • pupil (None | AbstractCartesian2dVectorArray) – The pupil positions of the input rays, in either normalized or physical units. If None (the default), self.grid_input.pupil will be used.

  • normalized_field (bool) – A boolean flag indicating whether the field parameter is given in normalized or physical units.

  • normalized_pupil (bool) – A boolean flag indicating whether the pupil parameter is given in normalized or physical units.

Return type:

RayFunctionArray

See also

raytrace

Similar to rayfunction except it computes all the intermediate rays, and it returns results in global coordinates.

raytrace(intensity=None, wavelength=None, field=None, pupil=None, axis=None, normalized_field=True, normalized_pupil=True)[source]#

Given the wavelength, field position, and pupil position of some input rays, trace those rays through the system and return the result in global coordinates, including all intermediate rays.

Parameters:
  • intensity (None | float | Quantity | AbstractScalar) – The energy density of the input rays.

  • wavelength (None | Quantity | AbstractScalar) – The wavelengths of the input rays. If None (the default), self.grid_input.wavelength will be used.

  • field (None | AbstractCartesian2dVectorArray) – The field positions of the input rays, in either normalized or physical units. If None (the default), self.grid_input.field will be used.

  • pupil (None | AbstractCartesian2dVectorArray) – The pupil positions of the input rays, in either normalized or physical units. If None (the default), self.grid_input.pupil will be used.

  • axis (None | str) – The axis along which the rays are accumulated. If None (the default), axis_surface will be used.

  • normalized_field (bool) – A boolean flag indicating whether the field parameter is given in normalized or physical units.

  • normalized_pupil (bool) – A boolean flag indicating whether the pupil parameter is given in normalized or physical units.

Return type:

RayFunctionArray

See also

rayfunction

Similar to raytrace except it only returns the rays at the last surface in local coordinates.

spot_diagram(figsize=(8, 6), s=5, cmap=None)[source]#

Create a spot diagram of the rays at each field point to inspect the performance of this optical system.

Parameters:
  • figsize (tuple[float, float]) – The size of the returned figure in inches.

  • s (float) – The marker size in points squared.

  • cmap (None | str | Colormap) – The colormap used to map scalar data to colors.

Return type:

tuple[Figure, Axes]

to_dxf(file, unit, transformation=None)#
Parameters:
to_string(prefix=None)#

Public-facing version of the __repr__ method that allows for defining a prefix string, which can be used to calculate how much whitespace to add to the beginning of each line of the result.

Parameters:

prefix (None | str) – an optional string, the length of which is used to calculate how much whitespace to add to the result.

Return type:

str

abstract property axis_surface: str#

The name of the logical axis representing the sequence of surfaces.

property field_max: AbstractCartesian2dVectorArray#

The upper right corner of this optical system’s field of view.

property field_min: AbstractCartesian2dVectorArray#

The lower left corner of this optical system’s field of view.

property field_stop: AbstractSurface#

The field stop surface.

abstract property grid_input: ObjectVectorArray#

The input grid to sample with rays.

This grid is simultaneously projected onto both the field stop and the pupil stop.

Positions on the stop can be specified in either absolute or normalized coordinates. Using normalized coordinates allows for injecting different grid types (cylindrical, stratified random, etc.) without specifying the scale of the stop surface.

If positions are specified in absolute units, they are measured in the coordinate system of the corresponding stop surface.

property index_field_stop: int#

The index of the field stop in surfaces_all.

property index_pupil_stop: int#

The index of the pupil stop in surfaces_all.

abstract property kwargs_plot: None | dict#

Extra keyword arguments that will be used in the call to named_arrays.plt.plot() within the plot() method.

abstract property object: AbstractSurface#

The external object being imaged or illuminated by this system.

If None, the external object is assumed to be at infinity.

property object_is_at_infinity: bool#

A boolean flag indicating if the object is at infinity.

If object doesn’t have an aperture, it is assumed that the object is at infinity.

property pupil_max#

The upper right corner of this optical system’s entrance pupil in physical units.

property pupil_min: AbstractCartesian2dVectorArray#

The lower left corner of this optical system’s entrance pupil in physical units.

property pupil_stop: AbstractSurface#

The pupil stop surface.

property rayfunction_default: RayFunctionArray#

Computes the rays in local coordinates at the last surface in the system as a function of input wavelength and position using grid_input.

This property is cached to increase performance. If grid_input is updated, the cache must be cleared with del system.rayfunction_default before calling this property.

property rayfunction_stops: RayFunctionArray#

A rayfunction defined on the input surface of the optical system, which is designed to exactly strike the borders of both the field stop and the pupil stop.

abstract property sensor: None | AbstractImagingSensor#

The imaging sensor that measures the light captured by this system.

This is the last surface in the optical system.

abstract property shape: dict[str, int]#

The array shape of this object.

abstract property surfaces: Sequence[AbstractSurface]#

A sequence of surfaces representing this optical system.

At least one of these surfaces needs to be marked as the pupil surface, and if the object surface is not marked as the field stop, one of these surfaces needs to be marked as the field stop.

property surfaces_all: list[AbstractSurface]#

Concatenate object with surfaces into a single list of surfaces.

abstract property transformation: None | AbstractTransformation#

the coordinate transformation between the global coordinate system and this object’s local coordinate system