| 1 |
#!/bin/csh -f |
| 2 |
# Changed this to csh -f. The -f option has been added after a |
| 3 |
# report that this script failed for a tcsh user who had a .cshrc file. |
| 4 |
# For Cygwin users, link your tcsh to csh, i.e., ln -s /bin/tcsh /bin/csh, |
| 5 |
# or obtain a regular csh from somewhere. |
| 6 |
#%// BK 27-Apr-2002 |
| 7 |
# |
| 8 |
# plotoffsets for gmt3-3 |
| 9 |
# used by Doris software for plotting of offset vectors after fine. |
| 10 |
# plotting magnitude background may require some diskspace |
| 11 |
# (subx, suby..) |
| 12 |
# bg assumed to be in one file, size=(width*height); width=pN-p0+1 |
| 13 |
# BK 16-May-2000 |
| 14 |
# sleeps & calls viewanddel instead of gv, for Doris software. |
| 15 |
#%// BK 19-Jul-2000 |
| 16 |
### RCS info ##### |
| 17 |
#%// BK 17-May-2000 |
| 18 |
#%// $Revision: 3.15 $ $Date: 2005/08/26 08:54:00 $ |
| 19 |
# Developers: |
| 20 |
# Bert Kampes |
| 21 |
# Lennert van den Berg |
| 22 |
################ |
| 23 |
################ |
| 24 |
|
| 25 |
# TODO: |
| 26 |
# -plot unit offset vectors |
| 27 |
# (this is pretty difficult, since normalized, what to plot, added it |
| 28 |
# in plotcpm for error vectors, bk 15 mar01) |
| 29 |
#%// BK 19-Jul-2000 |
| 30 |
|
| 31 |
### Handle input. |
| 32 |
# give doris time to write result file |
| 33 |
sleep 1 |
| 34 |
set PRG = `basename "$0"` |
| 35 |
set VER = "v1.0, part of Doris InSAR software" |
| 36 |
set AUT = "TUDelft, (c)1999-2010" |
| 37 |
echo "$PRG $VER, $AUT" |
| 38 |
echo " " |
| 39 |
|
| 40 |
### |
| 41 |
set USAGE = "0" #synopsis |
| 42 |
set HELP = "0" #exit afterwards |
| 43 |
set IFILE = "interferogram.out" # arg 1 default |
| 44 |
# args 2:5 (default) file dimension (plot dim.) |
| 45 |
@ L0 = 1 |
| 46 |
@ LN = 25000 |
| 47 |
@ P0 = 1 |
| 48 |
@ PN = 4900 |
| 49 |
set THRESHOLD = "0.4" # arg6 default |
| 50 |
set SLCFILE = "" # arg7 optional |
| 51 |
set SLCFORMAT = "" |
| 52 |
set DOBG = "0" # default (not possible w/o l0,lN,p0,pN |
| 53 |
|
| 54 |
switch ( $#argv ) |
| 55 |
case '7': |
| 56 |
set DOBG = "1" |
| 57 |
set SLCFILE = "$7" |
| 58 |
# ||| fall through ||| |
| 59 |
# |
| 60 |
case '6': |
| 61 |
set THRESHOLD = "$6" |
| 62 |
# ||| fall through ||| |
| 63 |
# |
| 64 |
case '5': |
| 65 |
@ L0 = $2 |
| 66 |
@ LN = $3 |
| 67 |
@ P0 = $4 |
| 68 |
@ PN = $5 |
| 69 |
# ||| fall through ||| |
| 70 |
# |
| 71 |
case '2': |
| 72 |
case '1': |
| 73 |
set IFILE = $1 |
| 74 |
breaksw |
| 75 |
# --- no fall through --- |
| 76 |
# |
| 77 |
default: |
| 78 |
set HELP = "1" |
| 79 |
endsw |
| 80 |
if ( $#argv == 2) set THRESHOLD = "$2" |
| 81 |
# Check input |
| 82 |
if ( ! -r "$IFILE" ) then |
| 83 |
echo " input file: $IFILE cannot be read." |
| 84 |
set HELP = "1" |
| 85 |
endif |
| 86 |
|
| 87 |
# Check if something went wrong |
| 88 |
set MORE = more; |
| 89 |
less >& /dev/null |
| 90 |
if ( $status == 0 ) set MORE = 'less -de' |
| 91 |
echo "Using as pager program: $MORE" |
| 92 |
if ( $HELP ) set USAGE = "1" |
| 93 |
if ( $USAGE ) then |
| 94 |
#cat << __EOF_USAGE | more -d |
| 95 |
cat << __EOF_USAGE | $MORE |
| 96 |
|
| 97 |
----------------------------------------------------------------------- |
| 98 |
|
| 99 |
$PRG -- Program to plot offset vectors from Doris |
| 100 |
Position, correlation, and background image can be plotted. |
| 101 |
|
| 102 |
SYNOPSIS: |
| 103 |
$PRG ifile [linelo hi pixlo hi [threshold [slcfile]]] |
| 104 |
|
| 105 |
ifile: Resultfile from Doris [mandatory arg] |
| 106 |
linelo: First azimuth line. [default: 1] |
| 107 |
linehi: Last azimuth line. [default: 25000] |
| 108 |
pixlo: First range pixel. [default: 1] |
| 109 |
pixhi: Last range pixel. [default: 4900] |
| 110 |
threshold: Only plot estimated with correlation above threshold. |
| 111 |
[default: 0.4] |
| 112 |
slcfile: Complex raw file. Magnitude is used as background image. |
| 113 |
(format can be complex real4 or short int.) |
| 114 |
|
| 115 |
EXAMPLE: |
| 116 |
$PRG interferogram.out 1 25000 1 4900 0.4 slcfile.raw |
| 117 |
|
| 118 |
PROG may depend on gawk or nawk and not work with std awk... |
| 119 |
|
| 120 |
----------------------------------------------------------------------- |
| 121 |
|
| 122 |
__EOF_USAGE |
| 123 |
endif |
| 124 |
if ( $HELP ) then |
| 125 |
#cat << __EOF_HELP | more -de |
| 126 |
cat << __EOF_HELP | $MORE |
| 127 |
|
| 128 |
ifile is the interferogram result file from the Doris software, see |
| 129 |
this script for details. Somewhere the fine output section should be |
| 130 |
present, containing lines such as: |
| 131 |
|
| 132 |
******************************************************************* |
| 133 |
*_Start_fine_coreg |
| 134 |
******************************************************************* |
| 135 |
Initial offsets (l,p): 212, 18 |
| 136 |
Window size for correlation (l,p): 80, 80 |
| 137 |
Max. offset that can be estimated: 40 |
| 138 |
Peak search ovs window (l,p): 16, 16 |
| 139 |
Oversampling factor: 32 |
| 140 |
Number_of_correlation_windows: 101 |
| 141 |
Number posL posP offsetL offsetP correlation |
| 142 |
0 27 27 241.06 3.19 0.42 |
| 143 |
1 27 127 241.36 3.29 0.72 |
| 144 |
... |
| 145 |
99 4733 971 241.86 3.50 0.48 |
| 146 |
|
| 147 |
******************************************************************* |
| 148 |
* End_fine_coreg:_NORMAL |
| 149 |
******************************************************************* |
| 150 |
|
| 151 |
See also: cpxfiddle, GMT. |
| 152 |
|
| 153 |
__EOF_HELP |
| 154 |
exit -1 |
| 155 |
endif |
| 156 |
|
| 157 |
|
| 158 |
### Initialize variables |
| 159 |
set TMPDIR = "." |
| 160 |
if ( ! -w "$TMPDIR" ) then |
| 161 |
set TMPDIR = "/tmp" |
| 162 |
endif |
| 163 |
if ( ! -w "$TMPDIR" ) then |
| 164 |
echo "Sorry, directory $TMPDIR seems not writable, exiting." |
| 165 |
exit -2 |
| 166 |
endif |
| 167 |
set PSFILE = $TMPDIR/tmpplot.ps |
| 168 |
set TMPFILE = $TMPDIR/tmpdata.plot |
| 169 |
rm -f $PSFILE $TMPFILE |
| 170 |
|
| 171 |
### ifile is transformed to tmpfile with columns: |
| 172 |
# 1: window number |
| 173 |
# 2: location x |
| 174 |
# 3: location y |
| 175 |
# 4: offset x |
| 176 |
# 5: offset y |
| 177 |
# 6: correlation |
| 178 |
|
| 179 |
|
| 180 |
### Create tmpfile with only data: grep fine section with awk and |
| 181 |
### remove trailing comment lines (5) and tailing comment (2) |
| 182 |
### |
| 183 |
###1: *_Start_fine_coreg |
| 184 |
###2: ******************************************************************* |
| 185 |
###3: Oversampling factor: 16 |
| 186 |
###4: Number_of_correlation_windows: 100 |
| 187 |
###5: Number posL posP offsetL offsetP correlation |
| 188 |
###6: 0 27 27 241.06 3.19 0.42 |
| 189 |
### ... |
| 190 |
###x: 99 4733 971 241.06 3.50 0.41 |
| 191 |
###x+1: |
| 192 |
###x+2: ******************************************************************* |
| 193 |
###x+3: * End_fine_coreg:_NORMAL |
| 194 |
###x+4: ******************************************************************* |
| 195 |
### |
| 196 |
# |
| 197 |
###################################################################### |
| 198 |
### find out if nawk is available, since awk seems not to know atan2? |
| 199 |
set AWK = awk; |
| 200 |
echo 1 | /usr/xpg4/bin/awk '{print 1}' >& /dev/null |
| 201 |
if ( $status == 0 ) set AWK = '/usr/xpg4/bin/awk' |
| 202 |
echo 1 | gawk '{print 1}' >& /dev/null |
| 203 |
if ( $status == 0 ) set AWK = 'gawk' |
| 204 |
echo 1 | nawk '{print 1}' >& /dev/null |
| 205 |
if ( $status == 0 ) set AWK = 'nawk' |
| 206 |
echo "Using as awk program: $AWK" |
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
###################################################################### |
| 211 |
### 1. Grep between start stop pair: |
| 212 |
echo "TMPFILE BEING GENERATED: step1" |
| 213 |
$AWK '/Start_fine/, /End_fine/' $IFILE >! $TMPFILE.$$ |
| 214 |
### 2. Get number of points (starting at window 0): |
| 215 |
@ NUMPOINTS = `$AWK '/Number_of/ {print $2}' $TMPFILE.$$` |
| 216 |
#### 3. Reduce file only to data: |
| 217 |
#tail -n +6 $TMPFILE.$$ | head -n $NUMPOINTS >! $TMPFILE |
| 218 |
#### 4. Remove above threshold (here is most easy...) |
| 219 |
#$AWK -v t=$THRESHOLD '$6>=t' $TMPFILE >! $TMPFILE.$$ |
| 220 |
#mv -f $TMPFILE.$$ $TMPFILE |
| 221 |
# |
| 222 |
#%// BK 25-Sep-2001: following bug report by Irek Baran. |
| 223 |
echo "TMPFILE BEING GENERATED: step2" |
| 224 |
#$AWK -v n=$NUMPOINTS -v t=$THRESHOLD '{if(NR>5&&NR<n+6){if ($6>t){print $0}}}' $TMPFILE.$$ > $TMPFILE |
| 225 |
#rm -f $TMPFILE.$$ |
| 226 |
|
| 227 |
#test how to pass arguments. failsave seems to be: #echo 111 | $AWK '{print '$t'}' |
| 228 |
#%// BK 16-Jun-2003 |
| 229 |
#$AWK '{if(NR>5&&NR<'$NUMPOINTS'+6){if ($6>'$THRESHOLD'){print $0}}}' $TMPFILE.$$ > $TMPFILE |
| 230 |
# v3.16: more info lines in resfile, skip more. |
| 231 |
$AWK '{if(NR>10&&NR<'$NUMPOINTS'+11){if ($6>'$THRESHOLD'){print $0}}}' $TMPFILE.$$ > $TMPFILE |
| 232 |
rm -f $TMPFILE.$$ |
| 233 |
echo "TMPFILE GENERATED" |
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
### Check if we have points ########################################## |
| 238 |
@ NP = `$AWK '{l=NR};END{print l}' $TMPFILE` |
| 239 |
echo "$NP points above coherence threshold $THRESHOLD found." |
| 240 |
if ( $NP < 1 ) then |
| 241 |
echo "exiting..." |
| 242 |
rm -f $TMPFILE |
| 243 |
exit |
| 244 |
endif |
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
###################################################################### |
| 249 |
### Plot: location of windows / wtests |
| 250 |
# plotted are: |
| 251 |
# - normalized observations (offsets) |
| 252 |
# - optionally background of magnitude image |
| 253 |
# - correlation as circles (legenda... o=1), thickness arrow? |
| 254 |
|
| 255 |
|
| 256 |
###################################################################### |
| 257 |
echo "Setting GMT defaults" |
| 258 |
# PAPER_MEDIA a4+ \ |
| 259 |
gmtset MEASURE_UNIT cm \ |
| 260 |
PAPER_MEDIA a4 \ |
| 261 |
PAGE_ORIENTATION portrait \ |
| 262 |
ANOT_FONT Helvetica \ |
| 263 |
ANOT_FONT_SIZE 10p \ |
| 264 |
ANOT_OFFSET 0.2 \ |
| 265 |
BASEMAP_AXES WeSn \ |
| 266 |
LABEL_FONT Helvetica \ |
| 267 |
LABEL_FONT_SIZE 10 \ |
| 268 |
UNIX_TIME_POS -2/-2 \ |
| 269 |
D_FORMAT %lg |
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
###################################################################### |
| 274 |
### Labeling of axis. |
| 275 |
echo " +++ Plotting the observed offset vectors (normalized) +++" |
| 276 |
set TITLE = "Offset_vectors_(Corr_>_$THRESHOLD)" |
| 277 |
set XLABEL = "Azimuth" |
| 278 |
set YLABEL = "Range" |
| 279 |
# height=y=azimuth, assume 5*stretched |
| 280 |
@ WIDTH = ( ( $PN - $P0 ) + 1) |
| 281 |
@ HEIGHT = ( ( $LN - $L0 ) + 1) |
| 282 |
set SLCFORMAT = "cr4" |
| 283 |
if ( $DOBG ) then |
| 284 |
# filewidth should be used, but is equal... |
| 285 |
#@ SIZECI2 = $WIDTH * $HEIGHT * 4 |
| 286 |
#@ SIZECR4 = $WIDTH * $HEIGHT * 8 |
| 287 |
set SIZECI2 = `awk 'BEGIN{print '$WIDTH' * '$HEIGHT' * 4 }'` # MA avoid integer overflow |
| 288 |
set SIZECR4 = `awk 'BEGIN{print '$WIDTH' * '$HEIGHT' * 8 }'` |
| 289 |
set FSIZE = `ls -l $SLCFILE | $AWK '{print $5}'` |
| 290 |
if ( $FSIZE == $SIZECI2 ) then |
| 291 |
echo " *** File format ${SLCFILE}: complex short." |
| 292 |
set SLCFORMAT = ci2 |
| 293 |
else if ( $FSIZE == $SIZECR4 ) then |
| 294 |
echo " *** File format ${SLCFILE}: complex float." |
| 295 |
set SLCFORMAT = cr4 |
| 296 |
else |
| 297 |
echo " *** Sorry, no background, file format could not be determined." |
| 298 |
set DOBG = "0" |
| 299 |
endif |
| 300 |
endif |
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
###################################################################### |
| 305 |
# GMT options |
| 306 |
@ TICKSL = $HEIGHT / 7 |
| 307 |
@ TICKSP = $WIDTH / 7 |
| 308 |
set RANGE = "-R$P0/$PN/$L0/$LN" |
| 309 |
set GENOPT = "-P -: " |
| 310 |
set FRAME = "-B"$TICKSP":"$YLABEL":/"$TICKSL":"$XLABEL"::."$TITLE":" |
| 311 |
set XSIZE = "16" |
| 312 |
set YSIZE = "0" |
| 313 |
@ NUMPIXS = ( $WIDTH * $HEIGHT ) |
| 314 |
# size paper, largest size $XSIZE |
| 315 |
# actually should go to landscape in that case... |
| 316 |
# strict stretching ERS1/2 only... |
| 317 |
set RATIO = "5" |
| 318 |
@ HEIGHT = $HEIGHT / $RATIO |
| 319 |
if ( $HEIGHT > $WIDTH ) then |
| 320 |
set YSIZE = $XSIZE |
| 321 |
#%// Bert Kampes, 31-Mar-2005: changed to awk from bc |
| 322 |
#set XSIZE = `echo "scale=3; $WIDTH/$HEIGHT*$YSIZE" | bc -l` |
| 323 |
set XSIZE = `echo "$WIDTH $HEIGHT $YSIZE" | $AWK '{printf "%f", $1 / $2 * $3}'` |
| 324 |
else |
| 325 |
#%// Bert Kampes, 31-Mar-2005: changed to awk from bc |
| 326 |
#set YSIZE = `echo "scale=3; $HEIGHT/$WIDTH*$XSIZE" | bc -l` |
| 327 |
set YSIZE = `echo "$HEIGHT $WIDTH $XSIZE" | $AWK '{printf "%f", $1 / $2 * $3}'` |
| 328 |
endif |
| 329 |
echo " *** Size plot (x,y): $XSIZE $YSIZE" |
| 330 |
set SIZE = "-JX$XSIZE/$YSIZE" |
| 331 |
|
| 332 |
|
| 333 |
###################################################################### |
| 334 |
### First plot background if requested. |
| 335 |
# for now, otherwize error |
| 336 |
set GRDFILE = $$.grd |
| 337 |
set CPTFILE = $$.cpt |
| 338 |
if ( $DOBG ) then |
| 339 |
echo " *** Making background plot..." |
| 340 |
set SUBX = "1" |
| 341 |
set SUBY = "1" |
| 342 |
# try to limit tmp GRDFILE to 10MB (2.500.000 binary float pixels) |
| 343 |
if ( $NUMPIXS > 10000000 ) then # eg. 25.000 * 5.000 |
| 344 |
set SUBY = "15" # else > 10MB tmpfile |
| 345 |
set SUBX = "3" # else > 10MB tmpfile |
| 346 |
else if ( $NUMPIXS > 5000000 ) then # eg. 10.000 * 5000 |
| 347 |
set SUBY = "10" # else > 10MB tmpfile |
| 348 |
set SUBX = "2" # else > 10MB tmpfile |
| 349 |
else if ( $NUMPIXS > 1250000 ) then # eg. 1500 * 5000 |
| 350 |
set SUBY = "5" |
| 351 |
endif |
| 352 |
echo " *** Subsampling data with factors (x,y): $SUBX $SUBY" |
| 353 |
# |
| 354 |
# assume total file has to be plotted (call from Doris...) |
| 355 |
#echo \\n" Mirroring in horiz, rather do it with GMT, but how?" : -Jx/-y ! |
| 356 |
set PROG = "cpxfiddle -w$WIDTH -f$SLCFORMAT -qmag -e0.2 -ofloat -M$SUBX/$SUBY -- $SLCFILE" |
| 357 |
|
| 358 |
# correct for GMT, subsampling output = ceil ((P-p+1)/sub) |
| 359 |
# outputlines after subsampling = ceil((P-p+1)/sub) |
| 360 |
#subsampling |
| 361 |
#set NUMX = `echo "$P0 $PN $SUBX" | $AWK '{printf "%i", ($2-$1)/$3+1}'` |
| 362 |
#set NUMY = `echo "$L0 $LN $SUBY" | $AWK '{printf "%i", ($2-$1)/$3+1}'` |
| 363 |
#multilooking |
| 364 |
set NUMX = `echo "$P0 $PN $SUBX" | $AWK '{print int(($2-$1+1)/$3)}'` |
| 365 |
set NUMY = `echo "$L0 $LN $SUBY" | $AWK '{print int(($2-$1+1)/$3)}'` |
| 366 |
echo " *** Number of output pixels (x,y): $NUMX $NUMY" |
| 367 |
|
| 368 |
#set EAST = `echo "$P0+($NUMX-1)*$SUBX" | bc -l` |
| 369 |
#set NORTH = `echo "$L0+($NUMY-1)*$SUBY" | bc -l` |
| 370 |
#%// Bert Kampes, 31-Mar-2005: changed to awk from bc |
| 371 |
set EAST = `echo "$P0 $NUMX $SUBX" | $AWK '{printf "%f", $1 + ( $2 - 1 ) * $3}'` |
| 372 |
set NORTH = `echo "$L0 $NUMY $SUBY" | $AWK '{printf "%f", $1 + ( $2 - 1 ) * $3}'` |
| 373 |
set BKRANGE = "-R$P0/$EAST/$L0/$NORTH" |
| 374 |
echo " *** GMT range: $BKRANGE" |
| 375 |
|
| 376 |
set GRDFILE = $$.grd |
| 377 |
set INC = "-I$SUBX/$SUBY" |
| 378 |
set IFORMAT = "-Zf" # binary float values |
| 379 |
echo " Calling: $PROG | xyz2grd -G$GRDFILE $BKRANGE $INC $IFORMAT" |
| 380 |
$PROG | xyz2grd -G$GRDFILE $BKRANGE $INC $IFORMAT |
| 381 |
# |
| 382 |
set CPTFILE = $$.cpt |
| 383 |
set CPTNAME = gray |
| 384 |
echo " Calling: grd2cpt $GRDFILE -C$CPTNAME -Z >! $CPTFILE" |
| 385 |
grd2cpt $GRDFILE -C$CPTNAME -Z >! $CPTFILE |
| 386 |
# |
| 387 |
# lower left is O of coord. system, while upperleft for grd file -> mirror horiz. |
| 388 |
#OK.. grdimage $GRDFILE $SIZE -C$CPTFILE -P -K -T >! $PSFILE |
| 389 |
# T slow, large: grdimage $GRDFILE $SIZE -C$CPTFILE -P -K -T >! $PSFILE |
| 390 |
set BKSIZE = "-JX$XSIZE/-$YSIZE" |
| 391 |
echo " Calling: grdimage $GRDFILE $BKSIZE -C$CPTFILE -P -K >! $PSFILE" |
| 392 |
grdimage $GRDFILE $BKSIZE -C$CPTFILE -P -K >! $PSFILE |
| 393 |
# Tidy tidy tidy |
| 394 |
echo " removing grdfile, cptfile: $GRDFILE $CPTFILE" |
| 395 |
rm -f $GRDFILE |
| 396 |
rm -f $CPTFILE |
| 397 |
|
| 398 |
# Set Overlay for next if this was first, else initialize new plot system |
| 399 |
set GMTFLAGS = "-K -O -N $GENOPT $RANGE $FRAME $SIZE -U -Sc -W6/255/0/0" |
| 400 |
else |
| 401 |
set GMTFLAGS = "-K -N $GENOPT $RANGE $FRAME $SIZE -U -Sc -W6/255/0/0" |
| 402 |
endif |
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
###################################################################### |
| 407 |
### Plot the location circles, where correl=size. |
| 408 |
echo " +++ Plotting location circles, size (cm) is correlation +++" |
| 409 |
$AWK '{print $2, $3, $6}' $TMPFILE | psxy $GMTFLAGS >> $PSFILE |
| 410 |
# |
| 411 |
set GMTFLAGS = "-K -O -N $GENOPT $RANGE $SIZE -Sc -W6/255/0/0" |
| 412 |
echo " +++ Plotting legenda circle +++" |
| 413 |
echo "$L0 $P0 1.0" | psxy -X-1.0 -Y-1.0 $GMTFLAGS >> $PSFILE |
| 414 |
echo "$L0 $P0 0.5" | psxy -Y-0.25 $GMTFLAGS >> $PSFILE |
| 415 |
#pstext:(x, y, size, angle, fontno, justify, text) |
| 416 |
set GMTFLAGS = "-K -O -N $GENOPT $RANGE $SIZE" |
| 417 |
echo "$L0 $P0 12 0 0 CM correlation" | pstext -Y1.0 $GMTFLAGS >> $PSFILE |
| 418 |
echo "$L0 $P0 12 0 0 LM 1.0" | pstext -X0.5 -Y-0.5 $GMTFLAGS >> $PSFILE |
| 419 |
echo "$L0 $P0 12 0 0 LM 0.5" | pstext -Y-0.5 $GMTFLAGS >> $PSFILE |
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
###################################################################### |
| 424 |
### Plot normalized offset vectors. |
| 425 |
# -G fill |
| 426 |
# -Sv arrowwidth/headlength/headwidth [0.075c/0.3c/0.25c] |
| 427 |
set GMTFLAGS = "-N -O -K -X0.5 -Y1.25 $GENOPT $RANGE $SIZE -Sv0.04/0.25/0.125 -G0/0/255 -W2/0/0/255" |
| 428 |
# |
| 429 |
echo "START STDL computation" |
| 430 |
set MINL = `$AWK 'NR==1{m=$4}$4<m{m=$4}END{print m}'<$TMPFILE` |
| 431 |
set MAXL = `$AWK 'NR==1{m=$4}$4>m{m=$4}END{print m}'<$TMPFILE` |
| 432 |
set MEANL = `$AWK '{s += $4}END{printf "%f", s/NR}'<$TMPFILE` |
| 433 |
# set MEANL = $MINL # Lennert |
| 434 |
set STDL = `$AWK '{sq += ( $4 - '$MEANL' ) * ( $4 - '$MEANL' )};END{printf "%f", sq / ( NR - 1 )}'<$TMPFILE` |
| 435 |
#set STDL = `$AWK -v m=$MEANL '{sq+=($4-m)*($4-m)};END{print sq/(NR-1)}'<$TMPFILE` |
| 436 |
# |
| 437 |
echo "START STDP computation" |
| 438 |
set MINP = `$AWK 'NR==1{m=$5}$5<m{m=$5}END{print m}'<$TMPFILE` |
| 439 |
set MAXP = `$AWK 'NR==1{m=$5}$5>m{m=$5}END{print m}'<$TMPFILE` |
| 440 |
set MEANP = `$AWK '{s += $5}END{printf "%f", s / NR}'<$TMPFILE` |
| 441 |
# set MEANP = $MINP # Lennert |
| 442 |
set STDP = `$AWK '{sq += ( $5 - '$MEANP' ) * ( $5 - '$MEANP' )};END{printf "%f", sq / ( NR - 1 )}'<$TMPFILE` |
| 443 |
#set STDP = `$AWK -v m=$MEANP '{sq+=($5-m)*($5-m)};END{print sq/(NR-1)}'<$TMPFILE` |
| 444 |
echo " *** min, max, mean, std (line): $MINL $MAXL $MEANL $STDL" |
| 445 |
echo " *** min, max, mean, std (pixel): $MINP $MAXP $MEANP $STDP" |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
###################################################################### |
| 450 |
### Normalize vectors by subtracting mean-2: |
| 451 |
### plot arrows as they are, normalized by max length ? (always longest==3cm?) |
| 452 |
#no cause then offset 1000 <> 1001 is no difference while it is the same as 10<>11 |
| 453 |
# thus scale length by l-max |
| 454 |
echo " *** Normalizing offset line by subtracting: $MEANL - 1" |
| 455 |
echo " *** Normalizing offset pixel by subtracting: $MEANP - 1" |
| 456 |
# |
| 457 |
#$AWK -v wl=$MEANL -v wp=$MEANP \ |
| 458 |
# '{ \ |
| 459 |
# {l=$4-wl-1.} \ |
| 460 |
# {p=$5-wp-1.} \ |
| 461 |
|
| 462 |
echo "start psxy vector drawing" |
| 463 |
# {dir=57.3*atan2(l,p)} \ |
| 464 |
# possibly gawk or nawk define atan2, not standard awk... |
| 465 |
$AWK '{{l = $4 - '$MEANL' - 1.0 }{p = $5 - '$MEANP' - 1.0 } \ |
| 466 |
{l = l + 0.0000001} {p = p + 0.0000001} \ |
| 467 |
{dir = 57.3 * atan2(l,p)} \ |
| 468 |
{scale = 1.5} \ |
| 469 |
{len = scale * sqrt ( l * l + p * p )} \ |
| 470 |
{printf "%.1f %.1f %.1f %.1f\n", $2, $3, dir, len} \ |
| 471 |
}' \ |
| 472 |
$TMPFILE | \ |
| 473 |
psxy $GMTFLAGS >> $PSFILE |
| 474 |
echo "...finished psxy vector drawing" |
| 475 |
|
| 476 |
|
| 477 |
### Print info on points as text (# offl offp). |
| 478 |
set GMTFLAGS = "-M -Wo -D0/2.5 -O -N -K $GENOPT $RANGE $SIZE" |
| 479 |
echo "> $LN $P0 8 0 0 LB 0.4 15 l" >! $TMPFILE.2 |
| 480 |
$AWK '{printf "@;255/0/0; @:10: %4.0i @;0/0/0; @:8: (%4.2f;%4.2f) - \n", $1,$4,$5}' $TMPFILE >> $TMPFILE.2 |
| 481 |
# Avoid overflow with head. |
| 482 |
head -n 60 $TMPFILE.2 | pstext $GMTFLAGS >> $PSFILE |
| 483 |
rm -f $TMPFILE.2 |
| 484 |
|
| 485 |
|
| 486 |
### Add the window numbers (last overlay, no -K (close plot system)). |
| 487 |
#pstext: (x, y, size(pts), angle(ccw), fontno, justify, text) |
| 488 |
set GMTFLAGS = "-O -N -G0/0/0 $GENOPT $RANGE $SIZE" |
| 489 |
echo " Calling: pstext $GMTFLAGS >> $PSFILE" |
| 490 |
#green, 14pts, RightTop BottomLeft |
| 491 |
$AWK '{printf "%.1f %.1f 10 0 0 RT %s\n", $2, $3, $1}' $TMPFILE | pstext $GMTFLAGS >> $PSFILE |
| 492 |
|
| 493 |
|
| 494 |
# calls from Doris, cannot interactive... |
| 495 |
#%// BK 19-Jul-2000 |
| 496 |
echo " Calling: viewanddel" |
| 497 |
rm -f $TMPFILE $GRDFILE $CPTFILE |
| 498 |
viewanddel $PSFILE |
| 499 |
|
| 500 |
### EOF |
| 501 |
|