Navigation: Scripting Reference Manual > Functions & Subroutines > ARNCreate2DDoubleFromComplex

 

ARNCreate2DDoubleFromComplex

 

Contact Us: fredsupport@photonengr.com

 

Description

Creates a new ARN whose data is a 2D array of double precision float values that are extracted from an existing ARN whose data is a 2D array of complex values.  The extracted data can be one of the following quantities: Energy, Amplitude, Signed Amplitude, Real, Imaginary, Phase.

 

Syntax

newARN = ARNCreate2DDoubleFromComplex(nodeID, operation)

 

Parameters

newARN (Long)

Returned node number of the new ARN created as a result of the data extraction from the complex valued ARN.

 

nodeID As long

Node number of the complex valued ARN from which the data in newARN is derived.

 

operation As Long

Specifies the quantity being extracted from complexARN.  Options are:

 

Value

Quantity (U = complex field)

0

Energy ( UU*)

1

Amplitude ( Sqrt(UU*) )

2

Signed Amplitude ( Re[U] Sqrt( UU* ) )

3

Real ( Re[U] )

4

Imaginary ( Im[U] )

5

Phase ( Arg[U] = Atn2( Im[U], Re[U] )

 

 

Example 1 - Creating an MTF from a PSF

The following example computes a Coherent MTF ARN from a Coherent PSF irradiance.

 

Sub Main

          Dim nAnaSrf As Long, psfARN As Long, fftARN As Long, mtfARN As Long

          nAnaSrf = FindFullName( "Analysis Surface(s).Analysis 1" )

 

          TraceCreateDraw                    'assumes a source is already set up to create a PSF

 

          IrradianceToARN( nAnaSrf, "coherent PSF", psfARN ) 'creates PSF irradiance ARN

 

              fftARN = ARNCreate2DComplexFromDouble( psfARN )          'creates new 2D complex ARN called fftARN from the PSF ARN

          ARNFFT2D fftARN    'runs FFT on the data

          ARNSetName(fftARN, "FFT PSF")

 

          mtfARN = ARNCreate2DDoubleFromComplex( fftARN, 1 )

          'converts fftARN back to double using operation 1 == field amplitude, this extract is the MTF

          ARNSetName(mtfARN, "coherent MTF")

          

End Sub

 

 

Example 2 - Extracting all quantities from Vector Field into multi-slice ARN

The following example computes a Vector Field analysis for a specific source.  The X, Y and Z complex field components are extracted into their own ARNs with complex valued data and then quantities from each ARN are further extracted into their own ARNs with data arrays of 2D double values.  Lastly, the extracted ARNs from each of the original X, Y and Z complex field data are merged together into multi-slice ARNs and the remaining ARNs are removed from the document.

 

Sub Main

   

    'Remove all ARNs

    ARNDeleteAllNodes()

 

    'Nodes of interest

    Dim src As Long, ana As Long

    src = FindFullName( "Optical Sources.Laser Beam - Vector" )

    ana = FindFullName( "Analysis Surface(s).Detector Entity 1 - Ana Hi-res asymmetric" )

 

    'Trace rays from a specific source node

    DeleteRays()

    CreateSource( src )

    TraceExisting()

 

    'Perform a vector field analysis

    Dim vfArn As Long

    VectorFieldToARN( ana, "VectorField", vfArn )

 

    'Loop over each vector field direction and extract all field quantities

    Dim fieldDir As Long, curComp As Long, sfArn As Long, compArns() As Long

    Dim sfMulti As Long

    ReDim compArns(5)

    For fieldDir = 0 To 2

 

        'Extract vector field direction into scalar complex ARN

        '0 = X, 1 = Y, 2 = Z

        sfArn = ARNCreate2DComplexFromComplex3D( vfArn, fieldDir )

        Select Case fieldDir

        Case 0

            ARNSetName( sfArn, ARNGetName(sfArn) & " X" )

        Case 1

            ARNSetName( sfArn, ARNGetName(sfArn) & " Y" )

        Case 2

            ARNSetName( sfArn, ARNGetName(sfArn) & " Z" )

        Case Else

            'pass

        End Select

 

        'For 2D complex field data:

        '    0 = Energy = UU*

        '    1 = Amplitude = Sqrt(UU*)

        '    2 = Signed Amplitude = Sgn(Re{U})Sqrt(UU*)

        '    3 = Real = Re{U}

        '    4 = Imaginary = Im{U}

        '    5 = Phase = Arg(U) = Atan2(Im{U},Re{U})

        For curComp = 0 To 5

            compArns(curComp) = ARNCreate2DDoubleFromComplex( sfArn, curComp )

        Next

 

        'Combine individual ARNs into a single multi-slice ARN

        sfMulti = ARNCombineIntoMultislice( compArns(), ARNGetName( sfArn ) & "_Multislice" )

 

    Next

 

    'Remove any non multi-slice ARN

    Dim curArn As Long

    For curArn = 0 To ARNGetMaxNodeNum()

        If ARNIsValidNode(curArn) Then

            If ARNGetSliceCount(curArn) = 1 Then

                ARNDelete(curArn)

            End If

        End If

    Next

    Update

 

End Sub

 

See Also

All ARN Scripting Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC