-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add Wyant/fringe ordered Zernike basis functions too #236
base: master
Are you sure you want to change the base?
Conversation
@kvangorkom This PR may be of interest to you. (but definitely feel free to completely ignore this if you're getting busy with other things and don't feel like looking at this now!) |
I put together some code a few months ago to do something very similar! I managed to cobble together an algorithm to map Fringe j -> (n, m) (and the inverse), but there's definitely room for improvement. You're welcome to adapt what I have (or else I can when I get the chance): https://github.com/kvangorkom/zernike/blob/master/zernike.py One thought from looking at your implementation: Fringe Zernikes, in my experience, tend not to be Noll normalized. There's probably room to argue this, but I wonder if it might be better to disable the normalization implicit in |
oh nice! I figured there had to be an algorithmic way to do that mapping rather than my hack of a lookup table. I will look at merging in your code for that. Thanks much!
That's not a "woops", that's specifically some of the feedback I was hoping for from you. 👍 Also I see your code has piston starting as index 1 as opposed to index 0. I wasn't sure what to do about that - I saw different starting indices in different references. Sigh. |
I've seen both index 1 and index 0, and I'm not sure there's a preferred convention. (I believe both Zemax and CodeV adopt 1, but 4D's 4Sight adopts 0). I suspect being explicit about it is the only way to handle it. Another complication (which you're likely already aware of) is that Wyant adopts a completely different (n, m) convention (see here). These map onto your (r, l) terms, but my impression is that it's not uncommon to generate Fringe zernikes based on Wyant (n, m, sin/cos) inputs. Robert Gray's MATLAB library handles it this way. I don't know if it's worth attempting to tackle this complication. |
Adds functions for getting Zernike polynomial indices and Zernike basis sets using the so-called fringe or Wyant ordering of the Zernike polynomials. I think I've got this right, but gaaah the literature on this is an inconsistent mess.
Same functionality as the existing Noll-ordering-based code (which this is calling behind the scenes); this just has the polynomials in a different ordering.
For now the polynomials are using the same scaling coefficients as the Noll indices, but I'm not sure if that's the correct thing to do, since Wyant himself has these on his web page without any scaling coefficients (see http://wyant.optics.arizona.edu/zernikes/zernikes.htm)
Could use some review, and still needs unit tests before merging.