def cached_zernike1(j, shape, pixelscale, pupil_radius, outside=np.nan, noll_normalize=True): """Compute Zernike based on Noll index *j*, using an LRU cache for efficiency. Refer to the `zernike1` docstring for details. Note: all arguents should be plain ints, tuples, floats etc rather than Astropy Quantities. """ y, x = Wavefront.pupil_coordinates(shape, pixelscale) r = np.sqrt(x**2 + y**2) rho = r / pupil_radius theta = np.arctan2(y / pupil_radius, x / pupil_radius) n, m = noll_indices(j) result = zernike(n, m, rho=rho, theta=theta, outside=outside, noll_normalize=noll_normalize) result.flags.writeable = False # don't let caller modify cached copy in-place return result
def cached_zernike1(j, shape, pixelscale, pupil_radius, outside=np.nan, noll_normalize=True): """Compute Zernike based on Noll index *j*, using an LRU cache for efficiency. Refer to the `zernike1` docstring for details. """ y, x = Wavefront.pupil_coordinates(shape, pixelscale) r = np.sqrt(x ** 2 + y ** 2) rho = r / pupil_radius theta = np.arctan2(y / pupil_radius, x / pupil_radius) n, m = noll_indices(j) result = zernike(n, m, rho=rho, theta=theta, outside=outside, noll_normalize=noll_normalize) result.flags.writeable = False # don't let caller modify cached copy in-place return result