How to model a black-box optical system using Zernike coefficients

It is often required to represent an optical system in a design even though you do not have detailed prescription data like radii of curvature, glasses, etc. This article shows how to use Zernike coefficients to describe the wavefront aberrations of a system and produce a simple but accurate representation of an optical system if a Zemax Black Box surface file cannot be used. This is typically the case if you are relying on experimental data measured using the optical system, but its prescription data is not available to you.

Authored By Mark Nicholson


Article Attachments


It is sometimes required to represent an optical sub-system without having detailed knowledge of its prescription. For first-order calculations a paraxial lens is adequate, but when wavefront aberrations are needed as well, Zernike phase coefficients can be used to give an accurate model of the wavefront produced by the optical system.

OpticStudio supports a comprehensive black-box capability which is recommended for this purpose. However, the following procedure can be used if a Zemax Black Box file cannot be provided.

Zernike phase data

These Zernike phase coefficients can be produced by OpticStudio, if you want to distribute aberration data to your customers without revealing prescription data, or by an interferometer if you are measuring a lens on which you have no prescription data. Depending on your interferometer software, you may have data in OpticStudio Zernike format already, grid phase data, or .INT files. OpticStudio can work with all of these, but for the purposes of this article we will use only Zernike data.

Zernike phase data represents a measurement of the performance of an optical system at a specific field and at a specific wavelength. Because information about the glasses, radii of curvature, aspheric coefficients, etc. are not part of the Zernike data, there is no way to scale Zernike data to a different field or wavelength. For this reason, you will need a set of Zernike phase data for each (field, wavelength) pair you want to model performance at. These can be entered into OpticStudio by either having a separate file for each (field, wavelength) combination or (more likely) a separate configuration for each (field, wavelength) pair.

There is one important exception: when the system being modeled is an all-reflective system, then the Zernike Standard SAG surface can be used to model performance at all wavelengths for a given field point. This article gives full details of this special case.

The starting design

All the sample files used in this article are included in a zip file that can be downloaded from a link at the top of this article. The first file we will look at is 'Cooke one field, one wavelength.zmx', which is based on the Cooke triplet sample file distributed with OpticStudio. As the name implies, this file is based on a single (field, wavelength) pair.


and its wavefront looks like so:


and its spot size is like so:


Now Zernike coefficients are a compact way of describing the wavefront error produced by an optical system. In order to produce a 'black box' model, we must first produce a paraxial optical system with the same first-order properties and then aberrate the wavefront produced by this paraxial system with the Zernike data.

The key paraxial data we need is the exit pupil position and exit pupil diameter. All wavefront data is measured in the exit pupil, and so our black box system must have the same pupil data. For this file, the pupil data is as follows:

Exit Pupil Diameter = 10.2337 mm

Exit Pupil Position = -50.9613 mm

The paraxial equivalent

Open the file 'Paraxial Equivalent.zmx'. It models the same system with just a paraxial lens surface:


Note the following:

  • It uses the same field and wavelength as the original design.
  • Its entrance pupil diameter is set to the same value as the exit pupil diameter of the original system. In this file the entrance pupil, stop surface, and exit pupil are all co-located.
  • The focal length of the paraxial lens, and the thickness to the image surface, are both set equal to -1*exit pupil position of the original file. The -1 factor is because the EXPP is measured from the image to the pupil, but the surface thickness is the distance from the pupil to the image, and so need to change sign.
  • The system has the same first-order properties as the original system.

The exit pupil of this system is exactly the same size and in the same location as the exit pupil of the original system. In order to add aberrations onto the paraxial lens output, we use a Zernike Standard Phase surface immediately after the paraxial lens. Our goal is to take the Zernike coefficients of the original lens, and add them onto the Zernike surface of the paraxial equivalent lens.


Copying Zernike data between lenses

Return to the 'Cooke One Field One Wavelength.zmx' file, and click on Analysis...Wavefront...Zernike Standard Coefficients. OpticStudio computes the wavefront of the system and then fits a series of Zernike polynomials.

Zernike Standard Coefficients

