Skip to main content
Solved

Incident angle vs image Height analysis with ZOS API


mocquin

I cannot find in the doc what are the names of the parameters in the API to change the field density and wavelength, especialy in the MODIFYSETTINGS which does not mention this type of analysis

Maybe it is not implemented ?

Also, the analysis results do not exihbit any data: 

print(analysis_results.NumberOfDataGrids)

print(analysis_results.NumberOfDataGridsRgb)

print(analysis_results.NumberOfDataScatterPoints)

print(analysis_results.NumberOfDataScatterPointsRgb)

print(analysis_results.NumberOfDataSeries)

print(analysis_results.NumberOfDataSeriesRgb)

print(analysis_results.NumberOfMessages)

print(analysis_results.NumberOfRayData)

all print 0, so is there a way to retrieve the results from this analysis ?

Best answer by chaasjes

Hi ​@mocquin,

The settings of this analysis are indeed not available through the ZOS-API. You can try to change the settings through a CFG file. ZOSPy also does this in some analyses where not all settings can be modified using the ZOS-API. It is not trivial as it requires reverse-engineering a binary file, but at least it is possible. You can find an example here: https://github.com/MREYE-LUMC/ZOSPy/blob/a776c95395dab96f9069cd58181b0f549f44d48a/zospy/analyses/new/polarization/transmission.py#L93

As for the analysis results, these are also not exposed through data grids, but you can export them to a text file and read that file programmatically. This is the case for many analyses and again ZOSPy's source code may help you with figuring out how to do that.

Hope this helps!

 

View original
Did this topic help you find an answer to your question?

4 replies

chaasjes
Forum|alt.badge.img
  • Visible
  • 33 replies
  • Answer
  • January 20, 2025

Hi ​@mocquin,

The settings of this analysis are indeed not available through the ZOS-API. You can try to change the settings through a CFG file. ZOSPy also does this in some analyses where not all settings can be modified using the ZOS-API. It is not trivial as it requires reverse-engineering a binary file, but at least it is possible. You can find an example here: https://github.com/MREYE-LUMC/ZOSPy/blob/a776c95395dab96f9069cd58181b0f549f44d48a/zospy/analyses/new/polarization/transmission.py#L93

As for the analysis results, these are also not exposed through data grids, but you can export them to a text file and read that file programmatically. This is the case for many analyses and again ZOSPy's source code may help you with figuring out how to do that.

Hope this helps!

 


mocquin
  • Author
  • Infrared
  • 9 replies
  • January 27, 2025

Hi ​@chaasjes 

 

thanks for you reply. For now I am getting familiar with the ZOSAPI, I’ll take a look at Zospy in the process.

I’m curious as how do you reverse-engineer the binary file ? Since it doesn’t seem to hold much logic or secret recipe, I’m wondering why CFG files are not just plain text files (json or yaml or like)

Kind of a bummer that not all analyses are available in the base API… having to workaround with writing and reading a text file feels ugly...


chaasjes
Forum|alt.badge.img
  • Visible
  • 33 replies
  • January 27, 2025

I’m curious as how do you reverse-engineer the binary file ? Since it doesn’t seem to hold much logic or secret recipe, I’m wondering why CFG files are not just plain text files (json or yaml or like)

The contents are basically just a binary array of numbers. The index and number of bytes for each setting you'll have to find out by trial and error, just change a byte and check what settings change in OpticStudio and how they change. I don't need to do this often (in the end, that's one of the reasons why I use ZOSPy) so the linked example in the ZOSPy code will give you more details than I can give off the top of my head right now.

Kind of a bummer that not all analyses are available in the base API… having to workaround with writing and reading a text file feels ugly...

I agree, but neither of the alternatives (waiting for Ansys to improve the ZOS-API support for analysis settings and results) are better than what we have now...

 


The index and number of bytes for each setting you'll have to find out by trial and error, just change a byte and check what settings change in OpticStudio and how they change.

 

If you just want to alter one specific setting this way, it might be quickest to save different configuration files that only differ in that one setting, and then compare the byte arrays. That should be slightly less cumbersome. However, if you already have all the settings files you need, you might as well load them using Settings.LoadFrom() rather than altering byte arrays.

 

If you have an implementation of this analysis, please also consider adding it to ZOSPy. This way others might also benefit from it!


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings