optiland.wavefront.zernike_opd
This module defines the ZernikeOPD class.
Kramer Harrison, 2024
Classes
|
Represents a Zernike Optical Path Difference (OPD) calculation. |
- class ZernikeOPD(optic: Optic, field: tuple[float, float], wavelength: str | float, num_rings: int = 15, zernike_type: ZernikeType = 'fringe', num_terms: int = 37, strategy: WavefrontStrategyType = 'chief_ray', remove_tilt: bool = False, **kwargs)[source]
Represents a Zernike Optical Path Difference (OPD) calculation.
This class inherits from both the ZernikeFit and OPD classes. It first generates the OPD map(s), then fits Zernike polynomials to the map(s).
- Parameters:
optic (object) – The optic object representing the optical system.
field (tuple) – The field used for the calculation.
wavelength (str | float) – The wavelength of light used in the calculation. Can be ‘primary’ or a float value.
num_rings (int, optional) – The number of rings used in the Zernike calculation. Default is 15.
zernike_type (str, optional) – The type of Zernike polynomials used. Default is ‘fringe’. See zernike module for more information.
num_terms (int, optional) – The number of Zernike terms used in the calculation. Default is 37.
strategy (str) – The calculation strategy to use. Supported options are “chief_ray”, “centroid_sphere”, and “best_fit_sphere”. Defaults to “chief_ray”.
remove_tilt (bool) – If True, removes tilt and piston from the OPD data. Defaults to False.
**kwargs – Additional keyword arguments passed to the strategy, including the afocal boolean flag to indicate if the system is afocal.
- property coeffs: BEArray
The fitted Zernike coefficients.
- Type:
Tensor
- 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
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:
- rms() be.ndarray
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: str = '2d', num_points: int = 128, figsize: tuple[float, float] = (7, 5.5), z_label: str = 'OPD (waves)') tuple[Figure, Axes]
Visualize the fitted Zernike surface.
- Parameters:
fig_to_plot_on (plt.Figure, optional) – Figure to plot on. If None, a new figure is created.
projection (str) – ‘2d’ for image plot, ‘3d’ for surface plot.
num_points (int) – Grid resolution for display.
figsize (tuple) – Figure size in inches.
to (defaults)
z_label (str) – Label for the z-axis or colorbar.
'OPD (defaults to)
- Returns:
A tuple containing the figure and axes objects.
- Return type:
tuple
- Raises:
ValueError – If projection is not ‘2d’ or ‘3d’.
- view_residual(fig_to_plot_on: Figure | None = None, figsize: tuple[float, float] = (7, 5.5), z_label: str = 'Residual (waves)')
Scatter plot of residuals between fitted surface and original data.
- Parameters:
fig_to_plot_on (plt.Figure, optional) – Figure to plot on. If None, a new figure is created.
figsize (tuple) – Figure size in inches. Defaults to (7, 5.5).
z_label (str) – Label for the colorbar. Defaults to ‘Residual (waves)’.
- Returns:
A tuple containing the figure and axes objects.
- Return type:
tuple