prtools.zernike_compose#
- zernike_compose(mask, coeffs, normalize=True, order='noll', rho=None, theta=None, legacy=False)[source]#
Create an OPD based on the supplied Zernike coefficients.
- Parameters:
mask (array_like) – Binary mask defining the extent to compute the Zernike polynomial over.
coeffs (array_like) – List of coefficients corresponding to Zernike indices used to create the OPD.
normalize (bool, optional) – If True (default), the output is normalized according to [1]. If False, the output value ranges [-1, 1] over the mask.
order ({'noll', 'fringe', 'ansi'}, optional) – Zernike ordering scheme. Default is ‘noll’.
rho (array_like, optional) – Radial coordinates of the mask array.
rhoshould 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.
legacy (bool, optional) – If True, reproduce the Zernike convention of prtools 2.0.2 and earlier. Default is False. See the warning below for details.
- Return type:
ndarray
Warning
prtools 2.0.2 and earlier computed Zernike polynomials in a coordinate system mirrored top-to-bottom (y -> -y). This results in modes with negative azimuthal order (sine terms: y tilt, 45 degree astigmatism, y coma, …) having a flipped sign. Modes with zero or positive azimuthal order are unaffected. The
zernike_coeff_legacy()function converts between current and legacy conventions.Examples
Compute a random OPD using the first ten Zernikes:
>>> mask = prtools.circle((256,256), 120, antialias=False) >>> coeffs = np.random.rand(10)*1e-8 >>> opd = prtools.zernike_compose(mask, coeffs) >>> plt.imshow(opd)
Using the same mask, compute an OPD representing 200 nm focus error (Z4) and -100 nm astigmatism error (Z6):
>>> opd = prtools.zernike_compose(mask, [0, 0, 0, 200e-9, 0, -100e-9]) >>> plt.imshow(opd)
References
[1] Noll, RJ. Zernike polynomials and atmospheric turbulence. J Opt Soc Am 66, 207-211 (1976).