Description Performs a Zernike decomposition on the data grid of a 2D ARN and returns the coefficients of the decomposition in an array. The cell values of the ARN must be single-valued Doubles (i.e. no integers, complex fields, etc.). If the ARN is multi-slice, this command operates on the active slice.
Syntax ARNDecomposeToZernikes( arn, xcen, ycen, xsemi, ysemi, maxCoef, isWaves, coefs() )
Parameters arn As Long Node number of the ARN whose 2D grid data is being decomposed into Zernikes. The input ARN would typically represent OPD or Wavefront data, though this is not a strict requirement.
xcen As Double Center position in X of the aperture over which the Zernike terms are being decomposed. The center position is relative to the origin of the ARN.
ycen As Double Center position in Y of the aperture over which the Zernike terms are being decomposed. The center position is relative to the origin of the ARN.
xsemi As Double Semi-aperture in X of the aperture over which the Zernike terms are being decomposed.
ysemi As Double Semi-aperture in Y of the aperture over which the Zernike terms are being decomposed.
maxCoef As Long Maximum Zernike term to be included in the decomposition. Due to Zernike term 0 (Piston), the coefs() array will be size maxCoef+1 after the subroutine executes.
isWaves As Boolean Indicates whether the coefficients of the coefs() array should have units of waves. If False, the coefficients are expressed in the same units as the ARN data. Although the intention of the ARNDecomposeToZernikes function is to support Wavefront (units of waves) and GeometricOPD (system units) maps, in order to maximize the flexibility of the ARNDecomposeToZernikes function there is no explicit requirement placed on the data units of the input ARN (i.e. the data units may be waves, may be system units, or may be some unknown user-supplied data unit). The table below indicates the coefficient scaling rules for different combinations of input ARN data units and the isWaves argument.
coefs() As Double After the subroutine executes, this array has size maxCoef+1 and contains the coefficients of the decomposed Zernike terms.
Example The example below performs a raytrace followed by a Geometric OPD Map analysis where FRED auto-determines the best-fit reference sphere. The source is polychromatic and therefore the OPD Map result is stored in a multi-slice ARN. After the OPD Map calculation is performed, the script loops over each slice of the multi-slice ARN, performs a Zernike decomposition on the current monochromatic OPD map, and then prints the decomposition results to the output window.
Sub Main
DeleteRays() ARNDeleteAllNodes() TraceCreate()
Dim anaNode As Long anaNode = FindFullName( "Analysis Surface(s).Exit Pupil" )
Dim influence As Double, xcen As Double, ycen As Double Dim xsemi As Double, ysemi As Double, wl As Double Dim opdarn As Long influence = 0.04 'Adjacent cell influence as a fraction of analysis surface width xcen = 0 ycen = 0 xsemi = 3.4 ysemi = 3.4 wl = 0.5 'Reference wavelength (will use ray wavelength nearest to this value) CalcOPDMapsAuto( anaNode, influence, xcen, ycen, xsemi, ysemi, wl, opdarn )
'Iterate over slices of the OPDmap ARN and decompose Dim nSlices As Long, curSlice As Long, maxCoef As Long, curCoef As Long Dim coefs() As Double Dim isWaves As Boolean Dim zstring As String isWaves = False maxCoef = 15 nSlices = ARNGetSliceCount( opdarn ) For curSlice = 0 To nSlices-1
ARNSetActiveSlice( opdarn, curSlice ) ARNDecomposeToZernikes( opdarn, xcen, ycen, xsemi, ysemi, maxCoef, isWaves, coefs() )
Print "" Print "Zernike decomposition result:" Print "Active slice: " & ARNGetTitle( opdarn ) Print "" & Chr(9) & "Term" & Chr(9) & "Coef (" & If(isWaves,"waves",GetUnits()) & ")" & Chr(9) & "Form" For curCoef = 0 To UBound(coefs) Print Chr(9); Print curCoef; Print coefs(curCoef); Print GetZernikeSurfIthTermText( curCoef ) Next
Next
End Sub
See Also
|