Skip to main content
Solved

How to retrieve specific data from Physical Optics Propagation with API?


Mo.
  • Student
  • 2 replies

Hey,

i want to retrieve data from POP with the API (in python). As far as i got i understand that the pop_analysis.GetResult() is delivering a matrix, like the one you get from the text tab in POP. So far so good. But I don’t know how to get the index for peak irradiance or any other certain value. So, can anybody help me to retrieve the peak irradiance value from that matrix? I’d really appreciate any help that would lead me to a solution. There seem to be some options like “IndexOf”, “FindIndex”, but I don’t know how to use them. My code for that section so far:

pop_analysis = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.PhysicalOpticsPropagation)
pop_analysis.ApplyAndWaitForCompletion()
pop_results = pop_analysis.GetResults()
matrixData = pop_results.GetDataGrid(0).Values

Thanks,

Mo

Best answer by Allie

Hi @Mo. 

When you use GetResults(), an interface containing a few objects is returned. I have discussed this in more detail here: 

 

The Peak Irradiance is given as part of the POP HeaderData object. In Python, you can extract it with the following:

 

pop = TheSystem.Analyses.Get_AnalysisAtIndex(4)
results = pop.GetResults()
header = results.HeaderData
irradiance = header.Lines[6]

 

That is a quick way to get the Peak Irradiance value. If you want both the Peak Irradiance and its location within the data matrix, you can use the index and max commands that Python provides to parse through your matrixData object. In order to use those two commands, you will need to convert your matrixData object from a System.Double[,] matrix to a Python array. You can do this with the list command. For example:

 

 

In my code, data was defined in the same way as your matrixData variable. Note: if you are using the Python boilerplate we provide, then the reshape function will perform the conversion for you. 

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

2 replies

Allie
Zemax Staff
Forum|alt.badge.img+2
  • Zemax Staff
  • 343 replies
  • Answer
  • April 26, 2022

Hi @Mo. 

When you use GetResults(), an interface containing a few objects is returned. I have discussed this in more detail here: 

 

The Peak Irradiance is given as part of the POP HeaderData object. In Python, you can extract it with the following:

 

pop = TheSystem.Analyses.Get_AnalysisAtIndex(4)
results = pop.GetResults()
header = results.HeaderData
irradiance = header.Lines[6]

 

That is a quick way to get the Peak Irradiance value. If you want both the Peak Irradiance and its location within the data matrix, you can use the index and max commands that Python provides to parse through your matrixData object. In order to use those two commands, you will need to convert your matrixData object from a System.Double[,] matrix to a Python array. You can do this with the list command. For example:

 

 

In my code, data was defined in the same way as your matrixData variable. Note: if you are using the Python boilerplate we provide, then the reshape function will perform the conversion for you. 


Mo.
  • Author
  • Student
  • 2 replies
  • April 28, 2022

Thank you very much @Allie !


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