pyzernike.radial_display#

pyzernike.radial_display(n: Integral | Sequence[Integral] | ndarray, m: Integral | Sequence[Integral] | ndarray, rho_derivative: Integral | Sequence[Integral] | ndarray | None = 0, *, precompute: bool = True, resolution: int = 200, rho_power: float = 1.0) → None[source]#

Display the radial Zernike polynomials \(R_{n}^{m}(\rho)\) and their derivatives in a matplotlib figure.

Each polynomial is drawn as a curve \(\rho \mapsto \frac{d^a R_{n}^{m}}{d\rho^a}(\rho)\) on \([0, 1]\). When several polynomials are given, the “Previous” and “Next” buttons of the figure navigate through them. The vertical axis spans \([\min(-1, R), \max(1, R)]\).

The radial Zernike polynomials [1] are defined for \(0 \leq m \leq n\) and \(n - m\) even by:

\[R_{n}^{m}(\rho) = \sum_{k=0}^{\frac{n-m}{2}} \frac{(-1)^k (n-k)!}{k! \left(\frac{n+m}{2} - k\right)! \left(\frac{n-m}{2} - k\right)!} \rho^{n-2k}\]

If \(m < 0\), \(m > n\), \(n - m\) is odd or \(a > n\), the displayed polynomial is zero.

Shape of the inputs. n, m and rho_derivative can each be a single integer or a sequence of integers (list, tuple or 1D numpy array). The integers are repeated to the length of the sequences, which must all have the same length.

See also

Parameters:
  • n (Union[Integral, Sequence[Integral], numpy.ndarray]) – The radial order(s) \(n\).

  • m (Union[Integral, Sequence[Integral], numpy.ndarray]) – The azimuthal frequency(ies) \(m\).

  • rho_derivative (Optional[Union[Integral, Sequence[Integral], numpy.ndarray]], optional) – The order(s) \(a \geq 0\) of the derivative with respect to \(\rho\). Default is 0 (no derivative). None is accepted and means 0.

  • precompute (bool, optional) – If True, the powers of \(\rho\) are cached and shared between the polynomials. Default is True.

  • resolution (int, optional) – The number of points along each axis of the display grid. Default is 200.

  • rho_power (float, optional) – The strictly positive exponent \(p\) of the display mapping: at the displayed radial coordinate \(s \in [0, 1]\), the polynomial is evaluated at \(\rho = s^{p}\). With \(p < 1\) (e.g. 0.5), the edge of the disk, where the high order polynomials oscillate the most, is enlarged; with \(p > 1\), the center is enlarged. Default is 1 (no mapping).

Return type:

None

Raises:
  • TypeError – If n, m or rho_derivative is not an integer or a sequence of integers, if precompute is not a boolean, or if resolution is not an integer or rho_power is not a real number.

  • ValueError – If the sequences do not have the same length or are empty, if a derivative order is negative, or if resolution is lower than 2 or rho_power is not strictly positive.

References

Examples

Display \(R_{2}^{0}(\rho)\):

from pyzernike import radial_display

radial_display(n=2, m=0)

Display all the radial polynomials of order 4 and their first derivatives:

radial_display(n=4, m=[0, 2, 4, 0, 2, 4], rho_derivative=[0, 0, 0, 1, 1, 1])
../_images/radial_display.png