Navigation: Scripting Reference Manual > Functions & Subroutines > ARNCreate2DSubsetByRange

 

ARNCreate2DSubsetByRange

 

Contact Us: fredsupport@photonengr.com

 

Description

This command creates a new 2D ARN from a subset of data in an existing 2D ARN by specifying axes value ranges.  Data values within the axes range limits given by aMin, aMax, bMin and bMax are included in the new 2D ARN dataset.  If the provided range limits are outside the minimum and maximum range limits of the existing ARN axes, then the range limits are truncated to the minimum and maximum range limits of the existing ARN axes.  Internally, the data in an ARN is stored on a 2D grid and there is a conversion between axes range limits and axes data grid indices.  For minimum range values, the minimum grid index kept will have its cell center always less than or equal to the requested minimum range value.  For maximum range values, the maximum grid index kept will be the cell whose center is closest to the requested range value.  This means that the cell center of the maximum index may be less than or greater than the maximum range requested by an amount which depends on the axes resolution.

 

 

Syntax

subArn = ARNCreate2DSubsetByRange( origArn, aMin, aMax, bMin, bmax, subArnName )

 

 

Parameters

subArn (Boolean)

Returned index of the new ARN containing the data subset.

 

origArn As Long

Index of the ARN containing the original data set from which subArn is created.

 

aMin As Long

Designates the minimum range value along the A axis of origArn for data which can be included in the subset.

 

aMax As Long

Designates the maximum range value along the A axis of origArn for data which can be included in the subset.

 

bMin As Long

Designates the minimum range value along the B axis of origArn for data which can be included in the subset.

 

bMax As Long

Designates the maximum range value along the B axis of origArn for data which can be included in the subset.

 

subArnName As String

String name of the newly created ARN containing the data subset.

 

 

Example

The following example retrieves a 2D ARN created by a detector entity, calculates the ARN cell statistics to determine the A and B axis ranges containing non-zero data, and then creates a new ARN containing the subset of non-zero data.

 

Sub Main

 

    'Prepare document

    ARNDeleteAllNodes()

    DeleteRays()

    ClearOutputWindow

 

    'Detector entity node

    Dim detSurf As Long

    detSurf = FindFullName( "Analysis Surface(s).Spherical Detector" )

 

    EnableTextPrinting False

    TraceCreate()

    EnableTextPrinting True

 

    'Detector entity auto-created ARN

    Dim mainArn As Long

    mainArn = DEGetMostRecentARNNum( detSurf )

 

    'Data statistics, find non-zero data window

    Dim tArnStats As T_ARN_2D_CELL_STATS

    Dim aMinIdx As Long, aMaxIdx As Long, bMinIdx As Long, bMaxIdx As Long

    ARNCompute2DCellStatistics( mainArn, tArnStats )

    aMinIdx = tArnStats.MinNonZeroIdxA

    aMaxIdx = tArnStats.MaxNonZeroIdxA

    bMinIdx = tArnStats.MinNonZeroIdxB

    bMaxIdx = tArnStats.MaxNonZeroIdxB

 

    'Convert index values to data ranges

    Dim aMin As Double, aMax As Double, bMin As Double, bMax As Double

    aMin = ARNGetAAxisValueAt( mainArn, aMinIdx )

    aMax = ARNGetAAxisValueAt( mainArn, aMaxIdx )

    bMin = ARNGetBAxisValueAt( mainArn, bMinIdx )

    bMax = ARNGetBAxisValueAt( mainArn, bMaxIdx )

 

    'Create windowed ARN zoomed on non-zero data

    Dim subArn As Long

    subArn = ARNCreate2DSubsetByRange( mainArn, aMin, aMax, bMin, bMax, _

        ARNGetName( mainArn ) & " - Windowed" )

 

    'Display

    ARNDisplayInChart( mainArn, "" )

    ARNDisplayInChart( subArn, "" )

 

    'Output Details

    Print "ARN ID" & Chr(9) & "A Min" & Chr(9) & "A Max" & Chr(9) & "B Min" & Chr(9) & "B Max"

    ARNGetAAxisRange( mainArn, aMin, aMax )

    ARNGetBAxisRange( mainArn, bMin, bMax )

    Print mainArn & Chr(9) & aMin & Chr(9) & aMax & Chr(9) & bMin & Chr(9) & bMax

    ARNGetAAxisRange( subArn, aMin, aMax )

    ARNGetBAxisRange( subArn, bMin, bMax )

    Print subArn & Chr(9) & aMin & Chr(9) & aMax & Chr(9) & bMin & Chr(9) & bMax

 

End Sub

 

See Also

ARN Script Commands

 

 

 

 

 

Copyright © Photon Engineering, LLC