When calculating the FFT PSF, I sometimes get the error message 'Computation aborted, invalid results'. When I change the PSF sampling, the error disappears. It is probably linked to a user defined surface (based on the multizone asphere surface example) combined with specific values of decentrations of the optical elements.
Do you have any ideas about the meaning of the error-message and how to debug it / get rid of it?
I am saving the FFT PSF window within a ZPL macro. Is there a way to do error-handling in the ZPL macro? (E.g. if the error occurs, the sampling of the FFT PSF calculation will be decreased and the calculation repeated...)
Hi again, Simon!
It sounds like it might be an issue of the analysis not completing in time for the text export to occur. Do you happen to have a PAUSE command in your macro anywhere? Using something like PAUSE THREADS will pause macro execution until all open windows complete their analysis (from our Help File pages at 'The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > PAUSE'):
Please let us know if this helps! Otherwise, we might have to take a closer look at your ZPL construction and provide additional feedback that way.
Second, I realized that you had a somewhat-related question on needing some specific PSF Image Delta. As we discussed, the Image Delta for the FFT PSF is going to be fundamentally related to the sampling of the pupil. However, if you eventually turn toward the Huygens PSF, the approach taken in that computation is much more general as we evaluate the PSF at the Image plane based on the rays that arrive at the surface (as opposed to taking the FFT of the Wavefront Map for FFT PSF). Since we don't perform a fourier transform, the Image Delta can be arbitrary in value. For more information, you can take a look at the following article. Just for your information!
I am having other difficulties with the saved FFT PSF: Sometimes it only contains the header and NAN values. When I redo the same calculation, the PSF gets exported as it should be.
Any ideas, how this can be avoided?
thank you very much for the in-depth answer.
Yes, I have defined an image delta for the PSF calculation. Sounds to me that an incompatibility of my image delta with the pupil sampling might be a cause of this error. If I set image delta= 0, the computation works find. However, in the end I will need a fixed value here to facilitate further evaluation on the PSF-output.
I have incoorporated the error-handling using the GETTEXTFILE. If the first line reads 'Computation aborted; invalid results!' OR 'Sampling too low, data inaccurate', I redo the computation with higher sampling.
There are a few reasons why this error message could appear. It's hard to say without seeing your file, but some prelimary thoughts are:
1) There could be some issues with level of aberrations at certain samplings of your pupil. Since the FFT PSF is going to be generated based on your Wavefront Map data, if there are significant levels of aberration/rapid changes in the data, the fourier transform will have some difficulty computing. Interestly, I think I've usually seen that increasing the sampling would remedy this, but it might be that decreasing the Pupil Sampling is also sidestepping this.
2) Do you have an Image Delta defined in your FFT PSF window? I have seen cases where some inputs for Image Delta would become incompatible with your Pupil Sampling setting. The issue is related to the fourier transform computation -- to create the desired sampling of the PSF on the Image plane, the grid used to sample the pupil must be scaled appropriately (the more distance between points in the pupil plane will result in less distance between points on the image plane). So, what can happen is that specifc settings of the Image Delta results in a scaled pupil grid that either does not have enough sampling points within the pupil (it is stretched too wide on the pupil) or that the sampling grid is too small to account for the full pupil. Some additonal discussion is in our Help Files at 'The Analyze Tab (sequential ui mode) > Image Quality Group > PSF > FFT PSF':
As for performing some error handling, the only way I can think to do this with the FFT PSF window itself would be to attempt to parse the text data tab using GETTEXTFILE. If your Text Tab for the FFT PSF returns as 'Computation aborted; invalid results!', then you know that you would need to adjust the settings of the PSF.
Alternatively, since you are using the FFT PSF specifically, you could also use the GETPSF keyword. This will run the FFT PSF with your specific inputs and places the data in VEC# vectors:
The benefit in this keyword is that the first element (vector position 0) will return either the size of the array or an error code if the computation could not be performed:
So, there are a few approaches you could take in running the PSF and seeing if there is an error in the computation prior to saving the data. You can find the above documentation on GETPSF in our Help Files at 'The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > GETPSF'.
Let us know how these thoughts work out for you! If you think your question requires a bit more detail specific for your system, you could either share that file here in the forums or create a case with us to keep it private. Thanks!