Replies: 3 comments 16 replies
-
I cannot attach zmx files to GitHub discussions. If you want to inspect the OpticStudio model, let me know and I'll send it in a different way. |
Beta Was this translation helpful? Give feedback.
-
Hi @crnh, Thanks for opening this and for the clear description. I believe the difference here simply comes down to definitions. If you closely follow the logic of the FFT PSF calculation in Without access to the internals of OpticStudio, I suspect it will be difficult to debug this fully. Nonetheless, I assume the difference is related only to this padding step, as all other calculation steps should be the same. Playing with the In any case, I am not opposed to changing the behavior of the PSF calculation if you want to make a proposal. Padding the pupils will be required, but perhaps the Regards, |
Beta Was this translation helpful? Give feedback.
-
I tried to replicate OpticStudio sampling behavior in Optiland, which seems doable.
Which results in the following 'effective pupil samplings': Furthermore, the grid size is doubled after adjusting the pupil sampling:
If I interpret this correctly, it should be fairly straightforward to calculate the effective pupil sampling (i.e. number or rays) that should be used by Optiland. This function replicates the table in OpticStudio's documentation: def effective_pupil_sampling(pupil_sampling: int) -> int:
return np.floor(32 * np.sqrt(2) ** (np.log2(pupil_sampling) - 5)).astype(int) There is a slight problem with the current padding implementation in Optiland: it adds the same amount of zeros on both sides of the pupil. If the difference between the effective pupil sampling and the grid size is odd (e.g. when the pupil sampling is 64, def _pad_pupils(self):
pupils_padded = []
for pupil in self.pupils:
padded = np.zeros((self.grid_size, self.grid_size), dtype=pupil.dtype)
center = self.grid_size // 2
padded[
center - pupil.shape[0] // 2 : center + pupil.shape[0] // 2 + pupil.shape[0] % 2,
center - pupil.shape[1] // 2 : center + pupil.shape[1] // 2 + pupil.shape[1] % 2,
] = pupil
pupils_padded.append(padded)
return pupils_padded Here are a few comparisons for different samplings: Observations:
Do you have any ideas where the differences may come from? Could it be differences in the sampling method (the table in OpticStudio's documentation mentions the 'approximate effective pupil sampling', suggesting that OpticStudio may use a non-integer pupil sampling)? Or could there be differences between the wavefronts used to calculate the PSFs? Regarding Optiland's PSF implementation, I think there are two viable options:
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I am trying to understand the parameters of
optiland.psf.FFTPSF
and obtain results similar to the FFT PSF in OpticStudio.OpticStudio's FFT PSF has two sampling parameters: the pupil sampling and the 'display' sampling.
The pupil sampling determines the sampling grid at the pupil, and the display sampling the output grid size.
The display sampling can be up to twice the pupil sampling, e.g. with a pupil sampling of 32x32, the maximum possible display sampling is 64x64.
I thought Optiland's
num_rays
corresponds to the pupil sampling and thegrid_size
to the display sampling, but this does not yield the expected results.As an example, I created the same eye model in OpticStudio and Optiland (see attached zmx and JSON files). Many outputs, including ray tracing and Zernike standard coefficients, are the same for these two models, so the PSF differences are unlikely to stem from model differences.
OpticStudio result for pupil sampling of 32x32, display sampling of 32x32:
OpticStudio result for pupil sampling of 32x32, display sampling of 64x64:
Optiland result for pupil sampling of 32x32, display sampling of 32x32:
Optiland result for pupil sampling of 32x32, display sampling of 64x64:
The Optiland results are obtained through the
FFTPSF.psf
property, to circumvent the cropping and interpolation performed byFFTPSF.view
.The extent of the Optiland PSF output is also much larger than the extent of the OpticStudio output (
FFTPSF._get_psf_units
yields 383 x 383 for the result with pupil sampling of 32x32, display sampling of 32x32, which is considerably larger than the 160 x 160 for the corresponding OpticStudio result).Can you help me figuring out which settings to use to reproduce the OpticStudio result in Optiland?
model.json
Beta Was this translation helpful? Give feedback.
All reactions