opticspy / lightpipes

LightPipes for Python, "Pure Python version"
https://opticspy.github.io/lightpipes/
BSD 3-Clause "New" or "Revised" License
227 stars 52 forks source link

Sending a Gaussian beam with aberrations through Shack Hartmann #41

Open pytesnim opened 4 years ago

pytesnim commented 4 years ago

Hello, I was wondering if there is a way to focus a Gaussian Beam with aberrations onto SH-WFS and finding the intensity distributions at the focus of the lenses? It seems at the current version of Lightpipes, set of individual fields are propagated through the lenses of the sensor and then Zernike functions are applied. That doesn't make any sense to me. Thanks very much!

ldoyle commented 4 years ago

Hello Tess,

are you referring to Fred's example in Examples/Zernike/Shack_HartmannDemo[2...3].py? As you can see from the plots, the examples work and create the expected abberated patterns. What might be confusing, esp. in the first demo, is that the field at the plane of the sensor is stored in F, while Forvard is applied and stored as a new variable F1 and the Zernike aberration is only applied and propagated in F2, which is never plotted. So maybe the "plot2" and "plot3" examples are more instructive.

However in all cases, the order of commands has the correct outcome:

In the same plane, e.g. the plane of the microlens array, the order of phase/intensity modulations is physically irrelevant as they are complex multiplications. So applying the phase shift due to the microlens first or the aberration first has the same outcome. You can plot the unwrapped phase after applying the microlens pattern and Zernike aberration, but before propagation.

So much for the example code. In your use case, it sounds like you would like to use an arbitrary input field and then apply the microlens array, which probably makes more sense in everday applications. This can still be done. The quickest way I can think of is to construct the Shack-Hartmann field like the example, with an unaberrated beam. Then, you can save the intensity distribution and (wrapped) phase in two variables, and use MultPhase and MultIntensity on your actual field to simulate the effect of the microlens array. A final Fresnel(F, f_microlenses) should then give you the expected distribution on the camera.

Let us know if this helps, maybe I can create an example with the method I described if you get stuck.