Surface#

class optika.surfaces.Surface(name=None, sag=None, material=None, aperture=None, aperture_mechanical=None, rulings=None, is_field_stop=False, is_pupil_stop=False, transformation=None, kwargs_plot=None)[source]#

Bases: AbstractSurface[SagT, MaterialT, ApertureT, ApertureMechanicalT, RulingsT]

Representation of a single optical interface.

Composition of a sag profile, material type, aperture, and ruling specification (all optional).

Examples

Define a spherical mirror, with a rectangular aperture, \(z=50 \; \text{mm}\) from the origin.

Reflect a grid of collimated rays off of this mirror and measure their position at the origin.

import matplotlib.pyplot as plt
import astropy.units as u
import astropy.visualization
import named_arrays as na
import optika

# define a spherical reflective surface 50 mm from the origin
mirror = optika.surfaces.Surface(
    sag=optika.sags.SphericalSag(radius=-100 * u.mm),
    material=optika.materials.Mirror(),
    aperture=optika.apertures.RectangularAperture(30 * u.mm),
    transformation=na.transformations.Cartesian3dTranslation(z=50 * u.mm),
)

# define a detector surface at the origin to capture the reflected rays
detector=optika.surfaces.Surface()

# define a grid of collimated input rays
rays_input = optika.rays.RayVectorArray(
    position=na.Cartesian3dVectorArray(
        x=na.linspace(-25, 25, axis="pupil_x", num=5) * u.mm,
        y=na.linspace(-25, 25, axis="pupil_y", num=5) * u.mm,
        z=0 * u.mm,
    ),
    direction=na.Cartesian3dVectorArray(0, 0, 1),
)

# propagate the rays through the mirror and detector surfaces
rays_mirror = mirror.propagate_rays(rays_input)
rays_detector = detector.propagate_rays(rays_mirror)

# stack the 3 sets of rays into a single object
# for easier plotting
rays = [
    rays_input,
    rays_mirror,
    rays_detector,
]
rays = na.stack(rays, axis="surface")

# plot the rays and surface
with astropy.visualization.quantity_support():
    fig, ax = plt.subplots()
    ax.set_aspect("equal")
    components_plot = ("z", "y")
    na.plt.plot(rays.position, axis="surface", components=components_plot, color="tab:blue");
    mirror.plot(ax=ax, components=components_plot, color="black");
../_images/optika.surfaces.Surface_0_0.png

Attributes

aperture

The region of this surface which allows light to propagate.

aperture_mechanical

The shape of the physical substrate containing this optical surface.

is_field_stop

Whether this surface is the field stop of an optical system.

is_pupil_stop

Whether this surface is the pupil stop of an optical system.

is_stop

If this surface is pupil stop or the field stop, return True.

kwargs_plot

Additional keyword arguments to pass to the plot() function.

material

The optical material type of this surface.

name

The human-readable name of the surface.

rulings

The optional ruling profile of this surface.

sag

The sag profile of this surface.

shape

The array shape of this object.

transformation

The transformation between system coordinates and this surface.

Methods

__init__([name, sag, material, aperture, ...])

plot([ax, transformation, components])

Plot the selected components onto the given axes.

propagate_rays(rays)

Refract, reflect, and/or diffract the given rays off of this surface

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.surfaces.Surface
Parameters:
  • name (None | str)

  • sag (SagT)

  • material (MaterialT)

  • aperture (ApertureT)

  • aperture_mechanical (ApertureMechanicalT)

  • rulings (RulingsT)

  • is_field_stop (bool)

  • is_pupil_stop (bool)

  • transformation (None | AbstractTransformation)

  • kwargs_plot (None | dict)

plot(ax=None, transformation=None, components=None, **kwargs)#

Plot the selected components onto the given axes.

Parameters:
Return type:

dict[str, AbstractScalar]

propagate_rays(rays)#

Refract, reflect, and/or diffract the given rays off of this surface

Parameters:

rays (RayVectorArray) – a set of input rays that will interact with this surface

Return type:

RayVectorArray

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

aperture: ApertureT = None#

The region of this surface which allows light to propagate.

aperture_mechanical: ApertureMechanicalT = None#

The shape of the physical substrate containing this optical surface.

is_field_stop: bool = False#

Whether this surface is the field stop of an optical system.

is_pupil_stop: bool = False#

Whether this surface is the pupil stop of an optical system.

property is_stop: bool#

If this surface is pupil stop or the field stop, return True.

kwargs_plot: None | dict = None#

Additional keyword arguments to pass to the plot() function.

material: MaterialT = None#

The optical material type of this surface.

name: None | str = None#

The human-readable name of the surface.

rulings: RulingsT = None#

The optional ruling profile of this surface.

sag: SagT = None#

The sag profile of this surface.

property shape: dict[str, int]#

The array shape of this object.

transformation: None | AbstractTransformation = None#

The transformation between system coordinates and this surface.