Zernike#
- class deepinv.physics.generator.Zernike[source]#
Bases:
objectStatic utility class for Zernike polynomials (ANSI/Noll Nomenclature). All methods are static; no instantiation required.
Zernike polynomials are a sequence of polynomials that are orthogonal on the unit disk. They are commonly used in optical systems to describe wavefront aberrations, see Lakshminarayanan and Fleck[1] (or this link).
They are defined by two indices: the radial order \(n\) and the azimuthal frequency \(m\), with the constraints that \(n >= 0\), \(|m| <= n\), and \(n - |m|\) is even.
The Zernike polynomial \(Z_n^m\) can be expressed in polar coordinates \((\\rho, \\theta)\) as:
\[ \begin{align}\begin{aligned}Z_n^m(\rho, \theta) =\\\begin{split}\begin{cases} N_n^m R_n^m(\rho) \cos(m \theta) & \text{ if } m \geq 0 \\ N_n^m R_n^m(\rho) \sin(|m| \theta) & \text{ if } m < 0 \end{cases}\end{split}\end{aligned}\end{align} \]where \(R_n^m(\rho)\) is the radial polynomial defined as:
\[R_n^m(\rho) = \sum_{k=0}^{(n - |m|)/2} (-1)^k \frac{(n - k)!}{k! \left(\frac{n + |m|}{2} - k\right)! \left(\frac{n - |m|}{2} - k\right)!} \rho^{n - 2k}\]and \(N_n^m\) is the normalization constant (root-mean-square, ensuring the polynomials have unit energy) given by:
\[\begin{split}N_n^m = \begin{cases} \sqrt{n + 1} & \text{ if } m = 0 \\ \sqrt{2(n + 1)} & \text{ if } m \neq 0 \end{cases}\end{split}\]
- References:
- static cartesian_evaluate(n, m, x, y, use_mask=True)[source]#
Evaluates the Zernike polynomial \(Z_n^m\) on given Cartesian coordinates.
- Parameters:
n (int) β the radial order
m (int) β the azimuthal frequency
x (torch.Tensor) β x-coordinates in Cartesian system
y (torch.Tensor) β y-coordinates in Cartesian system
use_mask (bool) β if True, values outside the unit disk are set to zero. Default to
True
- Returns:
Evaluated Zernike polynomial values as a tensor
- Return type:
- static index_conversion(index, *, convention='ansi')[source]#
Converts a single index for Zernike polynomials between different conventions. For more details on the conventions, see wikipedia.
- Parameters:
Single index for Zernike polynomials:
- static polar_evaluate(n, m, rho, theta, use_mask=True)[source]#
Evaluates the Zernike polynomial \(Z_n^m\) on given polar coordinates.
- Parameters:
n (int) β the radial order
m (int) β the azimuthal frequency
rho (torch.Tensor) β radial coordinates in polar system
theta (torch.Tensor) β angular coordinates in polar system
use_mask (bool) β if True, values outside the unit disk are set to zero. Default to
True
- Returns:
Evaluated Zernike polynomial values as a tensor
- Return type: