Solved

Accessing Polarization Analysis features using the ZOSAPI

  • 18 December 2020
  • 3 replies
  • 168 views

Badge +1

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?



 

icon

Best answer by David.Nguyen 3 November 2021, 14:39

View original

3 replies

Userlevel 7
Badge +2

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?

Userlevel 7
Badge +2

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