optiland.zernike.base

Base Zernike Module

This module contains the abstract base class for all zernike-related classes. The Zernike implementation in this module is based on Niu, K., & Tian, C. (2022). Zernike polynomials and their applications. Journal of Optics, 24(12), 123001. https://doi.org/10.1088/2040-8986/ac9e08

Kramer Harrison, 2025

Classes

BaseZernike([coeffs, num_terms])

Abstract base class for Zernike polynomials.

class BaseZernike(coeffs=None, num_terms=36)[source]

Abstract base class for Zernike polynomials.

Parameters:
  • coeffs (array-like) – The Zernike coefficients. Defaults to None.

  • num_terms (int) – the maximum number of terms. Only used if coeffs is None. Defaults to 36.

get_derivative(n=0, m=0, r=0, phi=0)[source]

Calculate the derivative of the Zernike polynomial for the given coefficients and parameters.

Returns a tuple of the radial (dZ / dr) and azimuthal (dZ / dphi) partial derivatives of the Zernike polynomial.

Parameters:
  • n (int) – Radial order of the Zernike term.

  • m (int) – Azimuthal order of the Zernike term.

  • r (float) – Radial distance from the origin.

  • phi (float) – Azimuthal angle in radians.

Returns:

The radial and azimuthal derivatives of the

Zernike polynomial.

Return type:

tuple[float, float]

get_term(coeff: ScalarOrArray = 0, n: int = 0, m: int = 0, r: ScalarOrArray = 0, phi: ScalarOrArray = 0) ScalarOrArray[source]

Calculate the Zernike term for given coefficients and parameters.

Parameters:
  • coeff (float) – Coefficient value for the Zernike term.

  • n (int) – Radial order of the Zernike term.

  • m (int) – Azimuthal order of the Zernike term.

  • r (float) – Radial distance from the origin.

  • phi (float) – Azimuthal angle in radians.

Returns:

The calculated value of the Zernike term.

Return type:

float

poly(r: ScalarOrArray = 0, phi: ScalarOrArray = 0) float[source]

Calculate the Zernike polynomial for given radial distance and azimuthal angle.

Parameters:
  • r (float) – Radial distance from the origin.

  • phi (float) – Azimuthal angle in radians.

Returns:

The calculated value of the Zernike polynomial.

Return type:

float

terms(r: ScalarOrArray = 0, phi: ScalarOrArray = 0) list[source]

Calculate the Zernike terms for given radial distance and azimuthal angle.

Parameters:
  • r (float) – Radial distance from the origin.

  • phi (float) – Azimuthal angle in radians.

Returns:

List of calculated Zernike term values.

Return type:

list