Skip to main content
Solved

use ZPL to make default contrast merit function

  • December 16, 2025
  • 2 replies
  • 84 views

John.Hygelund
Fully Spectral
Forum|alt.badge.img+1

I'd like to use the ZPL function DEFAULTMERIT to make a default merit function with the below settings:

rtaImage?eid=500Pf00000dVJo2&feoid=00N3g000000rtYd&refid=0EMPf00000IaT2j

If I use data = 8 is makes a contrast merit function, but seems to be unsupported in the documentation.

I can't see how to set the spatial frequency

or how to limit the merit function to config 1

rtaImage?eid=500Pf00000dVJo2&feoid=00N3g000000rtYd&refid=0EMPf00000IaTfR

Thanks for any advice,

John

Best answer by MichaelH

Hi John,

Your images are not coming through for me.

For the Optimization Wizard, there were changes implemented about 8 years ago when OpticStudio added the MECA/MECS/MECT operands, including adding the Contrast option to the Image Quality metric and simplifying some of the other image quality metrics.  When these changes were made, Zemax updated the ZOS-API by adding a ISEQOptimizationWizard2 but I don’t think they updated the ZPL keyword for DEFAULTMERIT.

Internal to OpticStudio, the DEFAULTMERIT uses enumerated values with integers starting from 0 to signify each option in a drop down for the data option.  Since the data option was present before Contrast optimization was introduced, you can select this with the ZPL keyword.  However, I believe that the Spatial Frequency field is a new field and therefore was never an option with the original DEFAULTMERIT keyword.  The 2 options I can think of to work around this are:

  • use the ZOS-API with the ISEQOptimizationWizard2
  • after applying the DEFAULTMERIT keyword, loop through all rows in the MFE and update the 5th column with the SETOPERAND keyword

2 replies

MichaelH
Ansys Staff
Forum|alt.badge.img+2
  • Ansys Staff
  • Answer
  • January 12, 2026

Hi John,

Your images are not coming through for me.

For the Optimization Wizard, there were changes implemented about 8 years ago when OpticStudio added the MECA/MECS/MECT operands, including adding the Contrast option to the Image Quality metric and simplifying some of the other image quality metrics.  When these changes were made, Zemax updated the ZOS-API by adding a ISEQOptimizationWizard2 but I don’t think they updated the ZPL keyword for DEFAULTMERIT.

Internal to OpticStudio, the DEFAULTMERIT uses enumerated values with integers starting from 0 to signify each option in a drop down for the data option.  Since the data option was present before Contrast optimization was introduced, you can select this with the ZPL keyword.  However, I believe that the Spatial Frequency field is a new field and therefore was never an option with the original DEFAULTMERIT keyword.  The 2 options I can think of to work around this are:

  • use the ZOS-API with the ISEQOptimizationWizard2
  • after applying the DEFAULTMERIT keyword, loop through all rows in the MFE and update the 5th column with the SETOPERAND keyword

John.Hygelund
Fully Spectral
Forum|alt.badge.img+1
  • Author
  • Fully Spectral
  • January 14, 2026

Hello ​@MichaelH ,

Thank you for your explanation and options. I was hoping to keep this effort with ZPL, but the second option sounds like it will work. I really appreciate your help!

-John