Open yohann95 opened 2 months ago
Hi Yohann,
Yes, you can control the center of the reference sphere in ray-optics. The analyses module has the class RayGrid whose main purpose is to compute grid sampled wavefronts.
RayGrid
has several attributes used to determine the center of the reference sphere. The eval_wavefront() function in the analyses
module traces the ray grid through the current optical model and returns a grid of opd
values.
There is another way to compute wavefronts with RayGrid. This separates the process into:
This allows the (potentially very compute intensive) ray trace to be done once, while evaluating the wavefront with different amounts of image tilt and defocus is quick enough to allow interactive changes to be displayed in a jupyter notebook. The wavefront notebook is in the ray-optics-notebooks repo.
The slider_update() function in create_focus_dashboard shows how the UI can be hooked up to do this.
Some pseudo-code demonstrating the idea follows:
ray_grid.foc = z offset from the last/image interface
ray_grid.image_pt_2d = base image point, x, y, referenced to the defocused image surface
ray_grid.update_data(build='rebuild') # this traces the rays
for dfoc_val in range of focus values
ray_grid.foc = dfoc_val
ray_grid.image_delta = np.array([dx, dy]) # this is an (optional) delta from image_pt_2d
ray_grid.update_data(build='update') # calculate wavefront wrt new reference point
Display of data from a RayGrid
can be done with the Wavefront class in the analysisfigure module.
Feel free to ask questions about any of this.
Thanks! Mike
Edit: for clarity
Hello Mike, When I compare the Zernike decomposition for the wavefront got by Oslo and ray-optics, I find a mismatch. Oslo gives directly the Zernike coefficients (in wave unit and not normalized). I get them through ray-optics calculating the projections myself, using the functions _wave_abr_fullcalc then _sm.tracegrid to get the wavefront. Specially, there is a mismatch for the tilt ( Z(x,y)=2x or 2y ). It is nearly zero in Oslo and not in ray-optics. I have tracked a bit the problem and I think this is because the reference sphere is centred at the intersection of the image plan with the optical axis and not with the emerging chief ray. Am I correct ? If yes, how can I change the center of the reference sphere ? Thanks in advance, Yohann