Both the sampling of the wavefront, and the number of Zernike terms, can be defined by the user via the Settings dialog. The key parameters in determining whether the wavefront is adequately sampled or the number of Zernike terms are the RMS fit error and the maximum fit error. Using the default parameters for both sampling and number of terms, this design delivers

Zernike Standard Coefficients_2

Which means that when we subtract the real wavefront from one reconstructed from the Zernike coefficients, the errors are of the order of a millionth of a wave. That's close enough! However, in general you may need to adjust the wavefront sampling and maximum Zernike term in order to achieve an acceptable fit.

We now need to transfer the Zernike coefficient data out of this design and into the paraxial equivalent design. This could be done by printing the Zernike data out and re-typing it, but this is tedious. This is a good job for a macro.

The following macro (also included in the zip file at the end of the article), called Zernike Readout.zpl, gets the Zernike data from this lens and saves it to a file in the format that Tools...Import Data on the Extra Data Editor can read. The steps it goes through are as follows:

First, it defines all the variables it will need (L1-19).

! This macro writes out the Zernike standard coefficients
! of a lens file in a format that can be directly imported
! into the Extra data Parameters of a  Zernike Standard Phase surface

! First define the variables we need
! Enter whatever values are appropriate
! Use INPUT statements if you prefer
max_order = 37 # can be up to 231
sampling = 2 #sampling is 1 for 32x32, 2 for 64x64 etc
field = 1
wavelength = 1
zerntype = 1 # Get standard, not fringe or Annular coefficients
epsilon = 0 # only used for Annular Zernike coefficients
reference = 0 # reference to the chief ray
vector = 1 # use the built-in VEC1 array to store the data
output$ = "zernike.dat"
path$ = $PATHNAME() # save the data in the same location as the file we are using
file$ = path$ + "\" + output$
PRINT "Writing data to ", file$

(Note that the sampling and maximum Zernike terms should be set to the values you used for the Zernike Analysis above.) Then the macro gets the Exit Pupil Diameter and Zernike data (L21-27):

! Then get the Exit Pupil Diameter. Use VEC1 to store the data
EXPD = VEC1(13) # see the manual for the data structure
normalization_radius = EXPD/2

! Then get the Zernike coefficients up to the maximum required order
GETZERNIKE max_order, wavelength, field, sampling, vector, zerntype, epsilon, reference

Note that the normalization radius of the Zernike surface is half the Exit Pupil Diameter. The macro then prints the data out to a .DAT file in the correct format for the Zernike Standard Phase surface to read it (L29-43):

! Then write them out to file in the format needed for the Import Tool
OUTPUT file$
PRINT max_order
PRINT normalization_radius
FOR order = 1, max_order, 1
    z_term = order + 8 # offset to the correct location in the data structure, see manual!
    PRINT VEC1(z_term)
NEXT order

! End
PRINT "Program End"

The Zernike data is entered to the Parameter columns of the Zernike Standard Phase surface as follows:


Put this macro into the {Zemax}/Macros folder, click on Programming...ZPL Macros...Refresh List so that the macro appears in the menu listing, and then run it. It will create a file called 'zernike.dat' in the same folder as the original OpticStudio file. If you open this file in Notepad, you will see:


This file contains all the data the Zernike Standard Phase surface needs. The first number is the number of Zernike terms, then the normalization radius, then each Zernike term. The Extra Data Editor's Import tool can read this file directly.

Return to the paraxial equivalent lens file. Browse and open the zernike.dat file in the Import tab of the Surface 2 Properties:


Press ‘Import’ button and a Zemax Message box will appear when the data is successfully imported:


The wavefront error now shows:


and the spot diagram shows


This file produces identical ray-tracing results to the original file! In the attached zip, the file 'Zernike Equivalent.zmx' shows the finished system. Also, the file 'Direct Comparison.zmx' shows both the original and Zernike versions of the same file as two different configurations. This allows easy comparisons between the two versions of the file.




Was this article helpful?
22 out of 22 found this helpful



Please sign in to leave a comment.