optiland.wavefront.strategy

Defines the strategies for wavefront analysis.

This module provides different strategies for calculating the wavefront OPD, each encapsulating a different algorithm for determining the reference sphere. This approach uses the Strategy design pattern to allow for easy switching between methods like ‘chief_ray’ and ‘centroid_sphere’.

Kramer Harrison, 2024

Functions

create_strategy(strategy_name, optic, ...[, ...])

Factory function to create a wavefront calculation strategy.

Classes

BestFitSphereStrategy

alias of BestFitStrategy

CentroidReferenceSphereStrategy

alias of CentroidStrategy

ChiefRayStrategy(optic, distribution, **kwargs)

Calculates wavefront using the chief ray as the reference.

ReferenceStrategy(optic, distribution[, ...])

Abstract base class for a wavefront calculation strategy.

BestFitSphereStrategy

alias of BestFitStrategy

class BestFitStrategy(optic: Optic, distribution: BaseDistribution, **kwargs)[source]

Wavefront analysis strategy using a best-fit reference geometry.

This strategy computes the wavefront error relative to a reference that is determined by a least-squares fit to the wavefront points.

compute_wavefront_data(field: tuple[float, float], wavelength: float) WavefrontData

Computes wavefront data using a centroid-anchored reference.

Parameters:
  • field – Tuple (Hx, Hy) of field coordinates.

  • wavelength – Wavelength for the analysis in the system’s units.

Returns:

Structured data for the computed wavefront.

Return type:

WavefrontData

CentroidReferenceSphereStrategy

alias of CentroidStrategy

class CentroidStrategy(optic: Optic, distribution: BaseDistribution, robust_trim_std: float = 3.0, **kwargs)[source]

Wavefront analysis strategy using a centroid-anchored reference.

Parameters:
  • optic – The optical system under analysis.

  • distribution – The pupil sampling distribution.

  • robust_trim_std – Number of standard deviations for optional outlier trimming in centroid computation. Set <= 0 to disable.

compute_wavefront_data(field: tuple[float, float], wavelength: float) WavefrontData[source]

Computes wavefront data using a centroid-anchored reference.

Parameters:
  • field – Tuple (Hx, Hy) of field coordinates.

  • wavelength – Wavelength for the analysis in the system’s units.

Returns:

Structured data for the computed wavefront.

Return type:

WavefrontData

class ChiefRayStrategy(optic: Optic, distribution: BaseDistribution, **kwargs)[source]

Calculates wavefront using the chief ray as the reference.

compute_wavefront_data(field: tuple[float, float], wavelength: float) WavefrontData[source]

Computes wavefront data using the chief ray reference method.

Parameters:
  • field (tuple[float, float]) – The field coordinates to analyze.

  • wavelength (float) – The wavelength to use for the analysis.

Returns:

A data object containing the results.

Return type:

WavefrontData

class ReferenceStrategy(optic: Optic, distribution: BaseDistribution, reference_type: ReferenceType = 'sphere', **kwargs)[source]

Abstract base class for a wavefront calculation strategy.

This class defines the common interface for all wavefront calculation strategies. It also provides shared utility methods that concrete strategies can use, such as calculating the OPD from the image to the exit pupil reference sphere.

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

  • distribution (Distribution) – The pupil sampling distribution.

  • reference_type (str) – The type of reference geometry (“sphere” or “plane”).

abstract compute_wavefront_data(field: tuple[float, float], wavelength: float) WavefrontData[source]

Orchestrates the full wavefront data calculation.

This method should perform all necessary steps, including ray tracing, reference sphere calculation, and OPD computation, to generate the final wavefront data for a given field and wavelength.

Parameters:
  • field (tuple[float, float]) – The field coordinates to analyze.

  • wavelength (float) – The wavelength to use for the analysis.

Returns:

A data object containing the results.

Return type:

WavefrontData

create_strategy(strategy_name: WavefrontStrategyType, optic: Optic, distribution: BaseDistribution, reference_type: ReferenceType = 'sphere', **kwargs) ReferenceStrategy[source]

Factory function to create a wavefront calculation strategy.

Parameters:
  • strategy_name (str) – The name of the strategy (“chief_ray”, “centroid”, “best_fit”).

  • optic (Optic) – The optical system.

  • distribution (Distribution) – The pupil sampling distribution.

  • reference_type (str) – “sphere” or “plane”.

Returns:

An instance of the requested strategy.

Return type:

ReferenceStrategy

Raises:

ValueError – If the strategy_name is unknown.