Navigation: Scripting Reference Manual > Functions & Subroutines > CalcOPDMapsFocus

 

CalcOPDMapsFocus

 

Contact Us: fredsupport@photonengr.com

 

Description

This subroutine performs a Geometric OPD Map analysis with a user-supplied x,y,z position in global coordinates indicating the center of the reference sphere.  Summary information regarding the ray counts and ray path lengths is automatically printed to the output window.  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

CalcOPDMapsFocus( anaNode, influence, xcen, ycen, xsemi, ysemi, xpos, ypos, zpos, 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.

 

xpos As Double

Specifies the x component of the position vector defining the center of the reference sphere in global coordinates.

 

ypos As Double

Specifies the y component of the position vector defining the center of the reference sphere in global coordinates.

 

zpos As Double

Specifies the z component of the position vector defining the center of the reference sphere in global coordinates.

 

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 with a reference sphere specified by its center position in global coordinates.  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.

 

In this specific example, the OPD map is being calculated in the exit pupil of an imaging lens.  The reference sphere center point can be found by calculating the image centroid (or chief ray intercept) position in global coordinates using the Best Focus analysis.  If the rayset is polychromatic, then the image centroid should be computed for rays of the desired reference wavelength.  This procedure can be automated in scripting but is not included in the example below for simplification.

 

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

    Dim xfocus As Double, yfocus As Double, zfocus 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

    xfocus    = 0

    yfocus    = 1.614370497617

    zfocus    = 15.18586481781

    CalcOPDMapsFocus( anaNode, influence, xcen, ycen, xsemi, ysemi, xfocus, yfocus, zfocus, 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