Solved

Extracting Strehl Ratio in Huygens PSF with Python ZOS-API

  • 1 September 2022
  • 2 replies
  • 552 views

Userlevel 1

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?

icon

Best answer by MichaelH 1 September 2022, 23:37

View original

2 replies

Userlevel 6
Badge +2

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)

 

 

Userlevel 1

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