Zemax API - Huygens PSF Output not matching TXT file
Hi everyone,
I created a Matlab script which can both output the results txt file via ‘GetTextFile’ and read the results of a Huygens PSF analysis directly. The problem is that these do not match.
Excerpt from my code:
newWin = TheSystem.Analyses.New_HuygensPsf();
...
newWin.ApplyAndWaitForCompletion();
newWin_Results = newWin.GetResults();
data = newWin_Results.DataGrids(1).Values.double;
newWin_Results.GetTextFile(outFolder)
Txt File Data Snippet:
data variable above snippet:
Is “DataGrids(1).Values.double;” the proper way to extract this information from GetResults? The text file also matches what standalone OpticsStudio provides me so I am taking that data to be the truth.
Page 1 / 1
Hi @BeauDiddley,
I can see that you are using:
newWin_Results.DataGrids(1)
Usually, a simple Huygens PSF will return a single DataGrid at index 0. How did you have a second DataGrid at index 1? I’m asking because if the settings are different it could explain the discrepancy.
Take care,
David
@David.Nguyen ,
Thanks for the reply. I believe this would be a case of Matlab indexes start at 1, not 0.
Oh dear, I had completely forgot about this peculiarity of MATLAB. Apologies.
When I try to do it in Python, it seems almost ok for me. But, I have to apply a transpose operation to the values! Also, for some reason, the first line is actually the last line. When I use this snippet in a default lens file:
Can you confirm that you see the same? It could have to do with the Python reshape function in the boilerplate code, I’ll check that.
Take care,
David
@David.Nguyen ,
Haha! Happens to all of us! Transposing via flipud solved the issue for me, but my first line is in the correct spot… weird.
Thanks a lot! My PSFs are pretty symmetric, which made this difficult to diagnose on my own.
@BeauDiddley
I kid you not, I actually spent several minutes trying to understand how you got the one there, asking myself: “how on earth do you get another DataGrid from this analysis?”. Completely oblivious of the MATLAB behaviour...
I think the issue is in my reshape function, I recycled an old one that I had modified. Anyway, happy to hear your are sorted :)