Hi, I have a question of how to extract the reference height or distortion in percentage with ZPL? I was using RAYY to get the real height but I’d like to extract the other two col data as well. Thanks!

Hi, I have a question of how to extract the reference height or distortion in percentage with ZPL? I was using RAYY to get the real height but I’d like to extract the other two col data as well. Thanks!
Best answer by David.Nguyen
Hi zemax_user,
I’m not quite sure which are the two columns you are refering to. Based on the title of your post, I’m assuming you want the Distortion column at least. There are several ways to go about this, but the easiest might be via the DIST Merit function operand:
DIST | Distortion in waves contributed by the surface defined by Surf at the wavelength defined by Wave. This is the third order distortion calculated from the Seidel coefficients (see “Seidel Coefficients”), and is not valid for non-paraxial systems. |
The way you call an optimization operand in ZPL is through the numeric functions OCOD and OPEV. Here is a specific example below:
# Numeric code of DIST operand
DIST_OPERAND = OCOD("DIST")
# DIST operand parameters
Surf = 0
Wave = 1
Absolute = 0
# Evaluate DIST operand
distortion = OPEV(DIST_OPERAND, Surf, Wave, Absolute, 0, 0, 0)
# Display distortion value
PRINT "Distortion: ", distortion, "%"
The only issue with this approach is that it displays the maximum distortion given by the most extreme field value. In your case, that would be the field at 0.51560750 deg, and the distortion reported will be 0.00278748 %. A work around would be to define a single field, and change its value in a loop with the SETSYSTEMPROPERTY (or SYSP) keyword. Something like so:
# Numeric code of DIST operand
DIST_OPERAND = OCOD("DIST")
# DIST operand parameters
Surf = 0
Wave = 1
Absolute = 0
# PRINT properties
FORMAT "%.8f" LIT
# Field properties
Y_FIELD = 103 # Code for field Y value in SYSP
NUM_OF_FIELDS = 100 # Number of field values to evaluate
MAX_FIELD = 14.0 # Maximum field value
FIELD_INC = MAX_FIELD / NUM_OF_FIELDS # Field value increment
# Loop over the different field values
FOR field_id, 0, NUM_OF_FIELDS, 1
# Calculate field value
field_value = field_id * FIELD_INC
# Update field value
SYSP Y_FIELD, 1, field_value
UPDATE
# Evaluate DIST operand
distortion = OPEV(DIST_OPERAND, Surf, Wave, Absolute, 0, 0, 0)
# Display distortion value
PRINT "Y Angle: ", field_value, " ",
PRINT "Distortion: ", distortion, " %"
NEXT
This is what it gives in the Double-Gauss 28 deg field sample file (with a single field):
I hope this helps, and take care,
David
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.