sources.base

Base Source Class Module

This module defines the abstract base class for all source types in Optiland. All concrete source implementations must inherit from BaseSource and implement the generate_rays method.

Classes

BaseSource([position])

Abstract base class for all source types in Optiland.

class BaseSource(position: tuple[float, float, float] = (0.0, 0.0, 0.0))[source]

Abstract base class for all source types in Optiland.

This class defines the interface that all source implementations must follow. All concrete source classes must implement the generate_rays method.

The source includes a coordinate system for proper positioning in 3D space. Rays generated by the source are automatically transformed from local coordinates to global coordinates using this coordinate system.

cs

The coordinate system defining the source’s position and orientation in 3D space.

Type:

CoordinateSystem

draw(num_rays: int = 5000, propagation_distance: float = 0.1, figsize: tuple[float, float] = (18, 8), cross_spatial: tuple[str, str] = ('x', 'y'), cross_angular: tuple[str, str] = ('L', 'M')) tuple[Figure, list[Axes]][source]

Visualize the extended source with a comprehensive 6-panel plot.

This method creates a visualization showing the spatial and angular distributions and propagation characteristics of the rays generated by this source. The plot consists of six panels arranged in a 2x3 grid:

Column 1: Spatial and Angular Distributions - Panel (0,0): XY spatial distribution with intensity color-coding - Panel (1,0): Angular distribution (L vs M direction cosines)

Column 2: Cross-sections - Panel (0,1): Spatial cross-sections (X and Y profiles) - Panel (1,1): Angular cross-sections (L and M profiles)

Column 3: Ray Propagation - Panel (0,2): XZ ray propagation paths with intensity-based coloring - Panel (1,2): YZ ray propagation paths with intensity-based coloring

Parameters:
  • num_rays (int, optional) – Number of rays to generate for visualization. Defaults to 5000.

  • propagation_distance (float, optional) – Distance in mm to propagate rays for path visualization. Defaults to 0.1.

  • figsize (tuple[float, float], optional) – Figure size (width, height) in inches. Defaults to (18, 8).

  • cross_spatial (tuple[str, str], optional) – Spatial cross-section axes. Defaults to (“x”, “y”).

  • cross_angular (tuple[str, str], optional) – Angular cross-section axes. Defaults to (“L”, “M”).

Returns:

Matplotlib figure and list of 6 axes objects.

Return type:

tuple[Figure, list[Axes]]

abstract generate_rays(num_rays: int) RealRays[source]

Generate a specified number of rays from this source.

Parameters:

num_rays (int) – The number of rays to generate.

Returns:

An object containing the generated rays with their

positions, directions, intensities, and wavelengths.

Return type:

RealRays

Raises:

ValueError – If num_rays is not a positive integer or if ray generation fails.