lentil.zernike_fit#
- lentil.zernike_fit(opd, mask, modes, normalize=True, rho=None, theta=None)[source]#
Fit a Zernike basis set to an OPD.
- Parameters:
opd (array_like) – OPD to fit.
mask (array_like) – Mask defining the extent to compute the Zernike polynomial over. All nonzero entries are included in the result.
modes (array_like) – List of modes (Noll ordering) to fit.
normalize (bool, optional) – If True (default), the output is normalized according to [1]. If False, the output value ranges [-1, 1] over the mask.
rho (array_like, optional) – Radial coordinates of the mask array.
rho
should be 0 at the origin and 1 at the edge of the circle.theta (array_like, optional) – Angular coordinates of the mask array in radians.
- Returns:
List of coefficients fit to the supplied OPD over the specified number of Zernike modes.
- Return type:
ndarray
Examples
>>> import numpy as np >>> import lentil >>> mask = lentil.circle((256,256), 128, antialias=False) >>> coeffs = np.random.rand(4)*100e-9 >>> opd = lentil.zernike_compose(mask, coeffs) >>> fit_coeffs = lentil.zernike_fit(opd, mask, np.arange(2,4)) >>> print('Tip/tilt coefficients:', coeffs[1:3]) >>> print('Fit tip/tilt coefficients:', fit_coeffs) Tip/tilt coefficients: [9.69097470e-08 9.94332699e-08] Fit tip/tilt coefficients: [9.69545890e-08 9.94781119e-08]
See also
zernike_remove
Fit and remove a Zernike basis set from an OPD.
References
[1] Noll, RJ. Zernike polynomials and atmospheric turbulence. J Opt Soc Am 66, 207-211 (1976).