Skip to main content
Solved

ZOS-API raytracing not considering apertures properly

  • October 20, 2022
  • 3 replies
  • 110 views

Sebastian Saman
Forum|alt.badge.img

When I simulate my setup, in MATLAB using the ZOS-API for raytracing, it seems to ignore or improperly account for aperture. I assume I am missing something, but don’t know what, and am looking for help on how to simulate apertures properly with raytracing. Any tips would be appreciated.

 

 

Best answer by David.Nguyen

Hi Sebastian,

 

It’s hard to say without seeing your file, but the ReadNextResult methods often have an integer return parameter called vignetteCode that should tell you whether a ray is vignetted. You can then decide not to plot the rays based on this parameter. The vignetteCode should be zero if the ray isn’t vignetted, otherwise I think it is the surface number at which the ray gets vignetted.

Have a look at example 22 in the ZOS-API Syntax Help, here’s an excerpt of how they read the rays:

while success
    if ((errCode == 0 ) && (vigCode == 0))
        x_ary(field, wave, rayNumber) = x;
        y_ary(field, wave, rayNumber) = y;
    end

As you can see, they ignore the rays whose vigCode (which is the vignetteCode) are non zero.

Hope this helps.

Take care,

 

David

View original
Did this topic help you find an answer to your question?

3 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1134 replies
  • Answer
  • October 20, 2022

Hi Sebastian,

 

It’s hard to say without seeing your file, but the ReadNextResult methods often have an integer return parameter called vignetteCode that should tell you whether a ray is vignetted. You can then decide not to plot the rays based on this parameter. The vignetteCode should be zero if the ray isn’t vignetted, otherwise I think it is the surface number at which the ray gets vignetted.

Have a look at example 22 in the ZOS-API Syntax Help, here’s an excerpt of how they read the rays:

while success
    if ((errCode == 0 ) && (vigCode == 0))
        x_ary(field, wave, rayNumber) = x;
        y_ary(field, wave, rayNumber) = y;
    end

As you can see, they ignore the rays whose vigCode (which is the vignetteCode) are non zero.

Hope this helps.

Take care,

 

David


Sebastian Saman
Forum|alt.badge.img

Thank you David,

Only using rays with no errors and no vignetting worked. Thank you very much.

x = x(0 == rayData.vignetteCode.double & 0 == rayData.errorCode.double);
y = y(0 == rayData.vignetteCode.double & 0 == rayData.errorCode.double);

 


Brian.Catanzaro
Fully Spectral
Forum|alt.badge.img+4

I provided additional details in this post:  link.

Checking the codes will only be useful if you ensure that you only trace rays that are inside the normalized pupil.  If you trace Px=1.0, Py=1.0 it will not throw an error or change the vignette code > 0.

-B


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings