UUunitAlg TCL UTILITIES USER MANUAL UUunitAlg
SYNOPSIS
Get a conversion algorithm to convert raw data to units
PACKAGE
TCLUDFUTILS
NAME
UUunitAlg
USAGE
set rV  UUunitAlg  kV UnitN SenN {pSrC}]
INPUT DEFINITIONS
kV - The comma separated data key and version nummber associated with the with UDF hierarchy of the opened file for which the algorithm is being returned. Key should have been obtained from a call to GetDataKey.
UnitN - The PIDF unit number which defines the algorithm to use in the unit conversion.
SenN - The PIDF sensor definition number associated with the data being converted.
pSrC - The location in the PIDF file where the measurement source is defined. This is an optional input variable which is defaulted to Sen indicating that the measurement is defined under the PIDF SENSOR definitions. If the measurement is defined uner the PIDF ANCILLARY definitions then this should be changed to Anc.
RETURN DEFINITION
Returns the algorithm definition which can be input directly into the ConvertToUnits procedure.
DESCRIPTION
UUunitAlg reads the PIDF associated with kV and returns the convertion algorithm found under the the PIDF unit definition number UnitN. The unit definition must be associated with the measurement defined under the PIDF definition SenN in the PIDF section designated in pSrC. Algorithms associated with the array index of a sensor are specified by giving the apprpriate conversion unit number together with the sensor PIDF number.
ERRORS
None Generated
C BACKING
No
EXAMPLE(S)
# RETURN THE X POSITION OF THE IMAGE SATELLITE IN BOTH KM AND Re

# INITIALIZE the UDF common variables

UDFInits

# GET the key for the UDF hierarchy IMAGE IMAGE1 OA ORBIT IMOORBIT

set KeY [GetDataKey IMAGE IMAGE1 OA ORBIT IMOORBIT]

# OPEN the data file containing the time 2001 198 1 0 0

FileOpen $KeY 0 2001 198 1 0 0 2001 198 6 0 0

# POSITION the file pointer to the beginning of the requested time

FilePos $KeY 0 2001 198 1 0 0

# IN the PIDF the Measurement definitions for the X, Y, and Z, spacecraft
#   locations are 0, 1, and 2 under the SENSOR drfinitions.  The UNIT 
#   definition to convert the measurements to km is 2 and to Re 5.
#   The algorithm definitions (2 per sensor) are set below.

set kV $KeY,0
set uX(0) [UUunitAlg $kV 2 0]
set uX(1) [UUunitAlg $kV 5 0]
set uY(0) [UUunitAlg $kV 2 1]
set uY(1) [UUunitAlg $kV 5 1]
set uZ(0) [UUunitAlg $kV 2 2]
set uZ(1) [UUunitAlg $kV 5 2]

# THE format used to print out the data

set FmT "%d %d %d : X %.0f  %.4f   Y %.0f  %.4f   Z %.0f  %.4f" 

# READ five instances of the satellite X,Y,Z positions and print out the
#   results (together the the start time) in both km and Re.

for { set I 0 } { $I < 5 } { incr I } { 
   ReadUDF $KeY 0 OA 0 0 0 
   set Xkm [ConvertToUnits $KeY 0 OA $uX(0) rV]
   set XRe [ConvertToUnits $KeY 0 OA $uX(1) rV]
   ReadUDF $KeY 0 OA 1 0 0 
   set Ykm [ConvertToUnits $KeY 0 OA $uY(0) rV]
   set YRe [ConvertToUnits $KeY 0 OA $uY(1) rV]
   ReadUDF $KeY 0 OA 2 0 1 
   set Zkm [ConvertToUnits $KeY 0 OA $uZ(0) rV]
   set ZRe [ConvertToUnits $KeY 0 OA $uZ(1) rV]

   puts stderr [format $FmT $ExDa(OA,BYR) $ExDa(OA,BDY) $ExDa(OA,BMSEC) \
          $Xkm $XRe $Ykm $YRe $Zkm $ZRe] 
}

>2001 198 3600000 : X -15183  -2.3831   Y -4507  -0.7075   Z 44264  6.9477
>2001 198 3720000 : X -15049  -2.3621   Y -4476  -0.7026   Z 44444  6.9760
>2001 198 3840000 : X -14914  -2.3409   Y -4445  -0.6977   Z 44621  7.0038
>2001 198 3960000 : X -14778  -2.3196   Y -4413  -0.6927   Z 44796  7.0312
>2001 198 4080000 : X -14642  -2.2982   Y -4381  -0.6877   Z 44969  7.0584

      
Feb 19, 2007