optic.extended_source_optic

Extended Source Optic Module

This module defines the ExtendedSourceOptic class, a wrapper around the core Optic class that enables extended source ray tracing. This design keeps the core Optic class unchanged while providing source-based ray tracing and visualization functionality.

Classes

ExtendedSourceOptic(optic, source)

Wrapper for Optic that enables extended source ray tracing.

class ExtendedSourceOptic(optic: Optic, source: BaseSource)[source]

Wrapper for Optic that enables extended source ray tracing.

This class wraps a standard Optic instance and provides source-based ray tracing and visualization methods without modifying the core Optic API. It delegates all standard Optic attributes and methods to the underlying optic instance.

Parameters:
  • optic (Optic) – The optical system to wrap.

  • source (BaseSource) – The extended source for ray generation.

optic

The underlying optical system.

Type:

Optic

source

The extended source for generating rays.

Type:

BaseSource

draw(num_rays: int = 1000, figsize: tuple[float, float] = (10, 4), xlim: tuple[float, float] | None = None, ylim: tuple[float, float] | None = None, title: str | None = None, projection: Literal['XY', 'XZ', 'YZ'] = 'YZ', ax: Axes | None = None) tuple[Figure, Axes][source]

Draw a 2D representation of the optical system with rays from the extended source.

This method traces rays from the attached source and visualizes them through the optical system alongside the rendered surfaces.

Parameters:
  • num_rays (int, optional) – The number of rays to generate and trace. Defaults to 1000.

  • figsize (tuple[float, float], optional) – The size of the figure. Defaults to (10, 4).

  • xlim (tuple[float, float] | None, optional) – The x-axis limits of the plot. Defaults to None.

  • ylim (tuple[float, float] | None, optional) – The y-axis limits of the plot. Defaults to None.

  • title (str | None, optional) – The title of the plot. Defaults to None, which auto-generates a title from the source type.

  • projection (Literal["XY", "XZ", "YZ"], optional) – The projection plane. Defaults to “YZ”.

  • ax (matplotlib.axes.Axes, optional) – The axes to plot on. If None, a new figure and axes are created. Defaults to None.

Returns:

A tuple containing the matplotlib Figure and Axes objects of the plot.

Return type:

tuple[Figure, Axes]

trace(num_rays: int = 1000) tuple[RealRays, dict][source]

Trace rays generated from the extended source through the optical system.

This method generates rays using the attached source and traces them through the optical system.

Parameters:

num_rays (int) – The number of rays to generate and trace. Defaults to 1000.

Returns:

A tuple containing:
  • RealRays: The traced rays (final positions and directions).

  • dict: Ray path data with ‘x’, ‘y’, ‘z’ arrays of shape

    (num_surfaces, num_rays).

Return type:

tuple

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

Not available for ExtendedSourceOptic.

Raises:

NotImplementedError – Always raised. Use trace(num_rays) instead.