Navigation: Scripting Reference Manual > Functions & Subroutines > ARNSetActiveSlice

 

ARNSetActiveSlice

 

Contact Us: fredsupport@photonengr.com

 

Description

This function specifies the index of a multi-slice ARN that should be the active slice.

 

Syntax

prevIdx = ARNSetActiveSlice( arn, idx )

 

Parameters

prevIdx (Long)

Returned value indicating the index of the previously active slice.

 

arn As Long

Node number of the ARN whose active slice is being specified.

 

idx As Long

Index (0-based) of the slice that should be set as the active slice.

 

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

All ARN Scripting Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC