Skip to main content

I'm trying to figure out a way to pull the text data generated by the Polarization Pupil Map analysis tool in OpticStudio into python using the ZOS-API Interactive Extension so that I don't need to download text files. Does anyone know how to do this?





 

Hi Jaren,



This worked for me on Windows (path) with an Interactive Extension, let me know if it gives you what you need. I forgot to mention, it should create the text file in your sample directiory as defined in the OpticStudio settings.



Take care, David





# Create a Polarization Pupil Map analysis


MyPolarizationPupilMap = TheSystem.Analyses.New_Analysis(ZOSAPI.Analysis.AnalysisIDM.PolarizationPupilMap)



# Check the implementation status of this analysis feature in the ZOSAPI


print('Does Polarization Pupil Map have fully-implemented settings?', MyPolarizationPupilMap.HasAnalysisSpecificSettings)



# This means the settings needs to be accessed through IAS_.ModifySettings (see Example 17 in the ZOSAPI Syntax Help)



# Retrieve Polarization Pupil Map results


MyPolarizationResults = MyPolarizationPupilMap.GetResults()



# Save results as text file


MyFileName = 'PolarizationPupilMapResults.txt'


if MyPolarizationResults.GetTextFile(TheApplication.SamplesDir + '\\' + MyFileName):


    print('Text file created successfully')




Thank you for this discussion.  Is there a way to access the data from the pupil map directly without creating a separate text file?  For example, could I just take the results and then create a numpy array with the pupil location and electric fields and phase.  Or do I need to create a text file and then load this into python to create the array?


Hi Scott,

 

Last time I checked, the Polarization Pupil Map wasn’t fully implemented into the ZOS-API. Therefore, you have to create the intermediate text file. Some analysis are partially implemented, meaning you can read an array directly, or edit the settings directly from the ZOS-API, some analysis are fully implemented, meaning you can do everything from within the ZOS-API. The developers are constantly implementing theses features, but I guess they prioritze the most utilized analysis features first.

If you want to know more about what status is a particular analysis, have a look at this article. Although, I wasn’t able to run the code as it is documented now (I think it uses an old boilerplate template), the method described there are generally valid (in some rare instances, an analysis, like RMS vs Field, might return a DataGrid or DataSeries although it is empty...).

Take care,

 

David


Reply