optiland.wavefront.opd#

This module defines the OPD class.

Kramer Harrison, 2024

Classes

OPD(optic, field, wavelength[, num_rays, ...])

Represents an Optical Path Difference (OPD) wavefront.

OPDData

Per-field OPD sample grid: pupil coordinates and wavefront error.

class OPD(optic: Optic, field: tuple[float, float], wavelength: str | float, num_rays: int = 15, distribution: DistributionType = 'hexapolar', strategy: WavefrontStrategyType = 'chief_ray', remove_tilt: bool = False, **kwargs)[source]#

Represents an Optical Path Difference (OPD) wavefront.

Parameters:
  • optic (Optic) – The optic object.

  • field (tuple) – The field at which to calculate the OPD.

  • wavelength (str | float) – The wavelength of the wavefront. Can be ‘primary’ or a float value.

  • num_rings (int, optional) – The number of rings for ray tracing. Defaults to 15.

  • strategy (str) – The calculation strategy to use. Supported options are “chief_ray”, “centroid”, and “best_fit”. Defaults to “chief_ray”.

  • afocal (bool) – If True, uses a planar reference geometry for afocal systems. If False, uses a spherical reference geometry. Defaults to False.

  • remove_tilt (bool) – If True, removes tilt and piston from the OPD data. Defaults to False.

  • **kwargs – Additional keyword arguments passed to the strategy.

Variables:
  • optic (Optic) – The optic object.

  • field (tuple[float, float]) – The field coordinates (Hx, Hy).

  • wavelength (float) – The wavelength of the wavefront in micrometers.

  • num_rays (int) – The number of rays (or rings for hexapolar distribution) to use for pupil sampling.

  • distribution (BaseDistribution) – The pupil sampling distribution instance.

  • data (dict) – A dictionary mapping (field, wavelength) tuples to WavefrontData objects. Inherited from Wavefront.

Methods:
  • view (projection=’2d’, num_points=256, figsize=(7, 5.5)) – Visualizes the OPD wavefront.

  • rms() – Calculates the root mean square (RMS) of the OPD wavefront.

static fit_and_remove_tilt(data: WavefrontData, remove_piston: bool = False, ridge: float = 1e-12) be.ndarray#

Removes piston and tilt from OPD data using weighted least squares.

Parameters:
  • data (WavefrontData) – The wavefront data containing pupil coordinates and OPD.

  • remove_piston (bool, optional) – If True, removes piston term as well as tilt. Defaults to False.

  • ridge (float, optional) – Small diagonal regularization for stability. Defaults to 1e-12.

Returns:

OPD with piston and tilt removed, shape (N,).

Return type:

opd_detrended (be.ndarray)

generate_opd_map(num_points: int = 256) OPDData[source]#

Generates the OPD map data.

Parameters:

num_points (int, optional) – The number of points for interpolation along each axis of the grid. Defaults to 256.

Returns:

A dictionary containing the interpolated OPD map, with keys ‘x’, ‘y’, and ‘z’. The values are NumPy arrays.

Return type:

dict[str, np.ndarray]

get_data(field: tuple[float, float], wl: float) WavefrontData#

Retrieves precomputed wavefront data for a field and wavelength.

Parameters:
  • field (tuple[float, float]) – The field coordinates, or a FieldPoint.

  • wl (float) – The wavelength in µm, or a WavelengthPoint.

Returns:

A data container with the computed wavefront results.

Return type:

WavefrontData

rms() be.ndarray[source]#

Calculates the root mean square (RMS) of the OPD wavefront.

Returns:

The RMS value.

Return type:

float

view(fig_to_plot_on: Figure | None = None, projection: PlotProjection = '2d', num_points: int = 256, figsize: tuple[float, float] = (7, 5.5)) tuple[Figure, Axes][source]#

Visualizes the OPD wavefront.

Parameters:
  • fig_to_plot_on (plt.Figure, optional) – The figure to plot on. If None, a new figure is created.

  • projection (str, optional) – The projection type. Defaults to ‘2d’.

  • num_points (int, optional) – The number of points for interpolation. Defaults to 256.

  • figsize (tuple, optional) – The figure size. Defaults to (7, 5.5).

Returns:

A tuple containing the figure and axes objects.

Return type:

tuple

Raises:

ValueError – If the projection is not ‘2d’ or ‘3d’.

class OPDData[source]#

Per-field OPD sample grid: pupil coordinates and wavefront error.

x: NDArray#
y: NDArray#
z: NDArray#