pyzernike.core.core_create_precomputing_terms#

pyzernike.core.core_create_precomputing_terms(n: array, m: array, rho_derivative: array, theta_derivative: array | None, flag_radial: bool, float_type: type[floating]) Tuple[array, array, array, array, integer, integer][source]#

Create the arrays of usefull exponents, frequencies and integers for the computation of Zernike polynomials and their derivatives.

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

pyzernike.core.core_polynomial() for computing Zernike polynomials.

For one defined Zernike polynomial of order n, azimuthal frequency m and derivative with respect to rho a, the usefull rho exponents are :

\[\{ n - 2k - a \mid k = 0, 1, \ldots, \frac{n - |m|}{2} \}\]

The useful integers for the factorials are :

\[\{ n - k, k, \frac{n + |m|}{2} - k, \frac{n - |m|}{2} - k, n - 2k, n - 2k - a \mid k = 0, 1, \ldots, \frac{n - |m|}{2} \}\]

if \(n \geq a\) and \(n \geq |m|\) and \((n - m)\) is even, otherwise the output is a zeros array with the same shape as \(\rho\).

For the angular part, the usefull frequencies for the cosine and sine terms are \(|m|\) depending on the parity of theta_derivative and the sign of m.

Parameters:
  • 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.

  • rho_derivative (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).

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

Returns:

A tuple containing:

  • powers_exponents: An 1D array of unique integer exponents for the powers of rho needed for the computations with dtype compatible with float_type.

  • cosine_frequencies: An 1D array of unique integer frequencies for the cosine terms needed for the computations with dtype compatible with float_type.

  • sine_frequencies: An 1D array of unique integer frequencies for the sine terms needed for the computations with dtype compatible with float_type.

  • factorials_integers: An 1D array of unique integers for the factorials needed for the computations with dtype compatible with float_type.

  • max_n: The maximum order in n as integer of type compatible with float_type.

  • max_abs_m: The maximum absolute azimuthal frequency in m as integer of type compatible with float_type.

Return type:

Tuple[numpy.array[numpy.integer], numpy.array[numpy.integer], numpy.array[numpy.integer], numpy.array[numpy.integer], numpy.integer, numpy.integer]