| TUgridMath | TCL UTILITIES USER MANUAL | TUgridMath |
|---|
| TUgridMath  | Grid1 Oper Grid2 Grid3 gInfo |
| Grid1 | - | A 2D data grid of data generated through a call to TUdataGrid. | |||||||||||||||||||||||||||
| Oper | - | The grid operation to perform.
|
|||||||||||||||||||||||||||
| Grid2 | - | A 2D data grid of data generated through a call to TUdataGrid. At times input may be either unused or be a return Grid. | |||||||||||||||||||||||||||
| Grid3 | - | The output grid in any operation. | |||||||||||||||||||||||||||
| gInfo | - | The grid information array. This must be the same for both Grid1 and Grid2 and by default will describe the output grid Grid3 |
| NONE |
Grid3 = Grid1 Oper Grid2
are peformed cell by cell. As such both Grid1 and Grid2
must be represented by the same grid information array. When Oper
is a division a check for division by 0 is made at each instance
of the operation. If true the result is set to gInfo(12)
which is the grid bad cell value.
# COMPUTE the rectangulan and cylindrical gradiant of a grid
# SET up the grid information array.
set gInfo(0) -6.0
set gInfo(1) 6.0
set gInfo(2) -6.0
set gInfo(3) 6.0
set gInfo(4) 100
set gInfo(5) 100
set gInfo(6) POINT
set gInfo(7) POINT
set gInfo(8) COLUMN
set gInfo(9) IGNORE
set gInfo(10) NEW:ADD:END
set gInfo(11) -1
set gInfo(12) -5
set gInfo(13) -1.0e30
set gInfo(14) 1.0e30
set gInfo(15) NO
set gInfo(16) NO
# SET up a data set consisting of three Gaussians centered at (-3,-3),
# (-3, 3) and at (3, 0). Each has a different intensity.
set nP 0
set nG [expr $gInfo(4) * $gInfo(5)]
for { set I 0 } { $I < $nG } { incr I } {
TUgridInfo 20 gInfo rV $I
set X($nP) $rV(2)
set Y($nP) $rV(3)
set R [expr ($X($nP)-3.0) * ($X($nP)-3.0) + ($Y($nP)-3.0) * ($Y($nP)-3.0)]
set A [expr exp(-$R / 6.0)]
set R [expr ($X($nP)-3.0) * ($X($nP)-3.0) + ($Y($nP)+3.0) * ($Y($nP)+3.0)]
set B [expr 3.0 * exp(-$R / 6.0)]
set R [expr ($X($nP)+3.0) * ($X($nP)+3.0) + $Y($nP)*$Y($nP)]
set C [expr 4.0 * exp(-$R / 6.0)]
set V($nP) [expr $A + $B - $C ]
incr nP
}
# GRID the data set
TUdataGrid $nP 1 X X 1 Y Y V gV Norm gInfo
# SET up the plot basics. There are a total of 5 plots defined here.
set GphInfo(xScrL) 500
set GphInfo(yScrL) 760
GraphicsOn TK ETones SWAP
GenWindow 1 0.0 0.0 0.0 1.0 1.0 0.0 0. 0. 0. 1. 1. 0. XY
set WinInfo(2,corFmt) 1
RelWindow 2 1 177.0 515.0 0. 377. 715. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 2 2 $gInfo(4) $gInfo(5)
set WinInfo(4,corFmt) 1
RelWindow 4 1 75.0 290.0 0. 275. 490. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 4 4 $gInfo(4) $gInfo(5)
set WinInfo(5,corFmt) 1
RelWindow 5 1 280.0 290.0 0. 480. 490. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 5 5 $gInfo(4) $gInfo(5)
set WinInfo(6,corFmt) 1
RelWindow 6 1 75.0 65.0 0. 275. 265. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 6 6 $gInfo(4) $gInfo(5)
set WinInfo(7,corFmt) 1
RelWindow 7 1 280.0 65.0 0. 480. 265. 0. -6. -6. 0. 6. 6. 0.
DefinePlot 7 7 $gInfo(4) $gInfo(5)
# SET up the color map to run from -4.5 to 4.5
PLTcolorMap -4.1 4.1 LINEAR 0 cA
# PLOT the gaussians
Plot3D 2 Xb Yb Dummy Dummy gV AUTO Dummy cA
# COMPUTE the rectangular gradient of the grid and plot both components
TUgridMath gV GRAD gdX gdY gInfo
PLTcolorMap -2.5 2.5 LINEAR 0 cA
Plot3D 4 Xb Yb Dummy Dummy gdX AUTO Dummy cA
Plot3D 5 Xb Yb Dummy Dummy gdY AUTO Dummy cA
# COMPUTE the cylindrical gradient of the grid and plot both components
TUgridMath gV GRADRCY gdP gdR gInfo
PLTcolorMap -5.5 5.5 LINEAR 0 cA
Plot3D 6 Xb Yb Dummy Dummy gdP AUTO Dummy cA
Plot3D 7 Xb Yb Dummy Dummy gdR AUTO Dummy cA
# THROW up the axis. Only annotate lower left-hand plot
PlotOutlines 2 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 4 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 5 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
PlotOutlines 6 [list "X" 1.0 "Y" 1.0] [list BOT BOT BOTH BOTH]
PlotOutlines 7 [list "" 1.0 "" 1.0] [list NONE NONE BOTH BOTH]
# LABEL the plots
TextProp 12 HOLD HOLD
WinClip 2 0
TexT 2 0.0 6.50 0.0 center "ORIGINAL" $GphInfo(White)
WinClip 4 0
TexT 4 0.0 6.50 0.0 center "dG/dX" $GphInfo(White)
WinClip 5 0
TexT 5 0.0 6.50 0.0 center "dG/dY" $GphInfo(White)
WinClip 6 0
TexT 6 0.0 6.50 0.0 center "(1.0/R)dG/dP" $GphInfo(White)
WinClip 7 0
TexT 7 0.0 6.50 0.0 center "dG/dR" $GphInfo(White)
update
| Sept 24, 2006 |
|---|