prtools.zernike_coeff_legacy#
- zernike_coeff_legacy(coeffs, modes=None, order='noll')[source]#
Convert Zernike coefficients between legacy and current orientation conventions.
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.
This conversion is involutory so it converts legacy coefficients to the current convention and current coefficients to the legacy convention.
- Parameters:
coeffs (array_like) – Zernike coefficients. The last axis indexes Zernike modes, so a stack of coefficient vectors (e.g. a time series) can be converted in a single call.
modes (array_like, optional) – Zernike mode indices corresponding to the last axis of
coeffs, e.g. themodespassed tozernike_fit(). If None (default),coeffs[..., k]is taken to be the coefficient for mode indexk + 1, matchingzernike_compose().order ({'noll', 'fringe', 'ansi'}, optional) – Zernike ordering scheme. Default is ‘noll’.
- Returns:
Converted coefficients with the same shape as
coeffs.- Return type:
ndarray
Notes
The conversion is exact for masks with an even number of pixels in each dimension. Along any dimension with an odd number of pixels, the legacy coordinate origin was also offset half a pixel from the mask centroid. The effect of that offset on fitted coefficients is small but is not a sign change, so it cannot be undone by this function.
Examples
Convert tip, tilt, and focus coefficients fit with prtools 2.0.2:
>>> prtools.zernike_coeff_legacy([1e-8, 2e-8, 3e-8], modes=[2, 3, 4]) array([ 1.e-08, -2.e-08, 3.e-08])
See also