Coverage for python/lsst/sims/utils/ZernikeModule.py : 88%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" A class that generates factorials and stores them in a dict to be referenced as needed. """
""" Return the factorial of num """ raise RuntimeError("Cannot handle negative factorial")
""" A class to generate and evaluate the Zernike polynomials. Definitions of Zernike polynomials are taken from https://en.wikipedia.org/wiki/Zernike_polynomials """
""" Make sure that n, m are a valid pair of indices for a Zernike polynomial.
n is the radial order
m is the angular order """ raise RuntimeError('Zernike polynomial n must be int') raise RuntimeError('Zernike polynomial m must be int')
raise RuntimeError('Radial Zernike n cannot be negative') raise RuntimeError('Radial Zernike m cannot be negative') raise RuntimeError('Radial Zerniki n must be >= m')
""" Make the radial part of the n, m Zernike polynomial.
n is the radial order
m is the angular order
Returns 2 numpy arrays: coeffs and powers.
The radial part of the Zernike polynomial is
sum([coeffs[ii]*power(r, powers[ii]) for ii in range(len(coeffs))]) """
# coefficients taken from # https://en.wikipedia.org/wiki/Zernike_polynomials
else:
""" Evaluate the radial part of a Zernike polynomial.
r is a scalar value
nm_tuple is a tuple of the form (radial order, angular order) denoting the polynomial to evaluate
Return the value of the radial part of the polynomial at r """
""" Evaluate the radial part of a Zernike polynomial.
r is a numpy array of radial values
nm_tuple is a tuple of the form (radial order, angular order) denoting the polynomial to evaluate
Return the values of the radial part of the polynomial at r (returns np.NaN if r>1.0) """ return np.array([],dtype=float)
# since we use np.where to handle cases of # r==0, use np.errstate to temporarily # turn off the divide by zero and # invalid double scalar RuntimeWarnings
""" Evaluate the radial part of a Zernike polynomial
r is a radial value or an array of radial values
n is the radial order of the polynomial
m is the angular order of the polynomial
Return the value(s) of the radial part of the polynomial at r (returns np.NaN if r>1.0) """
return np.zeros(len(r), dtype=float)
""" Evaluate a Zernike polynomial in polar coordinates
r is the radial coordinate (a scalar or an array)
phi is the angular coordinate in radians (a scalar or an array)
n is the radial order of the polynomial
m is the angular order of the polynomial
Return the value(s) of the polynomial at r, phi (returns np.NaN if r>1.0) """
""" Return the normalization of the n, m Zernike polynomial
n is the radial order
m is the angular order """ else:
""" Evaluate a Zernike polynomial at a point in Cartesian space.
x and y are the Cartesian coordinaes (either scalars or arrays)
n is the radial order of the polynomial
m is the angular order of the polynomial
Return the value(s) of the polynomial at x, y (returns np.NaN if sqrt(x**2+y**2)>1.0) """ # since we use np.where to handle r==0 cases, # use np.errstate to temporarily turn off the # divide by zero and invalid double scalar # RuntimeWarnings |