zernike.fit#
Zernike Fit Module
This module contains the ZernikeFit class, which can be used to fit Zernike polynomial to a set of points. This is commonly used for wavefront calculations, but the class can be used for any fitting operation requiring Zernike polynomials.
Kramer Harrison, 2025
Classes
|
Fit Zernike polynomials to wavefront or arbitrary data points. |
- class ZernikeFit(x: ScalarOrArray, y: ScalarOrArray, z: ScalarOrArray, zernike_type: Literal['fringe', 'standard', 'noll'] = 'fringe', num_terms: int = 36)[source]#
Fit Zernike polynomials to wavefront or arbitrary data points.
This class constructs a linear design matrix of Zernike basis functions and solves for the coefficients via least squares.
- Parameters:
- Variables:
x (array-like) – Flattened x-coordinates.
y (array-like) – Flattened y-coordinates.
z (array-like) – Flattened target values.
radius (array-like) – Radial coordinate of each point.
phi (array-like) – Azimuthal coordinate of each point.
num_pts (int) – Number of data points.
zernike (BaseZernike) – Zernike basis instance with fitted coefficients.
- property coeffs: BEArray#
The fitted Zernike coefficients.
- Type:
Tensor
- 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][source]#
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:
- Raises:
ValueError – If projection is not ‘2d’ or ‘3d’.