zernike_peak_to_valley#

pyzernike.zernike_peak_to_valley(coefficients: Sequence[float] | ndarray, *, normalize: bool = False, resolution: Integral = 256) → float[source]#

Compute the peak-to-valley (PV) of a sum of Zernike polynomials on the unit disk from its coefficients.

\[PV = \max_{\rho \leq 1} f - \min_{\rho \leq 1} f \quad \text{with} \quad f = \sum_j c_j Z_j\]

There is no closed-form expression: the function is evaluated with the recurrence relation on a polar grid of resolution radii in \([0, 1]\) and 2 * resolution angles. The result is a lower bound of the exact value, which converges quickly with the resolution for smooth functions (the error is of the order of the variation of \(f\) between two points of the grid).

It is also the PV on an ellipse for the polynomials of pyzernike.xy_zernike_polynomial() with \(h = 0\) (the image of the disk is the ellipse).

See also

Parameters:
  • coefficients (Union[Sequence[float], numpy.ndarray]) – The coefficients \(c_j\) in the OSA/ANSI ordering, as a 1D array of \(P = \frac{(N+1)(N+2)}{2}\) finite real numbers.

  • normalize (bool, optional) – If True, the coefficients are those of the polynomials normalized by the factors of Noll (see pyzernike.zernike_normalization()). Default is False.

  • resolution (Integral, optional) – The number of radii of the polar grid (the number of angles is 2 * resolution). Must be an integer greater than or equal to 2. Default is 256.

Returns:

The peak-to-valley, in the unit of the coefficients.

Return type:

float

Raises:
  • TypeError – If coefficients can not be converted to an array of real numbers, if normalize is not a boolean, or if resolution is not an integer.

  • ValueError – If coefficients is not a 1D array of finite values whose length is \(\frac{(N+1)(N+2)}{2}\), or if resolution is lower than 2.

Examples

The PV of the defocus \(Z_2^0 = 2\rho^2 - 1\) is 2:

from pyzernike import zernike_peak_to_valley

zernike_peak_to_valley([0.0, 0.0, 0.0, 0.0, 1.0, 0.0])  # 2.0