pyzernike.core.core_polynomial#

pyzernike.core.core_polynomial(rho: ndarray, theta: ndarray | None, n: array, m: array, rho_derivative: array, theta_derivative: array | None, flag_radial: bool, precompute: bool, float_type: type[floating]) List[ndarray][source]#

Assemble the Zernike polynomial \(Z_{n}^{m}(\rho, \theta)\) or the radial Zernike polynomial \(R_{n}^{m}(\rho)\) (if the flag flag_radial is set to True) for each given tuple of (n, m, rho_derivative, theta_derivative) in the input lists.

Warning

This method is a core function of pyzernike that is not designed to be use by the users directly. Please use the high level functions.

See also

  • rho and theta are expected to be floating point type numpy arrays of the same shape, dtype and in the range [0, 1] for rho.

  • n, m, rho_derivative and theta_derivative are expected to be arrays of integers of the same length and valid values.

The function is designed to precompute the useful terms for the Zernike polynomials, such as the powers of rho, the cosine and sine terms, and the logarithm of the factorials.

Parameters:
  • rho (numpy.ndarray (N-D array)) – The radial coordinate values with shape (…,) and floating point dtype corresponding to float_type.

  • theta (numpy.ndarray (N-D array)) – The angular coordinate values with shape (…,) and floating point dtype corresponding to float_type. Must be None if flag_radial is True.

  • n (numpy.array[numpy.integer]) – The orders of the Zernike polynomials to compute. Must be a 1D array of integers of type compatible with float_type.

  • m (numpy.array[numpy.integer]) – The azimuthal frequencies of the Zernike polynomials. Must be a 1D array of integers of type compatible with float_type.

  • numpy.array[numpy.integer] – The orders of the derivatives with respect to rho. Must be a 1D array of integers of type compatible with float_type.

  • theta_derivative (Optional[numpy.array[numpy.integer]]) – The orders of the derivatives with respect to theta. Must be None if flag_radial is True. Otherwise, must be a 1D array of integers of type compatible with float_type.

  • flag_radial (bool) – If True, computes the sets for radial polynomials only (no angular part). The output sine and cosine frequency sets will be empty. If False, computes the sets for full Zernike polynomials (including angular part).

  • precompute (bool) – If True, the useful terms for the Zernike polynomials are precomputed to optimize the computation. This is useful when computing multiple Zernike polynomials with the same rho and theta values. If False, the useful terms are computed on-the-fly for each polynomial, which may be slower but avoid memory overhead.

  • float_type (type[numpy.floating]) – The floating point type used for the computations (e.g., numpy.float32, numpy.float64).

Returns:

A list of numpy.ndarray containing the Zernike polynomials for each (n, m, rho_derivative, theta_derivative) tuple, or the radial Zernike polynomials if flag_radial is True. Each polynomial has the shape of rho (and theta if flag_radial is False).

Return type:

List[numpy.ndarray[numpy.floating]]