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

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.

optic

The optic object.

Type:

Optic

field

The field coordinates (Hx, Hy).

Type:

tuple[float, float]

wavelength

The wavelength of the wavefront in micrometers.

Type:

float

num_rays

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

Type:

int

distribution

The pupil sampling distribution instance.

Type:

BaseDistribution

data

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

Type:

dict

view(projection='2d', num_points=256, figsize=(7, 5.5))[source]

Visualizes the OPD wavefront.

rms()[source]

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]
clear() None.  Remove all items from D.
copy() a shallow copy of D
fromkeys(value=None, /)

Create a new dictionary with keys from iterable and values set to value.

get(key, default=None, /)

Return the value for key if key is in the dictionary, else default.

items() a set-like object providing a view on D's items
keys() a set-like object providing a view on D's keys
pop(k[, d]) v, remove specified key and return the corresponding value.

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem()

Remove and return a (key, value) pair as a 2-tuple.

Pairs are returned in LIFO (last-in, first-out) order. Raises KeyError if the dict is empty.

setdefault(key, default=None, /)

Insert key with a value of default if key is not in the dictionary.

Return the value for key if key is in the dictionary, else default.

update([E, ]**F) None.  Update D from mapping/iterable E and F.

If E is present and has a .keys() method, then does: for k in E.keys(): D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values() an object providing a view on D's values
x: NDArray
y: NDArray
z: NDArray