Skip to main content

I’m doing Monte Carlo analysis and I also need the POP encircled energy of each trial. I get POP graph that is actually 200 overlaid encircled energy of all the trials. How can I get the raw data of this bundle of graphs?

Hi @AsafPe,

 

As far as I’ve tried, there’s no direct way to access this data, and it seems to be a visualization feature only.

In my opinion, there are several ways to circumvent this limitation depending on your particular case.

General solution

The most general solution would be to perform the tolerancing with the ZOS-API instead of using the built-in tool. In short, within the ZOS-API, you would perturb your system, refresh the encircled energy analysis, save the data, and so on… That being said, it might be the heaviest solution to implement.

ZPL macro operand in Merit Function

If you want to stay away from the ZOS-API, assuming you are not using the Merit Function for your tolerancing, you can create a ZPL macro operand, which uses GETTEXTFILE to create a text file data for every run. The ZPL macro operand looks like so:

# Folder where the data is saved
folder$ = "E:\Overlay_test\"

# Temporary filename for each run
# (not sure how many unique filenames
# can be created in this way!)
filename$ = $TEMPFILENAME()
filename$ = $RIGHTSTRING(filename$, 11)

# Full path to file
saveto$ = folder$ + filename$

# Save analysis data to text file
GETTEXTFILE saveto$, Enc

# Return dummy operand value
OPTRETURN 0, 1.23

As you can see, this operand uses $TEMPFILENAME to create a temporary file name and save the diffraction encircled energy into that file. Note that I don’t know how many unique filenames $TEMPFILENAME can create, but I think you’ll be alright with your 200 runs. You could then have a simple Merit Function like so:

where you’d replace Mac# by whatever number suit you (remember ZPLM operands must be named ZPLXX.ZPL, with XX being a 2-digit integer that corresponds to the Mac# in the ZPLM operand). This means everytime the Merit Function is calculated, it will produce a text file of the Diffraciton Encircled Energy. Finally, if you run your Tolerancing like so:

meaning that for every run, you only do one calculation of the Merit Function, you would produce one text file. I’ve tried this and it seems to work for a few runs for me. Note that you will get more text file than Monte-Carlo runs and this is because the Merit Function might also be run twice for every tolerance operand in the sensitivity analysis, and an extra time for the nominal calculation!

Now, I hear you say: “but I’m actually using the Merit Function in my tolerancing”. Well, that might still be ok if you use a Tolerance Script instead, but of course things get a little bit more complicated. Instead of the Merit Function, you could use a User Script, in that script you could make use of two Merit Functions that you will have saved beforehand. One Merit Function is the one you use to optimize your run, and the other one is the one I documented here to save the resulting Diffraction Encircled Energy. In a tolerance script, you can use the commands LOADMERIT to load the Merit Functions, and OPTIMIZE to run a certain number of optimization cycle (0 meaning automatic number of cycles). This is a bit more heavy and we might have to tweak this method specifically to your file. If you share a simple example with me, I can help you investigate whether it would be feasible this way.

I hope it helps, and take care,

 

PS: of course, you then have to use a method of your choice to parse the text files

 

David

 


Reply