pyzernike.xy_zernike_display#

pyzernike.xy_zernike_display(n: Integral | Sequence[Integral] | ndarray, m: Integral | Sequence[Integral] | ndarray, x_derivative: Integral | Sequence[Integral] | ndarray | None = 0, y_derivative: Integral | Sequence[Integral] | ndarray | None = 0, *, Rx: Real | None = 1.0, Ry: Real | None = 1.0, x0: Real | None = 0.0, y0: Real | None = 0.0, alpha: Real | None = 0.0, h: Real | None = 0.0, precompute: bool = True, resolution: int = 200) → None[source]#

Display the Zernike polynomials on an elliptic annulus [1] and their derivatives with respect to \(x\) and \(y\) in a matplotlib figure.

../_images/elliptic_annulus_domain.png

The parameters of the elliptic annulus domain.#

Each polynomial is drawn as a colormap on a Cartesian grid covering the elliptic annulus, transparent outside the annulus, with the boundaries of the annulus. When several polynomials are given, the “Previous” and “Next” buttons of the figure navigate through them. The color scale spans \([\min(-1, Z), \max(1, Z)]\).

The polynomials and their derivatives are computed as in pyzernike.xy_zernike_polynomial() (any derivative order, exact at the center of the ellipse). If \(|m| > n\) or \(n - m\) is odd, the displayed polynomial is zero.

Shape of the inputs. n, m, x_derivative and y_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\).

  • x_derivative (Optional[Union[Integral, Sequence[Integral], numpy.ndarray]], optional) – The non-negative order(s) of the derivative with respect to \(x\). Default is 0 (no derivative).

  • y_derivative (Optional[Union[Integral, Sequence[Integral], numpy.ndarray]], optional) – The non-negative order(s) of the derivative with respect to \(y\). Default is 0 (no derivative).

  • Rx (Optional[Real], optional) – The semi-axis \(R_x\) of the ellipse along its x axis. Must be finite and strictly positive. Default is 1.0.

  • Ry (Optional[Real], optional) – The semi-axis \(R_y\) of the ellipse along its y axis. Must be finite and strictly positive. Default is 1.0.

  • x0 (Optional[Real], optional) – The x coordinate \(x_0\) of the center of the ellipse. Must be finite. Default is 0.0.

  • y0 (Optional[Real], optional) – The y coordinate \(y_0\) of the center of the ellipse. Must be finite. Default is 0.0.

  • alpha (Optional[Real], optional) – The rotation angle \(\alpha\) of the ellipse in radians. Must be finite. Default is 0.0.

  • h (Optional[Real], optional) – The ratio \(h\) of the inner to the outer semi-axes, in \([0, 1)\). Default is 0.0 (full ellipse).

  • precompute (bool, optional) – If True, the powers of \(\rho_{eq}\) and \(1/r\) and the cosine and sine terms 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.

  • orders (None is accepted for all the parameters of the ellipse and for the derivative)

  • value. (and means the default)

Return type:

None

Raises:
  • TypeError – If n, m, x_derivative or y_derivative is not an integer or a sequence of integers, if a parameter of the ellipse is not a real number, if precompute is not a boolean, or if resolution is not an integer.

  • ValueError – If the sequences do not have the same length or are empty, if a derivative order is negative, if a parameter of the ellipse is not finite, if Rx or Ry is not strictly positive, if h is not in \([0, 1)\), or if resolution is lower than 2.

References

Examples

Display the defocus \(Z_{2}^{0}\) on a rotated ellipse:

from pyzernike import xy_zernike_display

xy_zernike_display(n=2, m=0, Rx=2.0, Ry=1.0, alpha=0.5)

Display the gradient of the astigmatism \(Z_{2}^{2}\) on an elliptic annulus:

xy_zernike_display(n=2, m=2, x_derivative=[1, 0], y_derivative=[0, 1], Rx=2.0, Ry=1.0, h=0.3)