Closed jmeyers314 closed 6 years ago
just so I have this right, because I think I have a version of doing this that I could add to galsim:
if the wavefront W(rho, phi) = sum_i a_i Z_i(rho, phi), you want:
dW/dx (rho, phi) = sum_i b^x_i Z_i(rho, phi) (and dW/dy, too)
where bi = gamma^x{ij} a_j (ie a matrix multiplication).
I also have code that takes a_i Z_i * a_j Z_j = sum_k b_k Z_k (ie zernike multiplication), which I have found is super useful for simplifying products of derivatives of zernikes
Yeah, I think that looks right. Does your code happen to apply to both circular and annular Zernikes, by chance?
I have put very little thought into annular zernikes. All I really do with the code is implement noll's instructions for how to get the derivatives of the zernikes. So if the recursion relations are different for annulars, then it won't work.
I guess we can try it and see!
I still think it may be worth thinking about whether OpticalScreen.coef_array can be used directly (which may be faster than generating new Zernike coefficients(?), and should definitely work for both circular and annular Zernikes). In that case though, your code would still be useful in a unit test.
Merge via PR #962
During the DESC hack week, I implemented photon shooting for optical PSFs by computing finite difference gradients of optical phase screens.
It would probably be faster and more accurate to use an analytic expression for the gradients of Zernike polynomials, however.
This paper shows how to express circular Zernike gradients as Zernike polynomials with different coefficients, though it may also be possible to compute the derivatives directly from OpticalScreen.coef_array, which would then apply to both circular and annular Zernikes.