|
236 | 236 | print CSH "echo\n"; |
237 | 237 |
|
238 | 238 | if($gmt5==1){ |
239 | | - print CSH "gmtset MAP_FRAME_TYPE plain PS_MEDIA letter PROJ_LENGTH_UNIT inch FORMAT_GEO_MAP D MAP_TICK_LENGTH_PRIMARY $tick PS_CHAR_ENCODING Standard+ COLOR_NAN $cgray\n"; |
| 239 | + print CSH "gmt gmtset MAP_FRAME_TYPE plain PS_MEDIA letter PROJ_LENGTH_UNIT inch FORMAT_GEO_MAP D MAP_TICK_LENGTH_PRIMARY $tick PS_CHAR_ENCODING Standard+ COLOR_NAN $cgray\n"; |
240 | 240 | }else{ |
241 | 241 | # older gmt |
242 | 242 | print CSH "gmtset BASEMAP_TYPE plain PAPER_MEDIA letter MEASURE_UNIT inch PLOT_DEGREE_FORMAT D TICK_LENGTH $tick LABEL_FONT_SIZE $fsize2 ANOT_FONT_SIZE $fsize2 HEADER_FONT $fontno ANOT_FONT $fontno LABEL_FONT $fontno HEADER_FONT_SIZE $fsize1 CHAR_ENCODING Standard+ COLOR_NAN $cgray\n"; |
|
260 | 260 | $Ts[$k] = sprintf("-T%3.3f/%3.3f/%3.3f",-$ss[$k]*1.05,$ss[$k]*1.05,$ds[$k]); |
261 | 261 | print "color range Ts = $Ts[$k]\n"; |
262 | 262 |
|
263 | | - print CSH "makecpt -C$colorbar $Ts[$k] -D > color_${k}.cpt\n"; |
| 263 | + print CSH "gmt makecpt -C$colorbar $Ts[$k] -D > color_${k}.cpt\n"; |
264 | 264 | } |
265 | 265 |
|
266 | 266 | # colorbar |
|
291 | 291 |
|
292 | 292 | $name = "wavefield_${tlab}_${ttag}"; |
293 | 293 | $psfile = "$name.ps"; |
| 294 | + $pdffile = "$name.pdf"; |
294 | 295 | $jpgfile = "$name.jpg"; |
295 | 296 |
|
296 | 297 | print CSH "echo\n"; |
297 | 298 | print CSH "echo \"postscript file = $psfile\";echo\n"; |
298 | 299 | print CSH "echo\n"; |
299 | 300 | # clean |
300 | | - print CSH "rm -f $psfile\n\n"; |
| 301 | + print CSH "rm -f $psfile $pdffile $jpgfile\n\n"; |
301 | 302 |
|
302 | 303 | #$numf = 1; |
303 | 304 |
|
|
395 | 396 | #} # temp |
396 | 397 |
|
397 | 398 | if ($i == $imin && $k==1) { |
398 | | - print CSH "psbasemap $J $R $B $BG -K -V $orient $origin > $psfile\n"; |
| 399 | + print CSH "gmt psbasemap $J $R $B $BG -K -V $orient $origin > $psfile\n"; |
399 | 400 | } # START |
400 | 401 | else { |
401 | | - print CSH "psbasemap $J $R $B $BG -K -O -V $shift >> $psfile\n"; |
| 402 | + print CSH "gmt psbasemap $J $R $B $BG -K -O -V $shift >> $psfile\n"; |
402 | 403 | } |
403 | 404 |
|
404 | 405 | # PLOT THE FORWARD WAVEFIELD |
405 | 406 | if ($icolor==1) { |
406 | 407 | if ($igrd==1) { |
407 | 408 | #print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $nm}' $snapshot_f > dfile\n"; |
408 | 409 | #print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $nm}' $snapshot_f | nearneighbor -G$grdfile $R $interp\n"; |
409 | | - print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $nm}' $snapshot_f | xyz2grd -G$grdfile $R $interp\n"; |
410 | | - print CSH "grdimage $grdfile -C$cfile $J -K -O -V -Q >> $psfile\n"; |
| 410 | + print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $nm}' $snapshot_f | gmt xyz2grd -G$grdfile $R $interp\n"; |
| 411 | + print CSH "gmt grdimage $grdfile -C$cfile $J -K -O -V -Q >> $psfile\n"; |
411 | 412 | } else { |
412 | | - print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $nm}' $snapshot_f | psxy $R $J $minfo -C$cfile -K -O -V >> $psfile\n"; |
| 413 | + print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $nm}' $snapshot_f | gmt psxy $R $J $minfo -C$cfile -K -O -V >> $psfile\n"; |
413 | 414 | } |
414 | 415 |
|
415 | 416 | # mask points above topography |
416 | 417 | if ($imask==1) { |
417 | 418 | #print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2)}' $snapshot_f > maskpts\n"; |
418 | 419 | printf CSH "grep NaN $snapshot_f > maskpts\n"; |
419 | | - print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2)}' maskpts | psxy $R $J $minfo -C$cfile -K -O -V >> $psfile\n"; |
| 420 | + print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2)}' maskpts | gmt psxy $R $J $minfo -C$cfile -K -O -V >> $psfile\n"; |
420 | 421 | } |
421 | 422 | } |
422 | 423 |
|
|
429 | 430 | die("check if bfile $bfile exist or not\n"); |
430 | 431 | } |
431 | 432 | #print CSH "awk '{print \$1/1000,\$2/1000}' $bfile | psxy $J $R -W1.5p -m -K -O -V >> $psfile\n"; |
432 | | - print CSH "awk '{print \$1,\$2}' $bfile | psxy $J $R -W1p -m -K -O -V >> $psfile\n"; |
| 433 | + print CSH "awk '{print \$1,\$2}' $bfile | gmt psxy $J $R -W1p -m -K -O -V >> $psfile\n"; |
433 | 434 | } |
434 | 435 |
|
435 | 436 | # plot seismicity |
|
438 | 439 | if (not -f $bfile) { |
439 | 440 | die("check if bfile $bfile exist or not\n"); |
440 | 441 | } |
441 | | - print CSH "awk '{print \$1,\$2}' $bfile | psxy $J $R -Sc3p -G0 -K -O -V >> $psfile\n"; |
| 442 | + print CSH "awk '{print \$1,\$2}' $bfile | gmt psxy $J $R -Sc3p -G0 -K -O -V >> $psfile\n"; |
442 | 443 | } |
443 | 444 |
|
444 | | - if ($i == $imin) {print CSH "psscale -C$cfile $Dscale $BscaleS -K -O -V >> $psfile \n";} |
445 | | - print CSH "psbasemap $J $R $B -K -O -V >> $psfile\n"; |
| 445 | + if ($i == $imin) {print CSH "gmt psscale -C$cfile $Dscale $BscaleS -K -O -V >> $psfile \n";} |
| 446 | + print CSH "gmt psbasemap $J $R $B -K -O -V >> $psfile\n"; |
446 | 447 |
|
447 | 448 | # label the figures |
448 | 449 | if (0==1) { |
|
453 | 454 | print CSH "pstext $J $R -K -O -V >>$psfile<<EOF\n -1 0.75 14 0 $fontno CM ice\nEOF\n"; |
454 | 455 | print CSH "pstext $J $R -K -O -V >>$psfile<<EOF\n 1.0 0.75 14 0 $fontno CM water\nEOF\n"; |
455 | 456 | } |
456 | | - print CSH "psxy -W1p $J $R -K -O -V >>$psfile<<EOF\n1.0 0.6\n 0.7 -0.1\nEOF\n"; |
457 | | - print CSH "psxy -W1p $J $R -K -O -V >>$psfile<<EOF\n-1.0 0.6\n -0.7 -0.05\nEOF\n"; |
| 457 | + print CSH "gmt psxy -W1p $J $R -K -O -V >>$psfile<<EOF\n1.0 0.6\n 0.7 -0.1\nEOF\n"; |
| 458 | + print CSH "gmt psxy -W1p $J $R -K -O -V >>$psfile<<EOF\n-1.0 0.6\n -0.7 -0.05\nEOF\n"; |
458 | 459 | } |
459 | 460 | } |
460 | 461 |
|
461 | 462 | # plot stations and labels |
462 | 463 | if($iplotrec==1) { |
463 | 464 | #print CSH "awk '{print \$3/1000,\$4/1000}' $recfile2 | psxy $J $R -K -O -V $rec2 >> $psfile\n"; |
464 | | - print CSH "awk '{print \$3/1000,\$4/1000}' $recfile | psxy $J $R -K -O -V $rec >> $psfile\n"; |
| 465 | + print CSH "awk '{print \$3/1000,\$4/1000}' $recfile | gmt psxy $J $R -K -O -V $rec >> $psfile\n"; |
465 | 466 | #if($i==$imin && $iplotreclab==1) {print CSH "awk '{print \$3/1000,\$4/1000,8,0,$fontno,\"CM\",\"S\"\$7}' $recfile | pstext $textrec $J $R -K -O -V >> $psfile\n";} |
466 | | - if($i==$imin && $iplotreclab==1 && $k==1) {print CSH "awk '{print \$3/1000,\$4/1000,8,0,$fontno,\"CM\",\$1}' $recfile | pstext $textrec $J $R -K -O -V >> $psfile\n";} |
| 467 | + if($i==$imin && $iplotreclab==1 && $k==1) {print CSH "awk '{print \$3/1000,\$4/1000,8,0,$fontno,\"CM\",\$1}' $recfile | gmt pstext $textrec $J $R -K -O -V >> $psfile\n";} |
467 | 468 | } |
468 | | - print CSH "psxy $J $R -K -O -V $src >> $psfile<<EOF\n $srcx $srcz\nEOF\n"; |
| 469 | + print CSH "gmt psxy $J $R -K -O -V $src >> $psfile<<EOF\n $srcx $srcz\nEOF\n"; |
469 | 470 |
|
470 | 471 | # plot the time of the snapshot (for some reason, it won't work inside the B command) |
471 | 472 | #$xtext = $xmin-0.3*$xran; |
|
532 | 533 | if($ipsv==1) {$tlab0 = "PSV"} else {$tlab0 = "SH"} |
533 | 534 | $title = "$tlab0 wavefield -- $tlab"; |
534 | 535 | if($gmt5==1){ |
535 | | - print CSH "pstext -N $J $R $Utag -K -O -V $shift -F+f+a+j >>$psfile<<EOF\n $xmin $zmax $fsize0,$fontno 0 LM $title\nEOF\n"; |
| 536 | + print CSH "gmt pstext -N $J $R $Utag -K -O -V $shift -F+f+a+j >>$psfile<<EOF\n $xmin $zmax $fsize0,$fontno 0 LM $title\nEOF\n"; |
536 | 537 | }else{ |
537 | 538 | print CSH "pstext -N $J $R $Utag -K -O -V $shift >>$psfile<<EOF\n $xmin $zmax $fsize0 0 $fontno LM $title\nEOF\n"; # LM or CM |
538 | 539 | } |
|
570 | 571 |
|
571 | 572 | $name = "kernel_${tlab}_${ttag}"; |
572 | 573 | $psfile = "$name.ps"; |
| 574 | + $pdffile = "$name.pdf"; |
573 | 575 | $jpgfile = "$name.jpg"; |
574 | 576 |
|
575 | 577 | print CSH "echo\n"; |
576 | 578 | print CSH "echo \"kernel file = $kfile\"\n"; |
577 | 579 | print CSH "echo \"postscript file = $psfile\";echo\n"; |
578 | 580 | print CSH "echo\n"; |
579 | 581 | # clean |
580 | | - print CSH "rm -f $psfile\n\n"; |
| 582 | + print CSH "rm -f $psfile $pdffile $jpgfile\n\n"; |
581 | 583 |
|
582 | 584 | if($gmt5==1){ |
583 | 585 | $BscaleS = sprintf("-B%2.2e+l\"%s (x, z, t), 10\@+%2.2i\@+ m\@+-2\@+\" -BS",$bs[0],"K",$pwr[0]); |
|
619 | 621 |
|
620 | 622 | # START |
621 | 623 | if ($k == $kmin) { |
622 | | - print CSH "psbasemap $J $R $B -K -V $orient $origin > $psfile\n"; |
| 624 | + print CSH "gmt psbasemap $J $R $B -K -V $orient $origin > $psfile\n"; |
623 | 625 | } else { |
624 | | - print CSH "psbasemap $J $R $B -K -O -V $dY >> $psfile\n"; |
| 626 | + print CSH "gmt psbasemap $J $R $B -K -O -V $dY >> $psfile\n"; |
625 | 627 | } |
626 | 628 |
|
627 | 629 | print CSH "echo;echo \"norm = $norm[$k]\"\n"; |
|
632 | 634 | print CSH "echo;echo \"plotting by grdimage\";echo;\n"; |
633 | 635 | #print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $norm[$k]}' $kfile > dfile\n"; |
634 | 636 | #print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $norm[$k]}' $kfile | nearneighbor -G$grdfile $R $interp\n"; |
635 | | - print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $norm[$k]}' $kfile | xyz2grd -G$grdfile $R $interp\n"; |
636 | | - print CSH "grdinfo $grdfile\n"; |
637 | | - print CSH "grdimage $grdfile -Ccolor_${k}.cpt $J -K -O -V -Q >> $psfile\n"; |
| 637 | + print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $norm[$k]}' $kfile | gmt xyz2grd -G$grdfile $R $interp\n"; |
| 638 | + print CSH "gmt grdinfo $grdfile\n"; |
| 639 | + print CSH "gmt grdimage $grdfile -Ccolor_${k}.cpt $J -K -O -V -Q >> $psfile\n"; |
638 | 640 | } else { |
639 | 641 | print CSH "echo;echo \"plotting by psxy\";\n"; |
640 | | - print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $norm[$k]}' $kfile | psxy $R $J $minfo -Ccolor_${k}.cpt -K -O -V >> $psfile\n"; |
| 642 | + print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2) / $norm[$k]}' $kfile | gmt psxy $R $J $minfo -Ccolor_${k}.cpt -K -O -V >> $psfile\n"; |
641 | 643 | } |
642 | 644 |
|
643 | 645 | # mask points above topography |
644 | 646 | if($imask==1) { |
645 | 647 | print CSH "echo;echo \"using mask\";\n"; |
646 | 648 | #print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2)}' $kfile > maskpts\n"; |
647 | 649 | printf CSH "grep NaN $kfile > maskpts\n"; |
648 | | - print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2)}' maskpts | psxy $R $J $minfo -Ccolor_${k}.cpt -K -O -V >> $psfile\n"; |
| 650 | + print CSH "awk '{print \$1/1000,\$2/1000,\$($comp+2)}' maskpts | gmt psxy $R $J $minfo -Ccolor_${k}.cpt -K -O -V >> $psfile\n"; |
649 | 651 | } |
650 | 652 | } |
651 | 653 |
|
|
659 | 661 | die("check if bfile $bfile exist or not\n"); |
660 | 662 | } |
661 | 663 | #print CSH "awk '{print \$1/1000,\$2/1000}' $bfile | psxy $J $R -W1.5p -m -K -O -V >> $psfile\n"; |
662 | | - print CSH "awk '{print \$1,\$2}' $bfile | psxy $J $R -W1p -m -K -O -V >> $psfile\n"; |
| 664 | + print CSH "awk '{print \$1,\$2}' $bfile | gmt psxy $J $R -W1p -m -K -O -V >> $psfile\n"; |
663 | 665 | } |
664 | 666 |
|
665 | 667 | #print CSH "pscoast $J $R $B -W1p -Na/1p -Dh -K -O -V >> $psfile\n"; |
666 | 668 | #print CSH "awk '{print \$2,\$1}' INPUT/oms_shelf |psxy $J $R $Wshelf -K -O -V >> $psfile\n"; |
667 | 669 | if ($k == $kmin) { |
668 | | - print CSH "psscale -Ccolor_${k}.cpt $Dscale $BscaleS -K -O -V >> $psfile \n"; |
| 670 | + print CSH "gmt psscale -Ccolor_${k}.cpt $Dscale $BscaleS -K -O -V >> $psfile \n"; |
669 | 671 | } |
670 | 672 | #print CSH "awk '{print \$3/1000,\$4/1000}' $recfile | psxy $J $R -K -O -V $rec >> $psfile\n"; |
671 | 673 | #print CSH "psxy -N $J $R -K -O -V $src >> $psfile<<EOF\n $srcx $srcz\nEOF\n"; |
|
692 | 694 | $textinfo = "-G255"; #"-G0 -W255 -C2p -N"; |
693 | 695 | print "\ntitle plotting at $xtx, $ztx info: $textinfo $titles[$k]\n"; |
694 | 696 | if($gmt5==1){ |
695 | | - print CSH "pstext $textinfo $J $R -K -O -V -F+f+a+j >>$psfile<<EOF\n $xtx $ztx 16,$fontno 0 RT $titles[$k]\nEOF\n"; |
| 697 | + print CSH "gmt pstext $textinfo $J $R -K -O -V -F+f+a+j >>$psfile<<EOF\n $xtx $ztx 16,$fontno 0 RT $titles[$k]\nEOF\n"; |
696 | 698 | }else{ |
697 | 699 | # older gmt |
698 | 700 | print CSH "pstext $textinfo $J $R -K -O -V >>$psfile<<EOF\n $xtx $ztx 16 0 $fontno RT $titles[$k]\nEOF\n"; |
|
712 | 714 | if ($ipsv==1) {$tlab0 = "PSV";} else {$tlab0 = "SH";} |
713 | 715 | $title = "$tlab0 kernel -- $tlab"; |
714 | 716 | if($gmt5==1){ |
715 | | - print CSH "pstext -N $J $R $Utag -K -O -V $shift -F+f+a+j >>$psfile<<EOF\n $xmin $zmax $fsize0,$fontno 0 LM $title\nEOF\n"; |
| 717 | + print CSH "gmt pstext -N $J $R $Utag -K -O -V $shift -F+f+a+j >>$psfile<<EOF\n $xmin $zmax $fsize0,$fontno 0 LM $title\nEOF\n"; |
716 | 718 | }else{ |
717 | 719 | # older gmt |
718 | 720 | print CSH "pstext -N $J $R $Utag -K -O -V $shift >>$psfile<<EOF\n $xmin $zmax $fsize0 0 $fontno LM $title\nEOF\n"; |
|
725 | 727 | #------------------------- |
726 | 728 | # FINISH |
727 | 729 | #print CSH "pstext $J -R0/1/0/1 -O -V >>$psfile<<EOF\n 10 10 $fsize0 0 $fontno CM junk \nEOF\n"; |
728 | | -print CSH "psxy $J -R0/1/0/1 -O -V >>$psfile<<EOF\nEOF\n\n"; |
| 730 | +print CSH "gmt psxy $J -R0/1/0/1 -O -V >>$psfile<<EOF\nEOF\n\n"; |
729 | 731 | # cleanup |
730 | 732 | print CSH "rm -f temp.grd color_0.cpt color_1.cpt color_2.cpt\n"; |
731 | 733 | # user output |
732 | 734 | print CSH "\necho\necho \"see output psfile: $psfile\"\necho\n"; |
733 | 735 |
|
734 | | -# converts (using ImageMagick command) |
735 | | -#print CSH "convert $psfile $jpgfile\n"; |
| 736 | +# convert ps to pdf |
| 737 | +# check if ps2pdf command is available |
| 738 | +my $ps2pdf = `which ps2pdf 2>/dev/null`; |
| 739 | +chomp($ps2pdf); |
| 740 | +if (!defined $ps2pdf || $ps2pdf eq '') { |
| 741 | + print "ps2pdf command not found. Please install Ghostscript to convert ps-file to pdf-file.\n"; |
| 742 | +}else{ |
| 743 | + print CSH "echo \"converting to pdf...\"\n"; |
| 744 | + print CSH "ps2pdf $psfile $pdffile\n"; |
| 745 | +} |
| 746 | +# converts ps to jpg (using ImageMagick command) |
| 747 | +my $magick = `which magick 2>/dev/null`; |
| 748 | +chomp($magick); |
| 749 | +if (!defined $magick || $magick eq '') { |
| 750 | + print "magick command (ImageMagick) not found. Please install ImageMagick to convert ps-file to jpg-file.\n"; |
| 751 | +}else{ |
| 752 | + print CSH "echo \"converting to jpg...\"\n"; |
| 753 | + print CSH "magick -density 300 -quality 90 $psfile $jpgfile\n"; |
| 754 | +} |
| 755 | + |
736 | 756 | close (CSH); |
737 | 757 |
|
738 | 758 | # executes script |
|
0 commit comments