19.3. How-To

19.3.1. Collector Configuration File

Interactive Mode takes an XML Collector Configuration File and a DIRSIG cfg file as input. An example of the collector XML follows:

<?xml version="1.0" standalone="no"?>
<!DOCTYPE interactive SYSTEM "http://www.dirsig.org/dtds/interactive.dtd">
<interactive format="plain" pausepolicy="never">

  <simulationcollectors>
    <simscenefilename/>
    <simbandpasses/>
    <simscenebbox/>
  </simulationcollectors>

  <solutioncollectors>
    <pathviewray/>
    <pathsolidangle/>
    <pathsurfacecount/>
  </solutioncollectors>

  <surfacecollectors>
    <surfacematid/>
    <surfacetemperature/>
    <surfaceentrypoint/>
    <surfaceexitpoint/>
    <surfacepathlength/>
    <surfacenormal/>
    <surfacetransmission/>
    <surfaceradiance/>
  </surfacecollectors>

</interactive>
  

The interactive section has four attributes which may be set:

  1. The "format" attribute may be set to "plain", "xml", or "binary". It controls the output formatting of the Interactive Session.

  2. The "pausepolicy" is an experimental feature which may be set to "never", "percollector", or "persurface". Rather than immediately output all the results, the interactive session will halt at the specified points, waiting for the user to type an abitrary character (or characters) followed by a new line.

  3. The "startupoutputredirect" may specify a filename to which all the DIRSIG startup text gets redirected. This does not include the output portion of the interactive session. If this attribute is not specified, then all output will go to either stdout or stderr, as in a normal DIRSIG simulation. Note that input must still be provided via stdin.

  4. The "interactiveoutputredirect" may specify a filename to which all the DIRSIG interactive results are redirected. If this attribute is not specified, then all output will go to stdout. Note that input must still be provided via stdin.

In the collector configuration file, the "<simulationcollectors>" corresponds to the Simulation Level Queries. Likewise, "<solutioncollectors>" go with Solutions and "<surfacecollectors>" are applied to each surface in a given solution. A full list of available collectors are given in: Table 19-1, Table 19-2, and Table 19-3. The Document Type Definition (DTD) associated with this input file also lists the available options and provides a means for syntax validation using external tools.

Table 19-1. Simulation Level Collectors

Collector TagDescription
simatmmodelnameString describing atmospheric model being used.
simscenefilenameName of the top-level ODB filename for the simulation.
simmatfilenameName of the simulation material filename.
simbandpassesOutputs the simulation bandpass list. This is indicates the discretization of electromagnetic spectrum which DIRSIG is using in its radiometric calculations.
simscenebboxProvides extent points of an axis-aligned bounding box encapsulating all the nonmoving geometry in the scene.

Table 19-2. Solution Level Collectors

Collector TagDescription
pathviewrayOrigin and direction of the ray used to intersect geometry. (Matches what is supplied by user).
pathsolidangleSolid angle used for radiometric calculations with view ray. (Matches what is supplied by user).
pathsurfacecountNumber of surfaces intersected by the ray before the path transmission fell below DIRSIG's internal threshold. (Normally the maximum value in the transmission spectral vector is no higher than 0.5%).
pathradianceThe sensor reaching radiance.
pathtransmissionTransmission along the entire path. Note that this will be zero if the ray strikes any opaque surfaces.

Table 19-3. Surface Level Collectors

Collector TagDescription
surfacetransmissionA spectral vector of mueller matrices indicating the surface transmission.
surfaceradianceA spectral vector of stokes vector indicating the surface radiance in W/(cm^2 * omega * micron).
surfaceirradianceA spectral vector of stokes vectors indicating the surface irradiance in W/(cm^2).
surfacetemperatureThe temperature of the surface in Kelvin.
surfaceentrypointWorld space coordinate (in meters) where the view ray hit the surface.
surfaceexitpointWorld space coordinate (in meters) where the view ray left the surface. Relevant for volume geometry.
surfaceentrydistanceDistance along ray to surface entry.
surfaceexitdistanceDistance along ray to surface exit.
surfaceentryangleEntry angle of the ray relative to the surface normal. Given in radians.
surfaceexitangleExit angle of the ray relative to the surface normal. Given in radians.
surfacepathlengthLength of the ray segment passing through the surface. Relevant for volume geometry and equals the Euclidean distance between the entry and exit point.
surfacenormalA normalized vector describing the surface normal.
surfacematerialidThe Material Id associated with the surface. This corresponds to an entry in the materials database (.mat file).
surfacethermalthicknessNon-volume geometry can be given a thermal thickness for the purposes of running DIRSIG's temperature (Therm) model. This value is normally specified in the materials database (.mat file), but can be overridden on a per facet basis in a GDB file.
surfacegasconcentrationVolume geometry may be used to represent a gas, in which case this value represents the gas concentration of the associated material in PPM.

Note that Polarized Mueller Matrices are stored in Row Major Order (M01,M02, M03,M04, M10, ... ,M44). In the current release of Interactive Mode, the location attribute associated with each Mueller Matrix or Stokes Vector in a Spectral Vector gives the spectral location in Microns.

