API Reference#

All the functions are available at the top level of the package (import pyzernike then pyzernike.zernike_polynomial(...)). To learn how to use them, see Usage; for the definitions and the methods, see Mathematical description.

Common arguments#

The functions share the same names of arguments and the same conventions:

Argument

Meaning

rho, theta

Polar coordinates on the unit disk (\(0 \leq \rho \leq 1\), \(\theta\) in radians).

x, y

Cartesian coordinates, for the functions prefixed by xy_.

n, m

Radial order \(n\) and azimuthal frequency \(m\) of a polynomial \(Z_{n}^{m}\) (\(|m| \leq n\), \(n - m\) even). See Definition and conventions.

order

Maximum radial order \(N\): all the \(P = \frac{(N+1)(N+2)}{2}\) polynomials with \(n \leq N\) are used, in the OSA/ANSI ordering.

rho_derivative, theta_derivative

Orders \(a\) and \(b\) of the derivatives with respect to \(\rho\) and \(\theta\).

x_derivative, y_derivative

Orders \(d_x\) and \(d_y\) of the derivatives with respect to \(x\) and \(y\).

Rx, Ry, x0, y0, alpha, h

Parameters of the elliptic annulus: semi-axes, center, rotation angle (radians) and ratio \(h \in [0, 1)\) of the inner to the outer semi-axes. The default is the unit disk. See Extension to an elliptic annulus.

coefficients

Coefficients \(c_j\) of a sum \(\sum_j c_j Z_j\), in the OSA/ANSI ordering, for all the polynomials up to an order (1, 3, 6, 10, 15, … values). See Coefficients of a sum of polynomials.

normalize

If True, the polynomials (or the coefficients) are those normalized by the factors of Noll.

use_recursive

If True, the polynomials are computed with the recurrence relation (recommended for high orders).

default

Value set outside the domain (numpy.nan by default).

to_list

Output as a list of arrays (True) or as a single array (False).

Single integers and sequences of integers can be mixed for n, m and the derivative orders: the integers are repeated to the length of the sequences.

Polynomials on the unit disk#

pyzernike.zernike_polynomial()

Zernike polynomials \(Z_{n}^{m}(\rho, \theta)\) and their derivatives, for given \((n, m)\).

pyzernike.zernike_polynomial_up_to_order()

All the Zernike polynomials up to an order and their derivatives.

pyzernike.radial_polynomial()

Radial polynomials \(R_{n}^{m}(\rho)\) and their derivatives.

Polynomials on an elliptic annulus#

pyzernike.xy_zernike_polynomial()

Zernike polynomials in Cartesian coordinates on an elliptic annulus, and their derivatives of any order with respect to \(x\) and \(y\).

pyzernike.xy_zernike_polynomial_up_to_order()

All the Zernike polynomials up to an order on an elliptic annulus, and their derivatives.

pyzernike.xy_zernike_parameter_derivative()

Derivatives of the polynomials with respect to the parameters \((x_0, y_0, R_x, R_y, \alpha, h)\) of the annulus.

pyzernike.cartesian_to_elliptic_annulus()

Equivalent polar coordinates \((\rho_{eq}, \theta_{eq})\) of Cartesian points, and their derivatives.

Indexing and normalization#

pyzernike.zernike_index_to_order()

Orders \((n, m)\) of indices in the OSA/ANSI, Noll or Fringe convention.

pyzernike.zernike_order_to_index()

Indices of orders \((n, m)\) in the OSA/ANSI, Noll or Fringe convention.

pyzernike.zernike_polynomials_count()

Number of polynomials up to an order.

pyzernike.zernike_normalization()

Normalization factors of Noll.

Coefficients#

pyzernike.zernike_evaluate()

Sum of polynomials \(\sum_j c_j Z_j\) and its derivatives on the unit disk.

pyzernike.xy_zernike_evaluate()

Sum of polynomials and its derivatives on an elliptic annulus.

pyzernike.zernike_coefficients_convert()

Conversion of coefficients between the indexing conventions and the normalizations.

pyzernike.zernike_coefficients_rotate()

Coefficients in a rotated pupil.

pyzernike.zernike_coefficients_transform()

Coefficients in a scaled, decentered and rotated pupil.

pyzernike.zernike_rms()

Root mean square of a sum of polynomials.

pyzernike.zernike_peak_to_valley()

Peak-to-valley of a sum of polynomials.

pyzernike.zernike_strehl_ratio()

Strehl ratio of a wavefront (extended Maréchal approximation).

Fitting#

pyzernike.zernike_fit()

Least squares fit of sampled data on the unit disk.

pyzernike.xy_zernike_fit()

Least squares fit of sampled data on an elliptic annulus.

pyzernike.xy_zernike_least_squares()

Residual and Jacobian functions to estimate the parameters of the annulus with any least squares solver.

Symbolic expressions#

These functions require sympy (pip install sympy, see Installation).

pyzernike.zernike_symbolic()

Exact sympy expressions of the Zernike polynomials and of their derivatives.

pyzernike.radial_symbolic()

Exact sympy expressions of the radial polynomials and of their derivatives.

Display#

These functions require matplotlib (pip install matplotlib, see Installation).

pyzernike.zernike_display()

Figure of given Zernike polynomials on the unit disk.

pyzernike.radial_display()

Figure of given radial polynomials.

pyzernike.display_interactive()

Interactive window to explore the polynomials on the unit disk (command pyzernike).

pyzernike.xy_zernike_display()

Figure of given Zernike polynomials on an elliptic annulus.

pyzernike.xy_display_interactive()

Interactive window to explore the polynomials on an elliptic annulus (command pyzernike --xy).