Description This subroutine writes a single ARN to a Flexible Image Transport System (FITS) file. If the ARN data has multiple values per cell (ex. complex field), then the output FITS file will be multi-extension with one frame for each cell value component. If the ARN is multi-slice, then the output FITS file will be multi-extension with one frame for each cell value component for each slice in the ARN.
Syntax ARNSaveToFITS( arn, fpath )
Parameters arn As Long Node number of the ARN whose data is being written to a FITS file.
fpath As String File path output string (ex. "C:\temp\Irradiance.fits"). The *.fits file extension is not required in the fpath string and will be added automatically if omitted. If fpath contains the output file name only, then the FITS file will be written to the current working directory. If fpath contains a directory location and a file name, the FITS file will be written to the specified directory. If the specified directory does not exist, the script command will attempt to create the specified directory automatically.
Example The example below illustrates how to scan a plane wave source through a range of angles, calling a raytrace and analysis at each angle step. The analyses at each step are stored in individual analysis results nodes (ARNs), which are compiled into a single multi-slice ARN after the raytrace and analysis loop is finished. Lastly, the multi-slice ARN, which contains all of the analyses results from each source angle step, is written out to a single FITS file.
Sub Main
ARNDeleteAllNodes()
Dim src As Long, ana As Long src = FindFullName( "Optical Sources.Plane Wave Source" ) ana = FindFullName( "Analysis Surface(s).Focal Plane" )
'Source scan and analysis Dim curAng As Double, curArn As Long Dim parmString As String For curAng = 0 To 25 Step 5
'Set the Plane Wave type source primitive direction parmString = "0," & CStr(curAng) & ",SD" SourcePrimSetParmValue( src, 5, parmString )
'Raytrace and analyze DeleteRays() CreateSource( src ) TraceExisting() IrradianceToARN( ana, "Irradiance " & CStr(curAng), curArn )
Next
'Retrieve list of ARNs and compile them into a single multi-slice ARN Dim arnList() As Long ReDim arnList(ARNGetMaxNodeNum()) For curArn = 0 To ARNGetMaxNodeNum() arnList(curArn) = curArn Next curArn = ARNCombineIntoMultislice( arnList(), "Source Scan Results" )
'Write multi-slice ARN out to a FITS file. 'Each slice is an extension in the output FITS file. ARNSaveToFITS( curArn, GetDocDir() & "/SourceScanResults.fits" )
End Sub
See Also
|