Note also that the Surfaces are output in ascending order sorted by Entry Distance.

19.3.2. Bandpass Configuration File

The spectral coverage computed by Interactive Mode is determined by a Bandpass Configuration File. DIRSIG defines spectral regions using a minimum, maximum, and a uniform delta. These spectral regions are termed a "bandpass". Multiple bandpasses can be assembled in to a "bandpass list". A bandpass with a minimum wavelength of 0.3 microns, a maximum wavelength of 0.5 microns, and a sampling delta of 0.1 microns tells DIRSIG to simulate for the wavelengths 0.3, 0.4, and 0.5 microns. This means that internally, all the radiances, transmissions, irradiances, etc are computed for these three wavelengths. An example of the bandpass XML follows:

<bandpasslist>
  <bandpass spectralunits="microns">
    <minimum>0.3</minimum>
    <maximum>0.5</maximum>
    <delta>0.1</delta>
  </bandpass>  
</bandpasslist>
  

Spectral units of "microns", "nanometers", and "wavenumbers" are currently supported. An example of a bandpass XML specifying two bandpasses follows. This example will cause DIRSIG to simulate at 0.3, 0.31, 0.32, 0.33, 0.4, and 0.5 microns.

<bandpasslist>
  <bandpass spectralunits="microns">
    <minimum>0.3</minimum>
    <maximum>0.5</maximum>
    <delta>0.1</delta>
  </bandpass>  

  <bandpass spectralunits="nanometers">
    <minimum>310</minimum>
    <maximum>330</maximum>
    <delta>10</delta>
  </bandpass>  
</bandpasslist>
  

19.3.3. Interactive Mode Input

With a collector configuration file in place, DIRSIG4 can be placed in Interactive Mode as follows:

    dirsig4 -interactive ./collector.xml ./bandpass.xml nadir.cfg
  

In this case, collector.xml is the name of a Collector Configuration File. The bandpass.xml is the Bandpass Configuration File. The nadir.cfg is a traditional DIRSIG3 cfg file corresponding to a simulation. Parts of this CFG file, such as the atmosphere and the simulation base time, are still used by Interactive Mode. Future releases will allow all this information to be supplied via the command line, doing away entirely with the CFG file. When DIRSIG4 has finished loading the scene, the following prompt will appear:

Interactive Mode Ready
<!-- [time] [omega] [orX] [orY] [orZ] [dirX] [dirY] [dirZ] -->
  

The XML style comment indicates the input which Interactive Mode expects, summarized in Table 19-4. This informational prompt does not appear when operating in "binary" output mode.

Table 19-4. Interactive Input Parameters

ParameterDescription
timeOffset in seconds from simulation time specified in DIRSIG cfg. Fractional and negative values allowed.
omegaThe solid angle represented by the ray.
orX, orY, orZRay Origin: X, Y, and Z coordinates.
dirX, dirY, dirZRay Direction Vector: X, Y, and Z values.

Note that the ray direction vector does not need to be normalized. However, it may never be the zero vector. Also, the solid angle must obviously be greater than zero.

19.3.4. Interactive Mode Output

Interactive Mode is capable of outputting plain text, XML, or binary. The is controlled by setting the "format" attribute in the Collector Configuration File.

19.3.4.1. Plain Text Output

The Plain output format is intended to be human friendly. The following example contains the verbatim results of an interactive session.

Interactive Mode Ready

# Simulation Parameters #
Scene Bounding Box: 
    minimum: (-521.713,-543.484,-953.792)
    maximum: (1654.42,1632.64,1222.34)

# Solution Results #
View Ray: 
    origin: (800,800,1000)
    direction: (0,0,-1)
Solid Angle: 1
Surface Count: 1
Path Radiance: 
    [0.47 microns] 0.00279327
    [0.48 microns] 0.00281209
    [0.49 microns] 0.00275102
    [0.5 microns] 0.0028744

# Surface 1 #
Entry Distance: 859.254
Entry Angle: 0.485803
Material ID: 25

Interactive Mode Finished
    

19.3.4.2. XML Output

The XML output format allows users to easily parse interactive mode output using a DOM or SAX parser. The output is a completely valid XML document, including a reference to a DTD which can be used for basic syntax validation. Note that the spacing in the XML demonstration has been modified to make it more human-friendly. Likewise, some XML-style comments have been omitted for brevity.

<?xml version="1.0" standalone="no"?>
<!DOCTYPE interactivesession 
  SYSTEM "http://www.dirsig.org/dtds/interactive_out.dtd">
