Skip to main content
Solved

MODIFTSETTINGS type codes for geometric MTF

  • February 17, 2023
  • 5 replies
  • 202 views

harry000k

Type codes for modifysettings are listed in the Zemax help files under: The Programming Tab > About the ZPL > KEYWORDS (about the zpl) > MODIFYSETTINGS (keywords) 

However, Geometric MTF is not listed here. My question is: what are the type codes for the geometric MTF analysis window?

In case these do not exist, how would I go about modifying the settings for the geometric MTF analysis window via ZOSAPI?

Best answer by David.Nguyen

Hi harry,

 

If those codes are not in available in MODIFYSETTINGS, I doubt you’ll be able to do it in ZPL.

The first thing to do to check how the settings of an analysis in the ZOS-API can be modified is to check the HasAnalysisSpecificSettings property. If you run the code below (Python):

# New Geometric MTF Analysis
geo_mtf = TheSystem.Analyses.New_GeometricMtf()

# Check if settings are implemented
if geo_mtf.HasAnalysisSpecificSettings:
    print('Geometric MTF has its settings implemented in the ZOS-API')

You should get the following result:

Geometric MTF has its settings implemented in the ZOS-API

What this means is that the settings of Geometric MTF are directly available from the ZOS-API. You can find them in the ZOS-API Syntax Help (ZOSAPI.Analysis.Settings.Mtf.IAS_GeometricMtf Interface Reference):

Properties

IAS_Field  Field [get]
IAS_Wavelength  Wavelength [get]
SampleSizes  SampleSize [get, set]
bool  MultiplyByDiffractionLimit [get, set]
bool  ScatterRays [get, set]
bool  UseDashes [get, set]
bool  UsePolarization [get, set]
double  MaximumFrequency [get, set]

This is a small Python example for you:

# New Geometric MTF Analysis
geo_mtf = TheSystem.Analyses.New_GeometricMtf()

# Get settings of analysis
geo_mtf_set = geo_mtf.GetSettings()

# Modify wield
field = 1
geo_mtf_set.Field.SetFieldNumber(field)

# Modify wavlenegth
wave = 1
geo_mtf_set.Wavelength.SetWavelengthNumber(wave)

# Modify sampling
sampling = ZOSAPI.Analysis.SampleSizes.S_32x32
geo_mtf_set.SampleSize = sampling

# Use polarization
geo_mtf_set.UsePolarization = True

# Apply settings
geo_mtf.ApplyAndWaitForCompletion()

I hope this helps, and take care,

 

David

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

5 replies

David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1089 replies
  • Answer
  • February 17, 2023

Hi harry,

 

If those codes are not in available in MODIFYSETTINGS, I doubt you’ll be able to do it in ZPL.

The first thing to do to check how the settings of an analysis in the ZOS-API can be modified is to check the HasAnalysisSpecificSettings property. If you run the code below (Python):

# New Geometric MTF Analysis
geo_mtf = TheSystem.Analyses.New_GeometricMtf()

# Check if settings are implemented
if geo_mtf.HasAnalysisSpecificSettings:
    print('Geometric MTF has its settings implemented in the ZOS-API')

You should get the following result:

Geometric MTF has its settings implemented in the ZOS-API

What this means is that the settings of Geometric MTF are directly available from the ZOS-API. You can find them in the ZOS-API Syntax Help (ZOSAPI.Analysis.Settings.Mtf.IAS_GeometricMtf Interface Reference):

Properties

IAS_Field  Field [get]
IAS_Wavelength  Wavelength [get]
SampleSizes  SampleSize [get, set]
bool  MultiplyByDiffractionLimit [get, set]
bool  ScatterRays [get, set]
bool  UseDashes [get, set]
bool  UsePolarization [get, set]
double  MaximumFrequency [get, set]

This is a small Python example for you:

# New Geometric MTF Analysis
geo_mtf = TheSystem.Analyses.New_GeometricMtf()

# Get settings of analysis
geo_mtf_set = geo_mtf.GetSettings()

# Modify wield
field = 1
geo_mtf_set.Field.SetFieldNumber(field)

# Modify wavlenegth
wave = 1
geo_mtf_set.Wavelength.SetWavelengthNumber(wave)

# Modify sampling
sampling = ZOSAPI.Analysis.SampleSizes.S_32x32
geo_mtf_set.SampleSize = sampling

# Use polarization
geo_mtf_set.UsePolarization = True

# Apply settings
geo_mtf.ApplyAndWaitForCompletion()

I hope this helps, and take care,

 

David


harry000k
  • Author
  • Student
  • 2 replies
  • February 17, 2023

Hi David,

I tried running your code in the python interactive extension template and I am getting the following error: 

AttributeError: 'IAS_' object has no attribute 'Field'

 

Thanks for your help,

Harry

 

 


David.Nguyen
Luminary
Forum|alt.badge.img+2
  • Luminary
  • 1089 replies
  • February 17, 2023

Hi Harry,

 

Strange, it works for me with Python 3.8.13, Pythonnet 2.5.2, and OpticStudio 23.1.

Can you check your version of Python and Pythonnet?

Take care,

 

David


harry000k
  • Author
  • Student
  • 2 replies
  • February 17, 2023

Hi David,

 

Yes you were right, I was running Python 3.9.2 with Pythonnet 3.0.1

I have now switched to a virtual environment running Python 3.8.10 with Pythonnet 2.5.2 and the code is working perfectly.

 

Thanks for your help,

Harry 

 


Gaia
  • Single Emitter
  • 1 reply
  • December 24, 2024

Hi Harry,

Python 3.8 is no longer available, is there a way to modify MTF settings using the new versions of python?

 

Thank you,

Gaia


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