pyzernike.zernike_order_to_index#

pyzernike.zernike_order_to_index(n: Sequence[Integral], m: Sequence[Integral]) List[int][source]#

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

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

If \(|m| > n\) or \(n < 0\), or \((n - m)\) is odd, an error is raised.

See also

  • The parameters n and m must be sequences of integers with the same length.

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

Parameters:
  • n (Sequence[Integral]) – The radial orders of the Zernike polynomials.

  • m (Sequence[Integral]) – The azimuthal frequencies of the Zernike polynomials.

Returns:

A list of indices corresponding to the Zernike orders.

Return type:

List[int]

Raises:
  • TypeError – If n or m are not sequences of integers.

  • ValueError – If n and m do not have the same length.

Examples

from pyzernike import zernike_order_to_index

n = [2, 3, 4]
m = [0, 1, -2]
indices = zernike_order_to_index(n, m)
print(indices)  # Output: [4, 8, 11]