I have a python program that finds the shifts in the position of spots (consider it as focused spots). I want to connect my python program with Zemax (Through Interactive Extension script)
My question is, how do I connect specific feature (Say- Geometrical I mage analysis or Spot diagram) with python? Also, is there any changes I should be making in my python code, to connect with these Zemax features?
In OpticStudio you can navigate to Programming..ZOS-API Help..ZOS-API Syntax Help, you can then navitage to the Examples section, which shows a variety of uses for the ZOS-API, most of them available in Python
I’d like to also mention ZOSPy:
which is built on top of the ZOS-API, and enables more Pythonic access to OpticStudio.
The only Python requirement is the Pythonnet module, and you might want to be aware of this issue:
Now more specificaly, if you want interact with an analysis using the ZOS-API Interactive Extension, its important to assess the state of implementation of this analysis. There are mainly two things to checks.
First, analyses have a property called HasAnalysisSpecificSettings, which indicates whether you can modify the settings of said analysis directly from the ZOS-API (instead of going through a settings file). You can do it for a geometric image analysis:
and it will return True. This indicates that the geometric image analysis settings have been fully implemented in the ZOS-API. You can fill the full list of settings in the Syntax Help File, but I’m also copying them here for your reference:
Second, you need to check how to retrieve the results of the analysis. For that, you need to check what is returned by the GetResults() method. But, for geometric image analysis, these have not been implemented yet (to the best of my knowledge). Therefore, you need to save the results as a text file and parse it. You can save the results as a text file like so:
This creates a text file that contains the results of geometric image analysis, and then you can use Python to parse it and retrieve it in a Numpy array for example.
I hope this helps.
Take care,
David
Thanks David, this is useful. Let me try this out.