pyzernike.display_interactive#

pyzernike.xy_display_interactive(*, 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]#

Explore the Zernike polynomials on an elliptic annulus and their derivatives with respect to \(x\) and \(y\) in an interactive matplotlib figure.

../_images/elliptic_annulus_domain.png

The parameters of the elliptic annulus domain.#

The left panel of the figure contains:

  • text boxes to set the radial order \(n\), the azimuthal frequency \(m\) and the orders of the derivatives with respect to \(x\) and \(y\),

  • text boxes to set the parameters \((R_x, R_y, x_0, y_0, \alpha, h)\) of the elliptic annulus (\(\alpha\) in radians),

  • a text box to set the resolution of the grid,

  • a “Generate” button,

  • a message line reporting the invalid inputs.

The plot is computed and updated only when the “Generate” button is clicked, so that the values can be typed without triggering a computation at each change. The polynomials are drawn as colormaps on a Cartesian grid covering the elliptic annulus, transparent outside the annulus, with the boundaries of the annulus. The color scale spans \([\min(-1, Z), \max(1, Z)]\). If \(|m| > n\) or \(n - m\) is odd, the displayed polynomial is zero and a warning is shown.

The same figure is opened from the command line with pyzernike --xy.

See also

Parameters:
  • Rx (Optional[Real], optional) – The initial 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 initial 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 initial x coordinate \(x_0\) of the center of the ellipse. Must be finite. Default is 0.0.

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

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

  • h (Optional[Real], optional) – The initial 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 during the computation of each polynomial. Default is True.

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

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

  • value. (and means the default)

Return type:

None

Raises:
  • TypeError – 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 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.

Examples

Open the interactive figure:

from pyzernike import xy_display_interactive

xy_display_interactive()

Start with a rotated elliptic annulus:

xy_display_interactive(Rx=2.0, Ry=1.0, alpha=0.5, h=0.3)