Solved

Pulling Data from the Footprint Diagram

  • 18 February 2021
  • 4 replies
  • 827 views

I have a simple lens diagram where my goal is to decenter one of the two elements, and record the change in the Ray X Center value of the footprint diagram. I have found how to view/change the Decenter X column of the coordinate break using TheSystem.LDE.GetSurfaceAt(2).GetCellAt(12).get_Value() and xx.DoubleValue =. 


Next, I need to pull out the value of Ray X Center from the footprint diagram after propogating the changes made by altering the decenter. Either through grabbing the single value, or even saving the entire footprint diagram text values.


I have found what I believe is the correct location for this data at TheSystem.Analyses.Get_AnalysisAtIndex(2), as xx.get_GetAnalysisName() returns 'FootprintSettings'. I have not yet been able to find a method (through tab completing in PyCharm) that returns the data in any way. 


How can I pull out the footprint diagram information?

icon

Best answer by David.Nguyen 18 February 2021, 11:20

View original

4 replies

Userlevel 7
Badge +2

Hi Dakota,


You can use the Python code below in an Interactive Extension



# Create a Footprint Diagram analysis
FootprintDiagram = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.FootprintSettings)
# Check the implementation status of this analysis feature in the ZOSAPI
print('Does Wavefront Map have fully-implemented settings?', FootprintDiagram.HasAnalysisSpecificSettings)
# This means the settings needs to be accessed through IAS_.ModifySettings (see Example 17 in the ZOSAPI Syntax Help)
# Retrieve Footprint Diagram results
FootprintDiagramResults = FootprintDiagram.GetResults()
# Save results as text file
MyFileName = 'FootprintDiagramResults.txt'
if FootprintDiagramResults.GetTextFile(TheApplication.SamplesDir + '\\' + MyFileName):
print('Text file created successfully')

The Footprint Diagram hasn't been fully implemented yet I believe. This piece of code will write the Text Tab of the Footprint Diagram to a text file named FootprintDiagramResults.txt in the same folder as your lens design.


I leave you to parse that text file for further analysis. Let me know if you don't manage to do it.


Let me know if this helps.


Take care,


David

Hi David, 


Thank you so much for your answer, it was exactly what I needed. I now have all the footprint diagram data files to access, and Pandas can take it from here. Your help is very appreciated! Out of curiosity, how did you know where to look? The documentation didn't have much that seemed useful when I searched it fairly exhaustively. 


Best,


Dakota

Userlevel 5
Badge +2

Hello All,

Thanks for your posts here!

Dakota, if you would like to pull data from the analysis windows, then you need to know in which format the data is stored in the IAR_ Interface. The output data is split into multiple categories within the interface based on its type. A matrix of data will typically be provided as a DataGrid, while a 2 column list of data will be provided by a DataSeries. Sometimes, analysis window results are not pulled into the API, in which case the data must be pulled into an external text file using GetTextFile.

 

This knowledgebase article explains how to use Python or MATLAB to generate a list of available data types (IAR types) for each analysis in the ZOS-API:

 

Generating a list of output data types for each analysis in the ZOS-API · MyZemax

 

From here we can see that for the Footprint diagram no DataSeries and no DataGrid is available, which means that for this analysis we need to use GetTextFile as David showed.

 

You may find more information about how to pull the text data from the API in this forum thread:

 

 

Best,

Csilla

 

Userlevel 7
Badge +2

Hi Csilla, and Dakota,


Thanks for sharing those resources Csilla.


To answer Dakota's question, I would say that having worked at Zemax is a great help in finding what I need in the ZOS-API. Perhaps, this is what I can recommend. First, my primary source of information is the ZOS-API Syntax Help, which you can open from Programming...ZOS-API Help...ZOS-API Syntax Help. It might be difficult to read at first, but its structure is consitent, and once you know how to navigate it, it becomes less of a hassle. If you know a little bit about object-oriented programming (OOP), it can further help you read this documentation. Second, if you know you want details about a particular analysis, you have to remember that those are part of the optical system. Therefore, in the main page of the syntax help, under Getting Started, you can click ZOSAPI.IOpticalSystem (this is often named TheSystem in interactive extensions, and stand-alone templates). There you have all the properties, and methods of your optical system, and one of the method is called Analyses. The important trick here, is to not click on Analyses, because it'll just take you to the description of the method. What you need to do is click on I_Analyses on the left of Analyses. This is the return type, and it is the main object, which describes all the analyses windows in OpticStudio.


When you are on this page (ZOSAPI.Analysis.I_Analyses Interface Reference), you have all the methods to call an analysis. Some of them, you'd call with a specific method, if it exist, like for example, the Grid Distortion:



TheSystem.Analyses.New_GridDistortion()

Those that are not implemented, such as the Footprint Diagram, can be called with the method I showed you:



TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.FootprintSettings)

At this point, you might ask how do you know the name to feed this function. If you look under the method New_Analysis, you see that it takes a single argument, and this is an AnalysisIDM type of object. You can click on this type, and you'll be brought to the complete list of available analysis.


Then, you need to verify whether the settings have been implemented (otherwise you need to use setting files, and that's not so good in my opinion), and also, in which format is the resulting data. If you click on the return type IA_, this is the object for a particular analysis window, you should see it has two methods GetSettings(), and GetResults(). If you click on the return types of those methods: IAS_, and IAR_, you'll have the methods to read the results, and change the settings, if available.


I've been rambling a lot, but I hope this can help you. Again, a little bit of knowledge about OOP is helpful in this regard.


Take care,


David

Reply