pyzernike.zernike_index_to_order#

pyzernike.zernike_index_to_order(j: Sequence[Integral]) Tuple[List[int], List[int]][source]#

Convert indices in the OSA/ANSI Zernike polynomial ordering to their corresponding Zernike orders (n, m).

\[j = \frac{n(n + 2) + m}{2}\]

See also

  • j must be a sequence of non-negative integers.

The first few Zernike polynomials in the OSA/ANSI ordering are:

j

n

m

0

0

0

1

1

-1

2

1

1

3

2

-2

4

2

0

5

2

2

The process to compute the Zernike orders from the index is as follows:

\[n(n+2) = 2j - m \in [2j - n, 2j + n]\]

So :

\[n = \text{int}\left(\frac{-1 + \sqrt{1 + 8j}}{2}\right) \quad \text{and} \quad m = 2j - n(n + 2)\]
Parameters:

j (Sequence[Integral]) – The indices of the Zernike polynomials in the OSA/ANSI ordering.

Returns:

  • List[int] – A list of radial orders (n) of the Zernike polynomials.

  • List[int] – A list of azimuthal frequencies (m) of the Zernike polynomials.

Raises:

TypeError – If j is not a sequence of integers.

Examples

from pyzernike import zernike_index_to_order

j = [2, 3, 4]
n, m = zernike_index_to_order(j)
print(n)  # Output: [1, 2, 2]
print(m)  # Output: [1, -2, 0]