TUgridFill1D TCL UTILITIES USER MANUAL TUgridFill1D
SYNOPSIS
Fill gaps in a 1D grid
PACKAGE
TCLUTILS
NAME
TUgridFill1D
USAGE
TUgridFill1D  Grid gInfo Dir FmT {mGap} {Extend} {gNorm}
INPUT DEFINITIONS
Grid - A 1D data grid generated through a call to TUdataGrid.
gInfo - The grid information array.
Dir - The fill direction which must be X or Y.
FmT - The method used to fill the gaps. If V1 is the value at the leading edge of a gap and V2 the value at the closing edge then the methods are:
HF - V1 is projected across the gap.
HB - V2 is projected across the gap.
HM - V1 and V2 are projected to the center of the gap.
LI - The gap is filled with the linear interpolation of V1 to V2.
mGap - An optional value defaulted to -1 which specified a maximum gap size. If this value is >= 0 then gaps greater than this size will not be filled. Size has units of grid cells.
Expand - An optional value defaulted to 0. If this value is 0 gaps at the beginning and end of the grid will not be filled. If set to 1 the gaps will be filled using the first and last values in the grid.
gNorm - Optional input. This is the normalization array returned with the Grid> array from TUdataGrid. If provided the routine can absolutely identify empty grid cells, otherwise it makes its best guess were gaps exist.
RETURN DEFINITION
NONE
DESCRIPTION
TUgridFill1D takes a 1D Grid of values created using the procedure TUdataGrid and fills any data gaps that it finds in the grid. Gaps can be filled under one of four scenarios; the value leading into the gap can be propagated across the gap (HF, the value terminating the gap cane be propagated back through the gap HB, the leading and terminating values can both be propagated into the gap to meet at the center HM, or the gap can be filled with a linear interpolation of values from the leading to terminating value LI. By setting Extend to 1 gaps at the front and back of the array will be filled, otherwise they are left in place. Setting mGap allows the specification of a mazimum gap size. Gaps larger than this size will not be filled. If the normalization array generated with the Grid array is input into the procedure it will be used to locate the gapsi in Grid.
ERRORS
None Generated
C BACKING
No
EXAMPLE(S)
EXAMPLE 1:Filling gaps in a 1D grid using all four methods.
# FILL gaps in a 1D grid

# CREATE a sparse synthetic data set to the function: 
#       Y = A*X^3 + B*X^2 + C*X + D

set A  .5
set B -1.0
set C -2.0
set D  8.0

set nP 0
for { set I -3.0 } { $I <= 4.0 } { set I [expr $I + 0.5] } { 
   set Xs [expr $I * $I]
   set X($nP) $I
   set V($nP) [expr $A * $Xs * $I + $B * $Xs + $C * $I + $D]
   incr nP
}

# SET up the grid information array.  Grid is in X direction so set the
#   Y direction to a range -1.0 t0 1.0 over 1 grid

set gInfo(0) -3.00
set gInfo(1)  4.001
set gInfo(2) -1.0
set gInfo(3) 1.0
set gInfo(4) 500
set gInfo(5) 1
set gInfo(6) POINT
set gInfo(7) POINT
set gInfo(8) COLUMN
set gInfo(9) KEEP
set gInfo(10) NEW:ADD:END
set gInfo(11) 0.0
set gInfo(12) -1.0e30
set gInfo(13) -1.0e20
set gInfo(14) 1.0e20
set gInfo(15) NO
set gInfo(16) NO

# GET the center values of each X grid.  This is put into array cX

TUgridInfo 32 gInfo cX 

# CREATE the Grid.  The array Grid will be the base unfilled array 

set Y(0) 0.0
TUdataGrid $nP 1 X X $nP Y Y V Grid Norm gInfo 

# CREATE the grid gHF and fill the gaps using the HF method 

TUdataGrid $nP 1 X X $nP Y Y V gHF Norm gInfo 
TUgridFill1D gHF gInfo X HF -1 1 Norm

# CREATE the grid gHB and fill the gaps using the HB method 

TUdataGrid $nP 1 X X $nP Y Y V gHB Norm gInfo 
TUgridFill1D gHB gInfo X HB -1 1 Norm

# CREATE the grid gHM and fill the gaps using the HM method 

TUdataGrid $nP 1 X X $nP Y Y V gHM Norm gInfo 
TUgridFill1D gHM gInfo X HM -1 1 Norm

# CREATE the grid gLI and fill the gaps using the LI method 

TUdataGrid $nP 1 X X $nP Y Y V gLI Norm gInfo 
TUgridFill1D gLI gInfo X LI -1 1 Norm

# SHOW results graphically
 
GraphicsOn TK ETones SWAP
GenWindow 1 0.15 0.15 0.0 0.85 0.85 0.0  -3. -5.0 0. 4.0 15.0 0.
DefinePlot 1 1

# PLOT the unfilled in grid in blaok

set GoP [list $GphInfo(White) NONE]
Plot2D 1 Xb Yb cX Grid 0 499 LINE $GoP 

# PLOT the HF filled in grid in red

set GoP [list $GphInfo(Red) NONE]
Plot2D 1 Xb Yb cX gHF 0 499 LINE $GoP 

# PLOT the HB filled in grid in green

set GoP [list $GphInfo(Green) NONE]
Plot2D 1 Xb Yb cX gHB 0 499 LINE $GoP 

# PLOT the center filled in grid in cyan

set GoP [list $GphInfo(Cyan) NONE]
Plot2D 1 Xb Yb cX gHM 0 499 LINE $GoP 

# PLOT the linear filled in grid in blue

set GoP [list $GphInfo(Blue) NONE]
Plot2D 1 Xb Yb cX gLI 0 499 LINE $GoP 

# PUT up the plot axis and axis labels

PlotOutlines 1 [list "X" 1.0 "Y" 1.0] [list BOT BOT BOTH BOTH]

# THROW up some labels

TextProp 12 HOLD HOLD
WinClip 1 0
TexT 1 -1.0 15.5 0.0 center "NO FILL" $GphInfo(White)
TexT 1 -1.0 16.5 0.0 center "HF" $GphInfo(Red)
TexT 1 2.0 15.5 0.0 center "HB" $GphInfo(Green)
TexT 1 2.0 16.5 0.0 center "HM" $GphInfo(Cyan)
TexT 1 2.0 17.5 0.0 center "LI" $GphInfo(Blue)

update
      
Sept 21, 2006