Solved

OPENANALYSIS before GETTEXTFILE?

  • 13 September 2022
  • 3 replies
  • 163 views

Userlevel 5
Badge +3

The documentation is unclear to me: does GETTEXTFILE initiate the analysis in an existing window, or do I have to always use OPENANALYSISWINDOW before it?

How can I change the reported precision in DETECTOR RECTANGLE text output when it is being used to compute a Huygens PSF?  I need more than three postdecimal digits.

Thanks, Mike

 

icon

Best answer by Mike.Jones 13 September 2022, 17:59

View original

3 replies

Userlevel 6
Badge +2

Hi Mike,

You don’t need to run OPENANALYSISWINDOW before GETTEXTFILE.  Although they both share the same String Code for window naming and the same CFG from the MODIFYSETTINGS keyword, the OPENANALYSISWINDOW is to generate the plot and the GETTEXTFILE is simply to grab the “Text” tab results. 

When using the OPENANALYSISWINDOW, you can also use the numeric function WINN() to get the window number for the plot and then use EXPORTBMP or EXPORTJPG to save the “Graph” tab.  

So, these 2 keywords in combination allow you to get both the graph and the text output.

Unfortunately, just like displaying the text via the GUI, you cannot change the displayed number of digits.  You can either use the ZOS-API & GetResults() to obtain 14 decimal points or you can create a Merit Function if the operand exists.  Below is a Python example to get the Huygens PSF where you can see the output is double precision:

import zosapi, os

# connect to OpticStudio
zos = zosapi.App();

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

# open & run the analysis
win = zos.TheSystem.Analyses.New_Analysis(zos.ZOSAPI.Analysis.AnalysisIDM.HuygensPsf)
win.ApplyAndWaitForCompletion();

# get the results
res = win.GetResults();
data = res.GetDataGrid(0).Values
grid = zos.reshape(data, data.GetLength(0), data.GetLength(1))

# 14 digit accuracy for results
print(grid)

 

Userlevel 5
Badge +3

Thanks, good reply.  I don’t know Python and API yet but this will help me learn.

Another question: I’m in non-sequential mode and have multiple Detector Rectangle windows open, with the Huygens PSF just being one of those windows.  How do I tell GETTEXTDATA which Detector Rectangle to extract the data from?

Userlevel 6
Badge +2

Hi Mike,

You cannot pass a Window Number to the GETTEXTFILE; this keyword uses the saved settings in the DVR.CFG file.  You can change the following settings in the DVR.CFG file using the MODIFYSETTINGS keyword:

  • (surface number if using mixed mode)
  • detector number
  • show data as
  • row/column (for cross section show data as)
  • z-plane (for detector volume)
  • scale
  • smoothing
  • data (either incoherent or coherent illuminance if using with GETTEXTFILE)
  • zrd file name
  • filter string
  • min/max plot values
  • output file name for a saved BMP/JPG

So, you would need to change DVW_DETECTOR value to match the Detector Rectangle number, set the DVW_SHOW to 0 for full text output and DVW_DATA to 1 (coherent) via the MODIFYSETTINGS.

If you don’t already have the PSF Wave # set to 1 via the GUI, you’ll also need to call SETNSCPARAMETER for Par11 and change the value to 1.

Finally, if you’re cycling through different parameters in your system, you’ll need to call NSTR (and probably PAUSE THREAD) before calling GETTEXTFILE in order to re-run a non-sequential trace.

Reply