Skip to main content

ZOS-API- How to manipulate operands (and apply optimization wizard) in Merit function editor?

  • September 30, 2019
  • 0 replies
  • 1359 views

Julia
Zemax Staff
Forum|alt.badge.img+2
  • Zemax Staff
  • 53 replies
TheMFE = TheSystem.MFE;
TheSystem.MFE.AddOperand();
TheSystem.MFE.InsertNewOperandAt(1);
TheSystem.MFE. RemoveOperandsAt(1,3);
TheSystem.MFE. CopyOperands(1,3,5);
TheSystem.MFE. GetOperandAt(2);

In the above code:

  • Add a new operand to the end of the merit function editor
  • Insert a new operand at operand # 1
  • Remove 3 operands from operand #1
  • Copy 3 operands from operand#1 and paste at operand#5
  • Get access to operand#2 for further modification or definition


operand1= TheSystem.MFE.GetOperandAt(1);
operand1.ChangeType(ZOSAPI.Editors.MFE.MeritOperandType.REAY);
operand1.Target = 0.0;
operand1.Weight = 10.0;
operand1.GetCellAt(2).IntegerValue = 3;
operand1.GetCellAt(3).IntegerValue = 2;
operand1.GetCellAt(7).DoubleValue = 1.0;

In the above code:

  • Access operand#1
  • Change Type as REAY
  • Set Target as 0
  • Set Weight as 10.0
  • Set Surf (the 2nd cell) as 3
  • Set Wave (the 3rd cell) as 2
  • Set Py (the 7th cell) as 1.0

mfDir= TheSystem.MFE.MeritFunctionDirectory;
TheSystem.MFE.SaveMeritFunction(System.String.Concat(mfDir, '\savedMF.mf'));
TheSystem.MFE.GetMeritFunctionFiles();
TheSystem.MFE. LoadMeritFunction(System.String.Concat(mfDir, '\savedMF.mf'));TheSystem.MFE. InsertMeritFunction(System.String.Concat(mfDir, '\savedMF.mf'),3);


In the above code:

  • Get the default merit function directory
  • Save merit function as savedMF.mf with full file path
  • Get string list of merit function files
  • Load merit function file
  • Insert merit function file at operand# 3

TheSystem.MFE.CalculateMeritFunction();
TheSystem.MFE.NumberOfOperands;

The above code:

  • Calculate merit function value
  • Get the number of operands

TheSystem.MFE.GetOperandValue(ZOSAPI.Editors.MFE.MeritOperandType.NSDE,1,4,-1,1,2,0,0,0);

The above code:

  • Calculate the value of an operand. Type NSDE get the peaked intensity. It will return the value of any optimization operand, even if the operand is not currently in the merit function

OptWizard = TheSystem.MFE.SEQOptimizationWizard2;
OptWizard.Type=ZOSAPI.Wizards.OptimizationTypes.RMS;
OptWizard.Criterion=ZOSAPI.Wizards.CriterionTypes.Spot;
OptWizard.Reference=ZOSAPI.Wizards.ReferenceTypes.Centroid;
OptWizard.OverallWeight=1;
OptWizard.UseGaussianQuadrature=true;
OptWizard.Rings=3;
OptWizard.Arms=ZOSAPI.Wizards.PupilArmsCount.Arms_6;
OptWizard.UseGlassBoundaryValues=true;
OptWizard.GlassMin=3.0;
OptWizard.GlassMax=15.0;
OptWizard.UseAirBoundaryValues=true;
OptWizard.AirMin=0.5;
OptWizard.AirMax=1000.0;
OptWizard.AirEdgeThickness=0.5;
OptWizard.Apply();

The above code add operands through sequential optimization wizard by evaluating image quality as smallest RMS Spot, take centroid as reference.


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

0 replies

Be the first to reply!

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