<interactivesession>
  <simulationinfo>
    <simscenebbox>
	<box>
          <lowerextent>
            <point><x>-521.713</x><y>-543.484</y><z>-953.792</z></point>
          </lowerextent>
          <upperextent>
            <point><x>1654.42</x><y>1632.64</y><z>1222.34</z></point>
          </upperextent>
        </box>
    </simscenebbox>
  </simulationinfo>

  <solutioninfo>
    <pathviewray>
      <ray>
        <origin><point><x>800</x><y>800</y><z>1000</z></point></origin>
        <direction><vector><x>0</x><y>0</y><z>-1</z></vector></direction>
      </ray>
    </pathviewray>
    <pathsolidangle>1</pathsolidangle>
    <pathsurfacecount>1</pathsurfacecount>
    <pathradiance>
      <spectralvector>
        <stokesvector location="0.47"> 0.00279327 </stokesvector>
        <stokesvector location="0.48"> 0.00281209 </stokesvector>
        <stokesvector location="0.49"> 0.00275102 </stokesvector>
        <stokesvector location="0.5"> 0.0028744 </stokesvector>
      </spectralvector>
    </pathradiance>

    <surfaceinfo>
      <surfaceentrydistance>859.254</surfaceentrydistance>
      <surfaceentryangle>0.485803</surfaceentryangle>
      <surfacematid>25</surfacematid>
    </surfaceinfo>
  </solutioninfo>
</interactivesession>
    

19.3.4.3. Binary Output

Interactive Mode also supports binary output. This section describes the format for that output. All data is output as big endian, regardless of the CPU architecture on which DIRSIG is run. Table 19-5 shows the assumptions about the size and formatting of the basic types discussed in this section.

Table 19-5. Basic Type Descriptions

TypeDescription
byte8 bits, signed via two's complement, -128 to 127
int4 bytes, signed via two's complement, big endian, -2,147,483,648 to 2,147,483,647
double8 bytes, IEEE754 format, big endian, 4.94065645841246544e-324 to 1.79769313486231570e+308

DIRSIG builds on these basic types to build more complex types for things like rays, stokes vectors, strings, etc. The following collection of tables shows how these DIRSIG types are structured. They list the elements of each type, in order, and explain what that element represents.

Table 19-6. DIRSIG Type: String

TypeDescription
intNumber of characters in string.
N bytesAll N ASCII characters in string.

Table 19-7. DIRSIG Type: Mueller Matrix

TypeDescription
bytePolarization status. 0=unpolarized, 1=polarized.
1 or 16 doublesMueller matrix elements in row major order. If unpolarized, there is only a single double (M_00) otherwise the full 4x4 matrix is presented.

Table 19-8. DIRSIG Type: Stokes Vector

TypeDescription
bytePolarization status. 0=unpolarized, 1=polarized.
1 or 4 doublesStokes vector elements. If unpolarized, there is only a single double (S_0) otherwise the full 4 element vector is presented.

Table 19-9. DIRSIG Type: Spectral Vector of Mueller Matrices

TypeDescription
intNumber of mueller matrices in spectral vector.
N (double, Mueller Matrix)All N matrices in the vector are printed out. Each is preceeded by a double indicating the wavelength associated with the matrix in microns.

Table 19-10. DIRSIG Type: Spectral Vector of Stokes Vectors

TypeDescription
intNumber of stokes vectors in spectral vector.
N (double, Stokes Vector)All N stokes vectors in the spectral vector are printed out. Each is preceeded by a double indicating the wavelength associated with the stokes vector in microns.

Table 19-11. DIRSIG Type: Point

TypeDescription
doublex coordinate.
doubley coordinate.
doublez coordinate.

Table 19-12. DIRSIG Type: Vector

TypeDescription
doublex component.
doubley component.
doublez component.

Table 19-13. DIRSIG Type: Ray

TypeDescription
PointRay origin.
VectorRay direction.

Table 19-14. DIRSIG Type: Box

TypeDescription
PointMinimum extent of axis-aligned box.
PointMaximum extent of axis-aligned box.

Table 19-15. DIRSIG Type: Bandpass

TypeDescription
doubleMinimum extent of bandpass. Units defined byte "spectral units" byte.
doubleMaximum extent of bandpass. Units defined byte "spectral units" byte.
doubleSampling delta for bandpass.
byteSpectral units. 1 = wave numbers, 2 = microns, 3 = nanometers.
intTotal number of sampling points in bandpass. Should be same as computing via min/max extents and delta.

Table 19-16. DIRSIG Type: Bandpass List

TypeDescription
intNumber of "Bandpass" items in list.
intTotal number of sampling points for all the bandpasses in list.
N BandpassAll N bandpasses in the list, printed out sequentially. Number of bandpasses printed is given by "bandpass count" above.

With the list of basic types and DIRSIG types established above, it is now possible to parse the collector output when in binary mode. Table 19-17 shows the output from each collector.

Table 19-17. Binary Collector Outputs

CollectorOutput Type
simatmmodelnamestring
simscenefilenamestring
simmatfilenamestring
simbandpassesBandpass List
simscenebboxBox
pathviewrayRay
pathsolidangledouble
pathsurfacecountint
pathtransmissionSpectral Vector of Mueller Matrices
pathradianceSpectral Vector of Stokes Vectors
surfacetransmissionSpectral Vector of Mueller Matrices
surfaceradianceSpectral Vector of Stokes Vectors
surfacetemperaturedouble
surfaceentrypointPoint
surfaceexitpointPoint
surfaceentrydistancedouble
surfaceexitdistancedouble
surfaceentryangledouble
surfaceexitangledouble
surfacepathlengthdouble
surfacenormalVector
surfacematidint
surfacethermalthicknessdouble
surfacegasconcentrationdouble