| 1 |
#!/bin/csh -f |
| 2 |
### |
| 3 |
# Script to plot magnitude/or phase of complex file (pix interleaved) |
| 4 |
# (major row order, pixel interleaved, 2B=short) with GMT |
| 5 |
# based on scripts by: Falk Amelung, Ramon Hanssen. |
| 6 |
# requires: c++ program cpxfiddle |
| 7 |
# scheme: |
| 8 |
# 1. echo binary file to screen, pipe to xyz2grd |
| 9 |
# 2. xyz2grd (gmt) |
| 10 |
# 3. grdimage (gmt) |
| 11 |
# 4. scalebar (psscale gmt) |
| 12 |
# 5. title filename (psxy gmt) |
| 13 |
### RCS ### |
| 14 |
# $Revision: 3.5 $ $Date: 2003/04/14 06:25:52 $ |
| 15 |
# BK 10-May-2000 |
| 16 |
# |
| 17 |
# option for float file, simple plot only, use cat, -fr4 |
| 18 |
# TODO: -C input cpt file ipv. output name... |
| 19 |
#%// BK 19-Jun-2000 |
| 20 |
# TODO: magnitude image: histeq, also in bg plot plotoffsets |
| 21 |
#%// BK 09-Apr-2001 |
| 22 |
### |
| 23 |
set PRG = `basename "$0"` |
| 24 |
set VER = "v2.1, FMR software" |
| 25 |
set AUT = "Bert Kampes, (c)1999-2000" |
| 26 |
echo "$PRG $VER, $AUT" \\n |
| 27 |
|
| 28 |
|
| 29 |
### Set defaults, check later |
| 30 |
set FIRSTLINE = "1" # -l default |
| 31 |
set FIRSTPIXEL = "1" # -L default |
| 32 |
set LASTLINE = "0" # -p correct later if not user set |
| 33 |
set LASTPIXEL = "0" # -P correct later if not user set |
| 34 |
set EXP = "1.0" # -e default |
| 35 |
set SCALE = "1.0" # -s default |
| 36 |
set FFORMAT = "cr4" # -f default mph file |
| 37 |
set OUTPUT = "mag" # -q do magnitude |
| 38 |
set XSUB = "1" # -X sub sampling factor default |
| 39 |
set YSUB = "1" # -Y sub sampling factor default |
| 40 |
set XMULTILOOK = "1" # -M multilook factor default |
| 41 |
set YMULTILOOK = "1" # -M multilook factor default |
| 42 |
set MIRROR = "" # -m default none passed to prog |
| 43 |
set VERBOSE = "0" # -V |
| 44 |
set DEBUG = "" # -V passed to progs |
| 45 |
@ LINELENGTH = 0 |
| 46 |
|
| 47 |
# GMT |
| 48 |
gmtset MEASURE_UNIT cm \ |
| 49 |
PAPER_MEDIA a4+ \ |
| 50 |
PAGE_ORIENTATION portrait \ |
| 51 |
ANOT_FONT Helvetica \ |
| 52 |
ANOT_FONT_SIZE 10p \ |
| 53 |
ANOT_OFFSET 0.2c \ |
| 54 |
BASEMAP_AXES WeSn \ |
| 55 |
LABEL_FONT Helvetica \ |
| 56 |
LABEL_FONT_SIZE 10 \ |
| 57 |
UNIX_TIME_POS -2c/-2c |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
#set TITLE = "none" # -T title |
| 62 |
set TITLE = "" # -T title |
| 63 |
set XSIZE = "16" # -z largest paper size in cm (?) |
| 64 |
set YSIZE = "0" # -z largest paper size in cm (?) |
| 65 |
set CPTNAME = "0" # -C cpt lookup name |
| 66 |
set CPTZ = "" # -Z discontinuous table by default |
| 67 |
set SCALEBAR = "0" # -S largest paper size in cm (?) |
| 68 |
set LEAVEOPEN = "0" # -K |
| 69 |
set ONLYONEGMT = "1" # default only grdimage |
| 70 |
set TIMESTAMP = "0" # -U |
| 71 |
|
| 72 |
# Script variables |
| 73 |
set CALLGV = "1" # -g default gv |
| 74 |
set PSFILE = "$$.eps" # -o postscript output (default) |
| 75 |
set GRDFILE = "$$.grd" # -G netCDF grd file (default) |
| 76 |
set CPTFILE = "$$.cpt" # created (default) |
| 77 |
|
| 78 |
### Handle input. |
| 79 |
set HELP = "0" |
| 80 |
set OPTIONS = "w:e:s:l:L:p:P:f:q:F:G:c:C:o:z:T:m:M:hKSUVZg" |
| 81 |
set argv = `getopt $OPTIONS $*` |
| 82 |
# Check any input, getopts ok? |
| 83 |
if ( "$?argv" == "0" ) then |
| 84 |
echo "Sorry, no input or parse error." |
| 85 |
exit 1 |
| 86 |
endif |
| 87 |
|
| 88 |
# Process commandline arguments |
| 89 |
while ( "$1" != "--" ) |
| 90 |
switch ( $1 ) |
| 91 |
# Help |
| 92 |
case '-h': |
| 93 |
set HELP = "1" |
| 94 |
breaksw |
| 95 |
# linelength,width |
| 96 |
case '-w': |
| 97 |
@ LINELENGTH = "$2" |
| 98 |
shift |
| 99 |
breaksw |
| 100 |
# exponent |
| 101 |
case '-e': |
| 102 |
set EXP = "$2" |
| 103 |
shift |
| 104 |
breaksw |
| 105 |
# scale |
| 106 |
case '-s': |
| 107 |
set SCALE = "$2" |
| 108 |
shift |
| 109 |
breaksw |
| 110 |
# firstline |
| 111 |
case '-l': |
| 112 |
set FIRSTLINE = "$2" |
| 113 |
shift |
| 114 |
breaksw |
| 115 |
# lastline |
| 116 |
case '-L': |
| 117 |
set LASTLINE = "$2" |
| 118 |
shift |
| 119 |
breaksw |
| 120 |
# firstpixel |
| 121 |
case '-p': |
| 122 |
set FIRSTPIXEL = "$2" |
| 123 |
shift |
| 124 |
breaksw |
| 125 |
# lastpixel |
| 126 |
case '-P': |
| 127 |
set LASTPIXEL = "$2" |
| 128 |
shift |
| 129 |
breaksw |
| 130 |
# input format |
| 131 |
case '-f': |
| 132 |
set FFORMAT = "$2" |
| 133 |
if ( "$FFORMAT" != "ci2" & \ |
| 134 |
"$FFORMAT" != "r4" & \ |
| 135 |
"$FFORMAT" != "cr4" & \ |
| 136 |
"$FFORMAT" != "cr8" ) then |
| 137 |
echo " +++ "WARNING: -f \"$FFORMAT\" not recognized, continuing with \"cr4\" |
| 138 |
set FFORMAT = "cr4" |
| 139 |
endif |
| 140 |
shift |
| 141 |
breaksw |
| 142 |
# what to output |
| 143 |
case '-q': |
| 144 |
set OUTPUT = "$2" |
| 145 |
if ( "$OUTPUT" != "mag" & \ |
| 146 |
"$OUTPUT" != "phase" & \ |
| 147 |
"$OUTPUT" != "real" & \ |
| 148 |
"$OUTPUT" != "imag" & \ |
| 149 |
"$OUTPUT" != "normal" ) then |
| 150 |
echo " +++ "WARNING: -q \"$OUTPUT\" not recognized, continuing with \"mag\" |
| 151 |
set OUTPUT = "mag" |
| 152 |
endif |
| 153 |
shift |
| 154 |
breaksw |
| 155 |
# subsampling -Fx/y |
| 156 |
case '-F': |
| 157 |
set XSUB = `echo "$2" | cut -f1 -d'/'` |
| 158 |
set YSUB = `echo "$2" | cut -f2 -d'/'` |
| 159 |
shift |
| 160 |
breaksw |
| 161 |
# multilooking -Mx/y |
| 162 |
case '-M': |
| 163 |
set XMULTILOOK = `echo "$2" | cut -f1 -d'/'` |
| 164 |
set YMULTILOOK = `echo "$2" | cut -f2 -d'/'` |
| 165 |
shift |
| 166 |
breaksw |
| 167 |
# color table |
| 168 |
case '-c': |
| 169 |
set CPTNAME = "$2" |
| 170 |
shift |
| 171 |
breaksw |
| 172 |
# mirroring |
| 173 |
case '-m': |
| 174 |
set MIRROR = "-m $2" |
| 175 |
if ( "$MIRROR" != "-m YX" & \ |
| 176 |
"$MIRROR" != "-m XY" & \ |
| 177 |
"$MIRROR" != "-m X" & \ |
| 178 |
"$MIRROR" != "-m Y" ) then |
| 179 |
echo " +++ "WARNING: \"$MIRROR\" not recognized, continuing with no mirroring. |
| 180 |
set MIRROR = "" |
| 181 |
endif |
| 182 |
shift |
| 183 |
breaksw |
| 184 |
# color table |
| 185 |
case '-Z': |
| 186 |
set CPTZ = "-Z" |
| 187 |
breaksw |
| 188 |
# paper size |
| 189 |
case '-z': |
| 190 |
set XSIZE = "$2" |
| 191 |
shift |
| 192 |
breaksw |
| 193 |
# scale bar |
| 194 |
case '-S': |
| 195 |
set SCALEBAR = "1" |
| 196 |
set ONLYONEGMT = "0" |
| 197 |
breaksw |
| 198 |
# leave eps open after finish |
| 199 |
case '-K': |
| 200 |
set LEAVEOPEN = "1" |
| 201 |
breaksw |
| 202 |
# title |
| 203 |
case '-T': |
| 204 |
#set TITLE = "$TITLE $2" |
| 205 |
set TITLE = $2 |
| 206 |
set TITLE = "-B/:.${TITLE}:" |
| 207 |
shift |
| 208 |
breaksw |
| 209 |
# timestamp |
| 210 |
case '-U': |
| 211 |
set TIMESTAMP = "1" |
| 212 |
breaksw |
| 213 |
# verbose |
| 214 |
case '-V': |
| 215 |
set VERBOSE = "1" |
| 216 |
set DEBUG = "-V" |
| 217 |
echo " *** Verbose set" |
| 218 |
breaksw |
| 219 |
# postscript file name (output) |
| 220 |
case '-o': |
| 221 |
set PSFILE = $2 |
| 222 |
shift |
| 223 |
breaksw |
| 224 |
# grd file name (output) |
| 225 |
case '-G': |
| 226 |
set GRDFILE = $2 |
| 227 |
shift |
| 228 |
breaksw |
| 229 |
# cpt file name (output) |
| 230 |
case '-C': |
| 231 |
set CPTFILE = $2 |
| 232 |
shift |
| 233 |
breaksw |
| 234 |
# dogv |
| 235 |
case '-g': |
| 236 |
set CALLGV = "0" |
| 237 |
breaksw |
| 238 |
# not recognized pass to GMT |
| 239 |
default: |
| 240 |
echo option: $1 |
| 241 |
echo " +++ non existing option, I will give help later." |
| 242 |
set HELP="1" |
| 243 |
endsw |
| 244 |
shift # next flag |
| 245 |
end # while |
| 246 |
shift # skip the -- |
| 247 |
set CPXFILE = $1 |
| 248 |
if ( "$HELP" == "0" & "X$CPXFILE" == "X" ) then |
| 249 |
echo " +++ WARNING: infile missing" |
| 250 |
set HELP = "1" |
| 251 |
endif |
| 252 |
if ( "$HELP" == "0" ) then |
| 253 |
if ( ! -e $CPXFILE ) then |
| 254 |
echo " +++ WARNING: CPXFILE: $CPXFILE cannot be found" |
| 255 |
set HELP = "1" |
| 256 |
endif |
| 257 |
endif |
| 258 |
# Mandatory options |
| 259 |
if ( "$HELP" == "0" & $LINELENGTH == 0 ) then |
| 260 |
echo " +++ WARNING: -w width option missing" |
| 261 |
set HELP = "1" |
| 262 |
endif |
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
### Set internal script variables |
| 267 |
# Check user input -c |
| 268 |
if ( "$CPTNAME" == "0" ) then # not specified by user |
| 269 |
if ( "$OUTPUT" == "mag" ) then |
| 270 |
set CPTNAME = "gray" # cpt lookup name |
| 271 |
else if ( "$OUTPUT" == "phase" ) then |
| 272 |
#set CPTNAME = "sealand" # cpt lookup name |
| 273 |
set CPTNAME = "rainbow" # cpt lookup name |
| 274 |
else # real/imag |
| 275 |
#set CPTNAME = "sealand" # default |
| 276 |
set CPTNAME = "rainbow" # default |
| 277 |
endif |
| 278 |
endif |
| 279 |
|
| 280 |
|
| 281 |
# Check if help is asked |
| 282 |
if ( "$HELP" == "1" ) then |
| 283 |
#cat << __EOFHD | more -de |
| 284 |
cat << __EOFHD | more |
| 285 |
|
| 286 |
PROGRAM: $PRG -- Produce various eps codes from complex data files. |
| 287 |
|
| 288 |
SYNOPSIS: |
| 289 |
$PRG -w width [-f format==$FFORMAT] [-q out==$OUTPUT] [-e exp==$EXP] [-s sc==$SCALE] |
| 290 |
[-l 1] [-L alllines] [-p 1] [-P width] [-M$XMULTILOOK/$YMULTILOOK | -F$XSUB/$YSUB] |
| 291 |
[-m mirror] [-T title] [-c cptname==$CPTNAME] [-z size==$XSIZE] |
| 292 |
[-o epsfile] [-G grdfile] [-C cptfile] |
| 293 |
[-gKSUVZ] [-h elp] [--] cpxfile |
| 294 |
|
| 295 |
cpxfiddle options: |
| 296 |
-w width of complexfile in complex pixels |
| 297 |
-f format of complex input file. |
| 298 |
ci2|cr4|cr8 ($FFORMAT is default) |
| 299 |
r4 now also possible, though it limites other options. |
| 300 |
do not use subsampling, mirroring etc, file is cat-ed. |
| 301 |
-q output what is to be computed |
| 302 |
mag|phase|real|imag|normal ($OUTPUT is default) |
| 303 |
-e exp compute scale*output^exp |
| 304 |
-s scale compute scale*output^exp |
| 305 |
-l firstline cut out complexfile from firstline |
| 306 |
-L lastline cut out complexfile upto lastline |
| 307 |
-p firstpixel cut out complexfile from firstpixel |
| 308 |
-P lastpixel cut out complexfile upto lastpixel |
| 309 |
-m X Y XY mirror option. |
| 310 |
-M 1/1 multilook factor in X/Y direction |
| 311 |
-F 1/1 subsample Factor in X/Y direction |
| 312 |
|
| 313 |
GMT options: |
| 314 |
-T title title to plot (one word only for now) |
| 315 |
default no title |
| 316 |
-c colortable name of color table (see grd2cpt) |
| 317 |
if -q mag then gray table is default |
| 318 |
if -q other then $CPTNAME table is default |
| 319 |
-S add a scale bar (psscale) |
| 320 |
-Z continuous color table (grd2cpt) |
| 321 |
-K Leave postscript file open after last call to GMT |
| 322 |
-z cm largest size of paper |
| 323 |
-U Place UNIX time stamp and filename in output |
| 324 |
|
| 325 |
General options: |
| 326 |
-g Do not call gv to view result. |
| 327 |
-o output postscript file, default=$$.eps (pid) |
| 328 |
-G output grd file, default=$$.eps (pid) |
| 329 |
If specified, file is not removed at end |
| 330 |
If file exists, prompted for reuse. |
| 331 |
-C output cpt file, default=$$.cpt (pid) |
| 332 |
If specified, file is not removed at end |
| 333 |
If file exists, prompted for reuse. |
| 334 |
-V erbose give verbose information |
| 335 |
-h elp this help |
| 336 |
complexfile inputfile, major row order pixel interleaved |
| 337 |
|
| 338 |
EXAMPLES: |
| 339 |
Generate a postscript file with phase of complex interferogram |
| 340 |
in file cpxint.raw (complex 2x4B floats) that has 998 range pixels: |
| 341 |
$PRG -w 998 -qphase -fcr4 -- cpxint.raw |
| 342 |
|
| 343 |
The same but with a scale bar, timestamp, and no title: |
| 344 |
$PRG -w 998 -qphase -fcr4 -Tnone -U -S -- cpxint.raw |
| 345 |
|
| 346 |
To plot the magnitude to the power 0.3 of a file in the format |
| 347 |
complex short integers (2x2B) use: |
| 348 |
$PRG -w 998 -qmag -fci2 -e0.3 -- cpxint.raw |
| 349 |
|
| 350 |
To see a large file it is convenient to set a large size (-z). |
| 351 |
This file cannot be printed, but viewing it with gv is nice: |
| 352 |
$PRG -w 998 -qphase -z200 -- cpxint.raw |
| 353 |
|
| 354 |
To plot the phase of a hgt file, first create a tmp file with |
| 355 |
the program hgt2file (hgtfile infile linelength tmpfile [ampflag]) |
| 356 |
Next, run $PRG with appropriate flags for a float file, e.g. |
| 357 |
(Note that this limits some options in scaling etc.): |
| 358 |
$PRG -w 998 -crainbow -fr4 -- tmpfile |
| 359 |
|
| 360 |
BUGS: |
| 361 |
When mirroring and multilooking/subsampling sometimes |
| 362 |
the number of lines/pixels of the output is computed |
| 363 |
incorrectly. Simply don't use multilooking/subsampling... |
| 364 |
|
| 365 |
Please mail bugs/comments to [email protected] |
| 366 |
|
| 367 |
SEE ALSO: |
| 368 |
cpxfiddle, GMT |
| 369 |
|
| 370 |
__EOFHD |
| 371 |
exit 1 |
| 372 |
endif |
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
if ( $VERBOSE ) then |
| 377 |
echo " *** Color table name: $CPTNAME (-c option, grd2cpt)" |
| 378 |
endif |
| 379 |
|
| 380 |
|
| 381 |
# cpxfiddle internal variables |
| 382 |
set OFORMAT = "-o float" # binary to stdout |
| 383 |
|
| 384 |
|
| 385 |
### Check files |
| 386 |
set REUSEGRD = "0" |
| 387 |
set REUSECPT = "0" |
| 388 |
if ( -e $PSFILE ) then |
| 389 |
if ( $VERBOSE ) \ |
| 390 |
echo " *** Removing existing postscript output: $PSFILE" |
| 391 |
rm -f $PSFILE |
| 392 |
endif |
| 393 |
if ( -e $GRDFILE ) then |
| 394 |
echo " --- Press enter to remove grd file: $GRDFILE"\\n\ |
| 395 |
"r to reuse it"\\n\ |
| 396 |
"CTRL-C to quit" |
| 397 |
set key = $< |
| 398 |
if ( "$key" == "r" ) then |
| 399 |
if ( $VERBOSE ) echo " *** Re-using grdfile: $GRDFILE" |
| 400 |
set REUSEGRD = "1" |
| 401 |
else |
| 402 |
if ( $VERBOSE ) echo " *** Removing grdfile: $GRDFILE" |
| 403 |
rm -f $GRDFILE |
| 404 |
endif |
| 405 |
endif |
| 406 |
if ( -e $CPTFILE ) then |
| 407 |
echo " --- Press enter to remove cpt file: $CPTFILE"\\n\ |
| 408 |
"r to reuse it"\\n\ |
| 409 |
"CTRL-C to quit" |
| 410 |
set key = $< |
| 411 |
if ( "$key" == "r" ) then |
| 412 |
if ( $VERBOSE ) echo " *** Re-using cptfile: $CPTFILE" |
| 413 |
set REUSECPT = "1" |
| 414 |
else |
| 415 |
if ( $VERBOSE ) echo " *** Removing cptfile: $CPTFILE" |
| 416 |
rm -f $CPTFILE |
| 417 |
endif |
| 418 |
endif |
| 419 |
|
| 420 |
|
| 421 |
### Compute dimensions paper/file |
| 422 |
# sizes file |
| 423 |
set BYTES = "8" # bytes per pixel (re+im) |
| 424 |
if ( "$FFORMAT" == "ci2") then |
| 425 |
set BYTES = "4" # bytes per pixel (re+im) |
| 426 |
else if ( "$FFORMAT" == "cr8") then |
| 427 |
set BYTES = "16" # bytes per pixel (re+im) |
| 428 |
else if ( "$FFORMAT" == "r4") then |
| 429 |
set BYTES = "4" # bytes per pixel, use cat |
| 430 |
endif |
| 431 |
set FSIZE = `ls -l $CPXFILE | awk '{print $5}'` |
| 432 |
@ FILELINES = `echo "scale=0; $FSIZE/$LINELENGTH/$BYTES" | bc -l` |
| 433 |
if ( $VERBOSE ) then |
| 434 |
echo " *** LINELENGTH: $LINELENGTH FILESIZE: $FSIZE" |
| 435 |
echo " *** BYTES per cpx pixel: $BYTES FILELINES computed: $FILELINES" |
| 436 |
endif |
| 437 |
# |
| 438 |
# Check user input or set default |
| 439 |
if ( "$LASTLINE" == "0" ) then |
| 440 |
set LASTLINE = "$FILELINES" # default |
| 441 |
endif |
| 442 |
if ( "$LASTPIXEL" == "0" ) then |
| 443 |
set LASTPIXEL = "$LINELENGTH" # default |
| 444 |
endif |
| 445 |
# |
| 446 |
|
| 447 |
|
| 448 |
### Set program variables. |
| 449 |
set PROG = "cpxfiddle" |
| 450 |
set PROGOPTS = "-w$LINELENGTH -e$EXP -s$SCALE -S$XSUB/$YSUB -M$XMULTILOOK/$YMULTILOOK -l$FIRSTLINE -L$LASTLINE -p$FIRSTPIXEL -P$LASTPIXEL -f$FFORMAT $OFORMAT -q$OUTPUT $MIRROR $DEBUG $CPXFILE" |
| 451 |
# |
| 452 |
if ( $VERBOSE ) echo " *** Options for ${PROG}:"\\n $PROGOPTS |
| 453 |
|
| 454 |
# Set GMT options, difference in subsampling/multilook for numpix. |
| 455 |
if ( "$XMULTILOOK" != "1" ) then |
| 456 |
if ( "$XSUB" != "1" ) then |
| 457 |
echo " +++ WARNING: Sorry, not possible multilooking and subsampling." |
| 458 |
exit |
| 459 |
endif |
| 460 |
set XSUB = "$XMULTILOOK" |
| 461 |
endif |
| 462 |
if ( "$YMULTILOOK" != "1" ) then |
| 463 |
if ( "$YSUB" != "1" ) then |
| 464 |
echo " +++ WARNING: Sorry, not possible multilooking and subsampling." |
| 465 |
exit |
| 466 |
endif |
| 467 |
set YSUB = "$YMULTILOOK" |
| 468 |
endif |
| 469 |
|
| 470 |
set INC = "-I$XSUB/$YSUB" |
| 471 |
set IFORMAT = "-Zf" # binary float values |
| 472 |
# add lowerleft?? for real plot? |
| 473 |
# can be done with grdedit -A |
| 474 |
# |
| 475 |
# correct for GMT, subsampling output = ceil ((P-p+1)/sub) |
| 476 |
# correct for GMT, multilook output = floor ((P-p+1)/ml) |
| 477 |
#set RANGE = "-R$FIRSTPIXEL/$LASTPIXEL/$FIRSTLINE/$LASTLINE" |
| 478 |
# outputlines after subsampling = ceil((P-p+1)/sub) |
| 479 |
# outputlines after multilooking = floor((P-p+1)/sub) |
| 480 |
#%// BK 02-Oct-2000 |
| 481 |
# functions ceil and floor have to be used?, ceil!=floor+1 !!! |
| 482 |
# but ceil == floor(b-1/sub)+1 ??? (where b=$2-$1+1) (?) |
| 483 |
# Seems that some csh (linux) do not like it if `` goes over eol. with \ |
| 484 |
#%// BK 11-Dec-2000 |
| 485 |
set NUMX = `echo "$FIRSTPIXEL $LASTPIXEL $XSUB" | awk '{b=$2-$1+1}{if (int(b/$3)==b/$3){print int(b/$3)}else {print(int(b/$3))+1}}'` |
| 486 |
set NUMY = `echo "$FIRSTLINE $LASTLINE $YSUB" | awk '{b=$2-$1+1}{if (int(b/$3)==b/$3){print int(b/$3)}else {print(int(b/$3))+1}}'` |
| 487 |
if ( "$XMULTILOOK" != "1" ) then |
| 488 |
set NUMX = `echo "$FIRSTPIXEL $LASTPIXEL $XSUB" | awk '{print int(($2-$1+1)/$3)}'` |
| 489 |
endif |
| 490 |
if ( "$YMULTILOOK" != "1" ) then |
| 491 |
set NUMY = `echo "$FIRSTLINE $LASTLINE $YSUB" | awk '{print int(($2-$1+1)/$3)}'` |
| 492 |
#set NUMY = `echo "$FIRSTLINE $LASTLINE $YSUB" | awk '{printf "%i", (($2-$1+1)/$3)}'` |
| 493 |
endif |
| 494 |
#%// BK 02-Oct-2000 |
| 495 |
set EAST = `echo "$FIRSTPIXEL+($NUMX-1)*$XSUB" | bc -l` |
| 496 |
set NORTH = `echo "$FIRSTLINE+($NUMY-1)*$YSUB" | bc -l` |
| 497 |
# |
| 498 |
#BK 16MAY better use actual papersize, not file dimensions (cut out allowed) |
| 499 |
@ OUTPUTLINES = $NUMY |
| 500 |
@ OUTPUTWIDTH = $NUMX |
| 501 |
# size paper, largest size $XSIZE |
| 502 |
#if ( $FILELINES > $LINELENGTH ) then |
| 503 |
if ( $OUTPUTLINES > $OUTPUTWIDTH ) then |
| 504 |
if ( $VERBOSE ) echo " *** More output lines than pixels" |
| 505 |
set YSIZE = $XSIZE |
| 506 |
set XSIZE = `echo "scale=3; $OUTPUTWIDTH/$OUTPUTLINES*$YSIZE" | bc -l` |
| 507 |
else |
| 508 |
if ( $VERBOSE ) echo " *** More output pixels than lines" |
| 509 |
set YSIZE = `echo "scale=3; $OUTPUTLINES/$OUTPUTWIDTH*$XSIZE" | bc -l` |
| 510 |
endif |
| 511 |
if ( $VERBOSE ) echo " *** Papersize: XSIZE: $XSIZE YSIZE: $YSIZE" |
| 512 |
|
| 513 |
# |
| 514 |
# BK 18-May-2000 |
| 515 |
if ( "$OUTPUT" == "normal" ) then |
| 516 |
set EAST = `echo "2*($FIRSTPIXEL+($NUMX-1)*$XSUB)" | bc -l` |
| 517 |
endif |
| 518 |
set RANGE = "-R$FIRSTPIXEL/$EAST/$FIRSTLINE/$NORTH" |
| 519 |
|
| 520 |
|
| 521 |
### Prog binary dumps to stdout, xyz2grd makes grd file for GMT. |
| 522 |
if ( $REUSEGRD ) then |
| 523 |
if ( $VERBOSE ) echo " *** Using existing grd file: $GRDFILE" |
| 524 |
else |
| 525 |
if ( $VERBOSE ) echo " *** Creating new grd file: $GRDFILE" |
| 526 |
if ( "$FFORMAT" == "r4") then |
| 527 |
if ( $VERBOSE ) echo " *** Catting float file to xyz2grd" |
| 528 |
cat $CPXFILE | xyz2grd -G$GRDFILE $RANGE $INC $IFORMAT |
| 529 |
else |
| 530 |
if ( $VERBOSE ) echo " *** Options for xyz2grd:"\\n -G$GRDFILE $RANGE $INC $IFORMAT |
| 531 |
$PROG $PROGOPTS | xyz2grd -G$GRDFILE $RANGE $INC $IFORMAT |
| 532 |
endif |
| 533 |
endif |
| 534 |
set ZMIN = `grdinfo -C $GRDFILE | cut -f6` |
| 535 |
set ZMAX = `grdinfo -C $GRDFILE | cut -f7` |
| 536 |
set NINTERVALS = "4" # actually n+1... user input? |
| 537 |
set ZINT = `echo "$ZMIN $ZMAX $NINTERVALS" | awk '{printf "%10.2g", ($2-$1)/$3}'` |
| 538 |
if ( $VERBOSE ) then |
| 539 |
echo " *** zmin zmax #intervals zinterval: $ZMIN $ZMAX $NINTERVALS $ZINT" |
| 540 |
endif |
| 541 |
|
| 542 |
### grdhisteq |
| 543 |
if ( "$OUTPUT" == "mag" ) then |
| 544 |
echo "consider doing grdequalize here?" |
| 545 |
endif |
| 546 |
|
| 547 |
### grd2cpt |
| 548 |
# Select color table (loop index, select from 10?). |
| 549 |
set CPTS = "" |
| 550 |
if ( $REUSECPT ) then |
| 551 |
if ( $VERBOSE ) echo " *** Using existing cpt file: $CPTFILE" |
| 552 |
else |
| 553 |
if ( $VERBOSE ) echo " *** Creating new cpt file: $CPTFILE" |
| 554 |
### use -S if phase? |
| 555 |
if ( "$OUTPUT" == "phase" ) then |
| 556 |
### 40 intervals |
| 557 |
set PI = "3.1416" |
| 558 |
set CPTS = "-S-$PI/$PI/0.157" |
| 559 |
endif |
| 560 |
### BK 4-apr-2001: cut off mag>threshold |
| 561 |
### but it seems to work fine asis, so leave it... |
| 562 |
# if ( "$OUTPUT" == "mag" ) then |
| 563 |
# ### threshold = -LZMIN/ZMEAN*XXX/NN intervals |
| 564 |
# set PI = "3.1416" |
| 565 |
# set CPTS = "-S-$PI/$PI/0.157" |
| 566 |
# endif |
| 567 |
if ( $VERBOSE ) echo " *** Calling: grd2cpt $GRDFILE $CPTZ $CPTS -C$CPTNAME $DEBUG" |
| 568 |
grd2cpt $GRDFILE $CPTZ $CPTS -C$CPTNAME $DEBUG >! $CPTFILE |
| 569 |
endif |
| 570 |
|
| 571 |
### GMT general flags |
| 572 |
if ( $TIMESTAMP ) then |
| 573 |
set TIMESTAMPLLX = "-0.5" |
| 574 |
set TIMESTAMPLLY = "-0.5" |
| 575 |
# place timestamp little lower if also scalebar |
| 576 |
if ( $SCALEBAR ) set TIMESTAMPLLY = "-2.0" |
| 577 |
#set TIMESTAMP = -U/-0.5/-1.5/\"${CPXFILE:t}\" |
| 578 |
set TIMESTAMP = -U/$TIMESTAMPLLX/$TIMESTAMPLLY/\"${PRG}\:_${CPXFILE:t}\" |
| 579 |
if ( $VERBOSE ) echo " *** Timestamp: $TIMESTAMP" |
| 580 |
else |
| 581 |
set TIMESTAMP = "" |
| 582 |
endif |
| 583 |
set GMTFIRST = "-K" # append more later |
| 584 |
set GMTMIDDLE = "-K -O" # append more later and overlay |
| 585 |
set GMTCLOSE = "-O" # overlay |
| 586 |
set GMTFLAGS = "$GMTFIRST $DEBUG" |
| 587 |
if ( "$LEAVEOPEN" == "0" & "$ONLYONEGMT" == "1" ) \ |
| 588 |
set GMTFLAGS = "$DEBUG" |
| 589 |
|
| 590 |
### grdimage |
| 591 |
### Consider using -Iamp.grd for magnitude/phase display |
| 592 |
if ( $VERBOSE ) echo " *** Grdimage creates postscript file: $PSFILE" |
| 593 |
if ( $VERBOSE ) echo " *** Title: $TITLE" |
| 594 |
set SIZE = "-JX$XSIZE/$YSIZE" # bounding box size |
| 595 |
grdimage $GRDFILE $SIZE -C$CPTFILE $TITLE -P $GMTFLAGS $TIMESTAMP >! $PSFILE |
| 596 |
set GMTFLAGS = "$GMTMIDDLE $DEBUG" |
| 597 |
|
| 598 |
|
| 599 |
### add ? |
| 600 |
#pwd | psxy $RANGE $SIZE -X0 -Y0 -K >> $PSFILE |
| 601 |
|
| 602 |
|
| 603 |
### psscale this must be the last call to GMT |
| 604 |
if ( ! $LEAVEOPEN ) set GMTFLAGS = "$GMTCLOSE $DEBUG" |
| 605 |
if ( $SCALEBAR ) then |
| 606 |
if ( $VERBOSE ) echo " *** Adding scale bar (psscale)." |
| 607 |
set SCBOPTS = " " # |
| 608 |
set SCBLENGTH = `echo "scale=0; $YSIZE*0.6" | bc -l` |
| 609 |
set SCBWIDTH = "0.25h" # horizontal bar 0.25 cm |
| 610 |
set SCBLLX = `echo "scale=1; $XSIZE*0.45" | bc -l` |
| 611 |
set SCBLLY = "-0.4" |
| 612 |
#set SCBANNOT = "-B${ZINT}:magnitude:/:mag:" |
| 613 |
set SCBANNOT = "-B${ZINT}:magnitude:" |
| 614 |
if ( "$OUTPUT" == "phase" ) set SCBANNOT = "-B3.14:phase:/:rad:" |
| 615 |
set SCBOPTS = "-L" # equal sized |
| 616 |
# lower left corner position wrt. frame? |
| 617 |
#set SCBPOS='-D3/-0.5/6/0.25h' |
| 618 |
set SCBPOS = "-D$SCBLLX/$SCBLLY/$SCBLENGTH/$SCBWIDTH" |
| 619 |
#ok: set ANNOT='-B50::/:m:' |
| 620 |
psscale -C$CPTFILE $SCBPOS $SCBANNOT $SCBOPTS $GMTFLAGS >> $PSFILE |
| 621 |
endif |
| 622 |
|
| 623 |
|
| 624 |
### View. |
| 625 |
if ( $CALLGV ) then |
| 626 |
echo " *** View with gv: $PSFILE" |
| 627 |
gv -bg white -fg black $PSFILE & |
| 628 |
endif |
| 629 |
|
| 630 |
|
| 631 |
### Tidy up |
| 632 |
if ( "$GRDFILE" == "$$.grd" ) then |
| 633 |
if ( $VERBOSE ) echo " *** Removing tmp grdfile: $GRDFILE" |
| 634 |
rm -f $GRDFILE |
| 635 |
endif |
| 636 |
if ( "$CPTFILE" == "$$.cpt" ) then |
| 637 |
if ( $VERBOSE ) echo " *** Removing tmp cptfile: $CPTFILE" |
| 638 |
rm -f $CPTFILE |
| 639 |
endif |
| 640 |
if ( $VERBOSE ) then |
| 641 |
echo " *** Ouput postscript in: $PSFILE" |
| 642 |
echo \\n" *** Thank you for using $PRG" |
| 643 |
endif |
| 644 |
|
| 645 |
### EOF |
| 646 |
|