Zernike (paos.classes.zernike)

class Zernike(N, rho, phi, ordering='ansi', normalize=False)[source]

Bases: object

Generates Zernike polynomials

Parameters:
  • N (integer) – Number of polynomials to generate in a sequence following the defined ‘ordering’

  • rho (array like) – the radial coordinate normalised to the interval [0, 1]

  • phi (array like) – Azimuthal coordinate in radians. Has same shape as rho.

  • ordering (string) –

    Can either be:

    ANSI (ordering=’ansi’, this is the default); Noll (ordering=’noll’). Used in Zemax as “Zernike Standard Coefficients”,

    1. Noll, “Zernike polynomials and atmospheric turbulence”, J. Opt. Soc. Am., Vol. 66, No. 3, p207 (1976);

    Fringe (ordering=’fringe’), AKA the “Fringe” or “University of Arizona” notation; Standard (ordering=’standard’). Used in CodeV, Born and Wolf, Principles of Optics (Pergamon Press, New York, 1989).

  • normalize (bool) – Set to True generates ortho-normal polynomials. Set to False generates orthogonal polynomials as described in Laksminarayan & Fleck, Journal of Modern Optics (2011). The radial polynomial is estimated using the Jacobi polynomial expression as in their Equation in Equation 14.

Returns:

out – An instance of Zernike.

Return type:

masked array

Example

>>> import numpy as np
>>> from matplotlib import pyplot as plt
>>> x = np.linspace(-1.0, 1.0, 1024)
>>> xx, yy = np.meshgrid(x, x)
>>> rho = np.sqrt(xx**2 + yy**2)
>>> phi = np.arctan2(yy, xx)
>>> zernike = Zernike(36, rho, phi, ordering='noll', normalize=True)
>>> zer = zernike() # zer contains a list of polynomials, noll-ordered
>>> # Plot the defocus zernike polynomial
>>> plt.imshow(zer[3])
>>> plt.show()
>>> # Plot the defocus zernike polynomial
>>> plt.imshow(zernike(3))
>>> plt.show()

Note

In the example, the polar angle is counted counter-clockwise positive from the x axis. To have a polar angle that is clockwise positive from the y axis (as in figure 2 of Laksminarayan & Fleck, Journal of Modern Optics (2011)) use

>>> phi = 0.5*np.pi - np.arctan2(yy, xx)
static j2mn(N, ordering)[source]

Convert index j into azimuthal number, m, and radial number, n for the first N Zernikes

Parameters:
  • N (integer) – Number of polynomials (starting from Piston)

  • ordering (string) – can take values ‘ansi’, ‘standard’, ‘noll’, ‘fringe’

Returns:

m, n

Return type:

array

static mn2j(m, n, ordering)[source]

Convert radial and azimuthal numbers, respectively n and m, into index j

cov()[source]

Computes the covariance matrix M defined as

>>> M[i, j] = np.mean(Z[i, ...]*Z[j, ...])

When a pupil is defined as \(\Phi = \sum c[k] Z[k, ...]\), the pupil RMS can be calculated as

>>> RMS = np.sqrt( np.dot(c, np.dot(M, c)) )

This works also on a non-circular pupil, provided that the polynomials are masked over the pupil.

Returns:

M – the covariance matrix

Return type:

array