Navigation: Scripting Reference Manual > Functions & Subroutines > CalcOPDMapsAuto

 

CalcOPDMapsAuto

 

Contact Us: fredsupport@photonengr.com

 

Description

This subroutine performs a Geometric OPD Map analysis by letting FRED auto-determine the best-fit reference sphere.  Summary information regarding the ray counts, ray path lengths, and best-fit sphere (BFS) is automatically printed to the output window, where the BFS data is reported as the sphere center in global coordinates.  Refer to the Geometric OPD Map analysis Help topic for additional information about the calculation.  If multiple wavelengths are included in the analysis then the resulting ARN will be multi-slice, with one slice corresponding to the OPD Map result for each unique ray wavelength.

 

Syntax

CalcOPDMapsAuto( anaNode, influence, xcen, ycen, xsemi, ysemi, wl, opdarn )

 

Parameters

anaNode As Long

Node number of the analysis surface being used for the Geometric OPD Map calculation.

 

influence As Double

Specified as a fraction of the analysis surface width, this parameter sets a radius value over which adjacent cells can influence each other and has the effect of smoothing or filling-in cells which contain no ray data.  The recommended value is 0.04.

 

xcen As Double

Reference aperture center position in X specified in the local coordinate system of anaNode.

 

ycen As Double

Reference aperture center position in Y specified in the local coordinate system of anaNode.

 

xsemi As Double

Reference aperture semi-width in the X axis.

 

ysemi As Double

Reference aperture semi-width in the Y axis.

 

wl As Double

Specifies the wavelength (in microns) to be used in the reference sphere fitting.  If the raytraced data was at a wavelength(s) other than that specified by wl, the ray wavelength closest to the value of wl will be used for reference sphere fitting.

 

opdarn As Long

After the subroutine executes, this variable indicates the node number of the ARN where the Geometric OPD Map results are stored.  If multiple ray wavelengths were included in the calculation then the resulting ARN will be multi-slice, with one slice corresponding to the OPD Map result for each unique ray wavelength.

 

 

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

Analyses Script Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC