pyzernike.radial_display#

pyzernike.radial_display(n: ~numpy.array | ~typing.Sequence[~numbers.Integral], m: ~numpy.array | ~typing.Sequence[~numbers.Integral], rho_derivative: ~numpy.array | ~typing.Sequence[~numbers.Integral] | None = None, precompute: bool = True, float_type: ~numpy.floating = <class 'numpy.float64'>) None[source]#

Display the radial Zernike polynomial \(R_{n}^{m}(\rho)\) for \(\rho \leq 1\) in an interactive matplotlib figure.

The radial Zernike polynomial is defined as follows:

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

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

See also

The function allows to display several radial Zernike polynomials for different sets of (order, azimuthal frequency, derivative order) given as sequences.

  • The parameters n, m and rho_derivative must be sequences of integers with the same length.

Parameters:
  • n (Sequence[Integral] or numpy.array) – A sequence (List, Tuple) or 1D numpy array of the radial order(s) of the Zernike polynomial(s) to display. Must be non-negative integers.

  • m (Sequence[Integral] or numpy.array) – A sequence (List, Tuple) or 1D numpy array of the azimuthal frequency(ies) of the Zernike polynomial(s) to display. Must be non-negative integers.

  • rho_derivative (Optional[Union[Sequence[Integral], numpy.array]], optional) – A sequence (List, Tuple) or 1D numpy array of the order(s) of the radial derivative(s) to display. Must be non-negative integers. If None, is it assumed that rho_derivative is 0 for all polynomials.

  • precompute (bool, optional) – If True, the useful terms for the Zernike polynomials are precomputed to optimize the computation. If False, the useful terms are computed on-the-fly to avoid memory overhead. Default is True.

  • float_type (numpy.floating, optional) – The floating point type to use for the computations. Default is numpy.float64.

Return type:

None

Raises:
  • TypeError – If n, m or rho_derivative (if not None) are not sequences of integers.

  • ValueError – If the lengths of n, m and rho_derivative (if not None) are not the same.

Examples

Display the radial Zernike polynomial \(R_{2}^{0}(\rho)\):

from pyzernike import radial_display
radial_display(n=[2], m=[0]) # This will display the radial Zernike polynomial R_2^0 in an interactive matplotlib figure.

To display multiple radial Zernike polynomials, you can pass sequences for n and m:

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