Skip to main content
Solved

Extracting Strehl Ratio in Huygens PSF with Python ZOS-API

  • September 1, 2022
  • 2 replies
  • 949 views

Alex.Tripsas

I’m working on a code to see how the Strehl ratio of our system changes over different iterations.  I’m trying to extract the Strehl Ratio from the Huygens PSF like in the image below
 

However, I can’t seem to find how I can do this.  Can anyone help?

Best answer by MichaelH

Hi Alex,

If you’ve noticed, the Strehl Ratio is simply the maximum Z value when you have the Normalize box unchecked.  So while you cannot access the HeaderData from the Huygens PSF analysis (Zemax never hooked up this code block), you can simply get the non-normalized data & find the maximum value:

import zosapi, os

zos = zosapi.App()

zos.TheSystem.LoadFile(os.path.join(zos.TheApplication.SamplesDir, r'Sequential\Objectives\Double Gauss 28 degree field.zmx'), False)

# open and run Huygens PSF
win = zos.TheSystem.Analyses.New_Analysis(zos.ZOSAPI.Analysis.AnalysisIDM.HuygensPsf)
ws = win.GetSettings();
ws.Normalize = False;
win.ApplyAndWaitForCompletion()

# get the strehl ratio frm the raw data
wr = win.GetResults();
data = wr.DataGrids[0].Values;
strehl = max(list(data))
print('Strehl ratio: %4.3f' % strehl)

 

 

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

2 replies

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • 355 replies
  • Answer
  • September 1, 2022

Hi Alex,

If you’ve noticed, the Strehl Ratio is simply the maximum Z value when you have the Normalize box unchecked.  So while you cannot access the HeaderData from the Huygens PSF analysis (Zemax never hooked up this code block), you can simply get the non-normalized data & find the maximum value:

import zosapi, os

zos = zosapi.App()

zos.TheSystem.LoadFile(os.path.join(zos.TheApplication.SamplesDir, r'Sequential\Objectives\Double Gauss 28 degree field.zmx'), False)

# open and run Huygens PSF
win = zos.TheSystem.Analyses.New_Analysis(zos.ZOSAPI.Analysis.AnalysisIDM.HuygensPsf)
ws = win.GetSettings();
ws.Normalize = False;
win.ApplyAndWaitForCompletion()

# get the strehl ratio frm the raw data
wr = win.GetResults();
data = wr.DataGrids[0].Values;
strehl = max(list(data))
print('Strehl ratio: %4.3f' % strehl)

 

 


Alex.Tripsas
  • Author
  • Visible
  • 16 replies
  • September 1, 2022

Yep, that is exactly what I was looking for.  Didn’t even think to look at the raw data.  Thank you for sharing your code too.


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