diff --git a/README.md b/README.md index cc18f10..2b41523 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,16 @@ coulomb2gmt -- pre-released +### Output formats +Default format is `*.ps` file. You can use the options bellow to convert to other format and adjust paper size to map size. + +* `-outjpg` : Adjust and convert to JPEG. + +* `-outpng` : Adjust and convert to PNG (transparent where nothing is plotted) + +* `-outeps` : Adjust and convert to EPS" + +* `-outpdf` : Adjust and convert to PDF ## Contributing diff --git a/coulomb2gmt.sh b/coulomb2gmt.sh index d9d87c5..cce7dc2 100755 --- a/coulomb2gmt.sh +++ b/coulomb2gmt.sh @@ -35,8 +35,18 @@ function help { echo " Purpose : Plot Coulomb Stress change results" echo " Usage : coulomb2gmt.sh | options | " echo " Switches: " - echo "/*** PLOT COULOMB OUTPUTS *****************************************************/" + echo "/*** GENERAL OPTIONS **********************************************************/" echo " -r [:=region] set different region minlon maxlon minlat maxlat prjscale" + echo " -topo [:=topography] plot dem file if exist " + echo " -o [:= output] name of output files" +# echo " -l [:=labels] plot labels" +# echo " -leg [:=legend] insert legends" + echo " -cmt [:=Plot central moment tensors] insert file " + echo " -faults [:= faults] plot NOA fault database" + echo " -mt [:= map title] title map default none use quotes" + echo " -h [:= help] help menu" + echo "" + echo "/*** PLOT COULOMB OUTPUTS *****************************************************/" echo " -cstress [:=Coulomb Stress] " echo " -sstress [:=Shear Stress] " echo " -nstress [:=Normal strain] " @@ -45,10 +55,6 @@ function help { echo " -fsurf [:=Fault surface] " echo " -fdep [:=Fault calculation depth] " echo " -fcross [:=plot cross section projections] " - echo " -cmt [:=Plot central moment tensors] insert file " - echo "" - echo " -terobs scale excl plot terrestrial proc" - echo " -pscleg : plot scale legent for shear strain temp" echo "" echo "/*** PLOT OKADA85 *************************************************************/" echo " -dgpso :observed gps displacements" @@ -56,17 +62,6 @@ function help { echo " -dvert :plot vertical displacements" echo " -dsc :scale for displacements" echo "" - echo "/*** PLOT STRAINS **********************************************/" - echo " -str (gmt_file)[:= strains] Plot strain rates " - echo " -strsc [:=strain scale]" - echo "" - echo "/*** OTHER OPTIONS ************************************************************/" - echo " -topo [:=topography] plot dem file if exist " - echo " -o [:= output] name of output files" - echo " -l [:=labels] plot labels" - echo " -leg [:=legend] insert legends" - echo " -jpg [:=convert] eps file to jpg" - echo " -h [:= help] help menu" echo "/*** OUTPUT FORMATS ***********************************************************/" echo " -outjpg : Adjust and convert to JPEG" echo " -outpng : Adjust and convert to PNG (transparent where nothing is plotted)" @@ -94,13 +89,10 @@ dscale=100 # ////////////////////////////////////////////////////////////////////////////// # Pre-defined parameters for bash script switches TOPOGRAPHY=0 -LABELS=0 +# LABELS=0 OUTFILES=0 -LEGEND=0 -OUTJPG=0 -OUTPNG=0 -OUTEPS=0 -OUTPDF=0 +# LEGEND=0 +FAULTS=0 RANGE=0 CSTRESS=0 @@ -124,13 +116,21 @@ DVERT=0 STRAIN=0 STRSC=50 -##//////////////////check default param file //////////////////////////////////// +OUTJPG=0 +OUTPNG=0 +OUTEPS=0 +OUTPDF=0 + + +# ////////////////////////////////////////////////////////////////////////////// +#check default param file if [ ! -f "default-param" ] then echo "default-param file does not exist" exit 1 else source default-param + echo "Default parameters file: default-param" fi # ////////////////////////////////////////////////////////////////////////////// @@ -145,7 +145,7 @@ then help else echo "***** not enough input arguments ******" - echo " use -h to present help doc" + echo " use -h to present help documentation" exit 1 fi elif [ -f ${pth2inpdir}/${1}.inp ]; @@ -153,7 +153,7 @@ then inputfile=${1} inputdata=${2} echo "input file exist" - echo $inputfile $inputdata + echo "input coulomb file:" $inputfile " input data files:" $inputdata while [ $# -gt 2 ] do case "$3" in @@ -171,6 +171,33 @@ do shift shift ;; + -topo) + TOPOGRAPHY=1 + shift + ;; + -o) + OUTFILES=1 + outfile=${4}.ps + shift + shift + ;; + -cmt) + echo "///////BUG--if you don't use input file at -cmt switch--you lose next option!!!xaxa\\\\\\\\\\\\" + if [ -f ${4} ]; + then + CMT=1 + inpcmt=${4} + else + echo "CMT file does not exist!CMT wil not plot" + fi + shift + shift + ;; + -faults) + FAULTS=1 + shift + ;; + -cstress) CSTRESS=1 shift @@ -218,18 +245,7 @@ do FCROSS=1 shift ;; - -cmt) - echo "///////BUG--if you don't use input file at -cmt switch--you lose next option!!!xaxa\\\\\\\\\\\\" - if [ -f ${4} ]; - then - CMT=1 - inpcmt=${4} - else - echo "CMT file does not exist!CMT wil not plot" - fi - shift - shift - ;; + -dgpso) DGPSO=1 shift @@ -262,16 +278,7 @@ do shift shift ;; - -topo) - TOPOGRAPHY=1 - shift - ;; - -o) - OUTFILES=1 - outfile=${4}.ps - shift - shift - ;; + -l) LABELS=1 shift @@ -307,16 +314,48 @@ done fi # ////////////////////////////////////////////////////////////////////////////// -# Pre-defined parameters for GMT +# Output file name definition if [ "$OUTFILES" -eq 0 ] then outfile=${inputdata}.ps fi +# ////////////////////////////////////////////////////////////////////////////// +# Check if all input file exist + +### check dems +if [ "$TOPOGRAPHY" -eq 1 ] +then + if [ ! -f $inputTopoB ] + then + echo "grd file for topography toes not exist, var turn to coastline" + TOPOGRAPHY=0 + fi +fi + +### check NOA FAULT catalogue +if [ "$FAULTS" -eq 1 ] +then + if [ ! -f $pth2faults ] + then + echo "NOA Faults database does not exist" + echo "please download it and then use this switch" + FAULTS=0 + fi +fi + +### check LOGO file +if [ ! -f "$pth2logos" ] +then + echo "Logo file does not exist" + LOGO=0 +fi pth2inpfile=${pth2inpdir}/${inputfile}.inp pth2gpsfile=${inputdata}.disp + + if [ "$RANGE" -eq 0 ] then minlon=$(grep "min. lon" ${pth2inpfile} | awk '{print $6}') @@ -331,13 +370,24 @@ sclon=$(echo print $maxlon - 0.22 | python) scale=-Lf${sclon}/${sclat}/36:24/20+l+jr range=-R$minlon/$maxlon/$minlat/$maxlat proj=-Jm$minlon/$minlat/1:$prjscale - -if [ "$CSTRESS" -eq 0 ] + +# ////////////////////////////////////////////////////////////////////////////// +# Define to plot coastlines or topography + +if [ "$CSTRESS" -eq 0 ] || [ "$SSTRESS" -eq 0 ] || [ "$NSTRESS" -eq 0 ] || [ "$DILSTRAIN" -eq 0 ] then ################## Plot coastlines only ###################### gmt pscoast $range $proj -Df -W0.5/10 -G240 -UBL/4c/-2c/"DSO-HGL/NTUA" -K -Y4.5c> $outfile gmt psbasemap -R -J -O -K -B$frame:."Coulomb outputs plot": --FONT_ANNOT_PRIMARY=10p $scale --FONT_LABEL=10p >> $outfile + + # PLOT NOA CATALOGUE FAULTS Ganas et.al, 2013 + if [ "$FAULTS" -eq 1 ] + then + echo "plot NOA FAULTS CATALOGUE Ganas et.al, 2013 ..." + gmt psxy $pth2faults -R -J -O -K -W.5,204/102/0 >> $outfile + fi fi + if [ "$TOPOGRAPHY" -eq 1 ] then # ####################### TOPOGRAPHY ########################### @@ -354,7 +404,9 @@ then gmt pscoast -J -R -Df -W0.25p,black -K -O -U$logo_pos >> $outfile fi -#///////// PLOT COULOMB STRESS CHANGE +# ////////////////////////////////////////////////////////////////////////////// +# PLOT COULOMB STRESS CHANGE + if [ "$CSTRESS" -eq 1 ] then ################# Plot Coulomb source AnD coastlines only ###################### @@ -366,12 +418,19 @@ then rm test test_i test_sample.grd test.cpt gmt pscoast $range $proj -Df -W0.5,120 -O -K >> $outfile gmt psbasemap -R -J -O -K -B$frame:."Plot Coulomb Stress Change": --FONT_ANNOT_PRIMARY=10p $scale --FONT_LABEL=10p>> $outfile - + # PLOT NOA CATALOGUE FAULTS Ganas et.al, 2013 + if [ "$FAULTS" -eq 1 ] + then + echo "plot NOA FAULTS CATALOGUE Ganas et.al, 2013 ..." + gmt psxy $pth2faults -R -J -O -K -W.5,204/102/0 >> $outfile + fi #////////// Plot scale Bar \\\\\\\\\\\\\\\\\\\\ gmt psscale -D2.75i/-0.4i/4i/0.15ih -Ctestcpt -B0.2/:bar: -O -K >> $outfile fi -#///////// PLOT SHEAR STRESS CHANGE +# ////////////////////////////////////////////////////////////////////////////// +# PLOT SHEAR STRESS CHANGE + if [ "$SSTRESS" -eq 1 ] then # MAKE INPUT FILE........ @@ -388,13 +447,19 @@ then rm test test_i test_sample.grd gmt pscoast $range $proj -Df -W0.5,120 -O -K >> $outfile gmt psbasemap -R -J -O -K -B$frame:."Plot Shear Stress Change": --FONT_ANNOT_PRIMARY=10p $scale --FONT_LABEL=10p>> $outfile - + # PLOT NOA CATALOGUE FAULTS Ganas et.al, 2013 + if [ "$FAULTS" -eq 1 ] + then + echo "plot NOA FAULTS CATALOGUE Ganas et.al, 2013 ..." + gmt psxy $pth2faults -R -J -O -K -W.5,204/102/0 >> $outfile + fi #////////// Plot scale Bar \\\\\\\\\\\\\\\\\\\\ gmt psscale -D2.75i/-0.4i/4i/0.15ih -Ctestcpt.cpt -B0.2/:bar: -O -K >> $outfile rm tmp1 tmp2 tmpall testcpt.cpt fi -#///////// PLOT NORMAL STRESS CHANGE +# ////////////////////////////////////////////////////////////////////////////// +# PLOT NORMAL STRESS CHANGE if [ "$NSTRESS" -eq 1 ] then # MAKE INPUT FILE........ @@ -411,13 +476,20 @@ then rm test test_i test_sample.grd gmt pscoast $range $proj -Df -W0.5,120 -O -K >> $outfile gmt psbasemap -R -J -O -K -B$frame:."Plot Normal Stress Change": --FONT_ANNOT_PRIMARY=10p $scale --FONT_LABEL=10p>> $outfile - + # PLOT NOA CATALOGUE FAULTS Ganas et.al, 2013 + if [ "$FAULTS" -eq 1 ] + then + echo "plot NOA FAULTS CATALOGUE Ganas et.al, 2013 ..." + gmt psxy $pth2faults -R -J -O -K -W.5,204/102/0 >> $outfile + fi #////////// Plot scale Bar \\\\\\\\\\\\\\\\\\\\ gmt psscale -D2.75i/-0.4i/4i/0.15ih -Ctestcpt -B0.2/:bar: -O -K >> $outfile rm tmp1 tmp2 tmpall testcpt.cpt fi -#///////// PLOT DILATATION STRAIN +# ////////////////////////////////////////////////////////////////////////////// +# PLOT DILATATION STRAIN + if [ "$DILSTRAIN" -eq 1 ] then # MAKE INPUT FILE........ @@ -434,13 +506,20 @@ then rm test test_i test_sample.grd gmt pscoast $range $proj -Df -W0.5,120 -O -K >> $outfile gmt psbasemap -R -J -O -K -B$frame:."Plot Diletation Strain": --FONT_ANNOT_PRIMARY=10p $scale --FONT_LABEL=10p>> $outfile - + # PLOT NOA CATALOGUE FAULTS Ganas et.al, 2013 + if [ "$FAULTS" -eq 1 ] + then + echo "plot NOA FAULTS CATALOGUE Ganas et.al, 2013 ..." + gmt psxy $pth2faults -R -J -O -K -W.5,204/102/0 >> $outfile + fi #////////// Plot scale Bar \\\\\\\\\\\\\\\\\\\\ gmt psscale -D2.75i/-0.4i/4i/0.15ih -Ctestcpt.cpt -B0.2/:bar: -O -K >> $outfile rm tmp1 tmp2 tmpall testcpt.cpt fi -#///////// PLOT gmt_fault_map_proj.dat \\\\\\\\\\\\\\\ +# ////////////////////////////////////////////////////////////////////////////// +# PLOT gmt_fault_map_proj.dat + if [ "$FPROJ" -eq 1 ] then gmt psxy ${inputdata}-gmt_fault_map_proj.dat -Jm -O -R -W1,red -K >> $outfile @@ -454,8 +533,9 @@ then gmt psxy ${inputdata}-gmt_fault_calc_dep.dat -Jm -O -R -W0.4,black -K >> $outfile fi +# ////////////////////////////////////////////////////////////////////////////// +# PLOT CMT of earthquakes -#///////// PLOT CMT of earthquakes \\\\\\\\\\\\\\\\\\ if [ "$CMT" -eq 1 ] then awk '{print $1,$2}' $inpcmt | psxy -Jm -O -R -Sa0.3c -Gred -K>> $outfile @@ -463,34 +543,18 @@ then awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9}' $inpcmt | gmt psmeca -R -Jm -Sa0.4 -CP0.05 -K -O -P >> $outfile fi -#//////// PLOT CROSS SECTIO PROJECTIO \\\\\\\\\\\\\\\\\ +# ////////////////////////////////////////////////////////////////////////////// +# PLOT CROSS SECTIO PROJECTION + if [ "$FCROSS" -eq 1 ] then psxy ${inputdata}-cross.ll -Jm -O -R -W0.4,blue -K >> $outfile awk '{print $1,$2,9,0,1,"RB",$3}' ${inputdata}-cross.ll | pstext -Jm -R -Dj0.1c/0.1c -O -V -K>> $outfile fi -# # /////// PLOT TRIANGLES FROM HIST DATA \\\\\\\\\\\\\\\\\ -# grep ">" ../../triangle/gmt_src/tr_full \ -# | awk '{print $3, $4, 7, 0, 1, "RM",$2}' >tmp-tr -# # gmt psxy tmp-tr -R -J -O -K -Ss0.6c -Gwhite -Wthinnest >> $outfile -# gmt pstext tmp-tr -R -J -D-.2/-.2 -O -K -Ggreen>> $outfile -# rm tmp-tr -# -# psxy ../../triangle/gmt_src/tr_full -R -Jm -m -W.5p,102/204/0,7_7_10_7:0 -O -K >> $outfile - -if [ "$TEROBS" -eq 1 ] -then - grep ">" ../../triangle/gmt_src/tr_full \ - | awk '{print $3, $4, 5, 0, 1, "RM",$2}' >tmp-tr -# gmt psxy tmp-tr -R -J -O -K -Ss0.6c -Gwhite -Wthinnest >> $outfile - gmt pstext tmp-tr -R -J -D-.2/-.2 -O -K -Ggreen>> $outfile - rm tmp-tr - - psxy ../../triangle/gmt_src/tr_full -R -Jm -m -W.5p,102/204/0,7_7_10_7:0 -O -K >> $outfile -fi +# ////////////////////////////////////////////////////////////////////////////// +# PLOT GPS OBSERVED AND MODELED OKADA SURF DESPLACEMENTS -#/////// PLOT GPS OBSERVED AND MODELED OKADA SURF DESPLACEMENTS\\\\\\\\ scvlat=$(echo print $sclat + .07 | python) scvlon=$sclon @@ -529,35 +593,6 @@ fi # 20.50 37.50 0.02 0 0 0 0 20mm # EOF -#/////// PLOT STRAINS FROM OKADA \\\\\\\\ -#//////////////////////////////////////////////////////////////// -### PLOT STRAIN RATES parameters - -if [ "$STRAIN" -eq 1 ] -then -for i in `ls $pth2work*.sta`;do - gmt psxy $i -Jm -O -R -Sc.16c -Gyellow -W0.01c -K >> $outfile ; #fill patterns-Gp300/1:F0/0/0B-ls -# gmt pstext $i -Jm -R -Dj0.2c/0.2c -Gwhite -O -K -V>> $outfile - -done - -for i in `ls $pth2work*.reg`;do - gmt psxy $i -Jm -O -R -W0.02c,90 -K >> $outfile ; #fill patterns-Gp300/1:F0/0/0B-ls -done - - gmt psvelo $pth2comp -Jm $range -Sx${STRSC} -L -A10p+e -Gblue -W2p,blue -V -K -O>> $outfile - gmt psvelo $pth2ext -Jm $range -Sx${STRSC} -L -A10p+e -Gred -W2p,red -V -K -O>> $outfile - awk '{print $3,$2,8,0,1,"LM",$12}' $pth2strpar | gmt pstext -R -J -D.6/-.4 -O -K -Gyellow >> $outfile - - strsclon=$(echo print $maxlon - 0.22 | python) - strsclat=$(echo print $minlat + 0.18 | python) - echo "$strsclon $strsclat 0 -2 90" | gmt psvelo -Jm $range -Sx${STRSC} -L -A10p+e -Gblue -W2p,blue -V -K -O>> $outfile - echo "$strsclon $strsclat 2 0 90" | gmt psvelo -Jm $range -Sx${STRSC} -L -A10p+e -Gred -W2p,red -V -K -O>> $outfile - echo "$strsclon $strsclat 9 0 1 CB 2000 nstrain" | gmt pstext -Jm -R -Dj0c/.9c -Gwhite -O -K -V>> $outfile - -fi - - #################--- Close eps output file ----################################# echo "909 909" | gmt psxy -Sc.1 -Jm -O -R -W1,red >> $outfile diff --git a/default-param b/default-param index c651d5f..870cc87 100644 --- a/default-param +++ b/default-param @@ -1,45 +1,47 @@ #!/bin/bash #use this file to cheange default parameters for plots + # ////////////////////////////////////////////////////////////////////////////// # Set PATHS parameters pth2dems=${HOME}/Map_project/dems -# inputTopoL=${pth2dems}/ETOPO1_Bed_g_gmt4.grd -# inputTopoB=${pth2dems}/ETOPO1_Bed_g_gmt4.grd + inputTopoL=${pth2dems}/ETOPO1_gr_resample01m.grd #ETOPO1_Bed_g_gmt4.grd inputTopoB=${pth2dems}/ETOPO1_gr_resample01m.grd #ETOPO1_Bed_g_gmt4.grd + pth2logos=$HOME/Map_project/logos/DSOlogo2.eps pth2faults=$HOME/Map_project/faults/NOAFaults_v1.0.gmt +# ////////////////////////////////////////////////////////////////////////////// #Path to input file directory # pth2inptf=$(pwd) pth2inpdir=../inp_historic/ +pth2inpfile=../inp_historic/${inputfile}.inp +#pth2gpsfile=../output_files/GPS_output.csv +#pth2gpsfile=../gmt_files/${inputdata}.disp +pth2gpsfile=${inputdata}.disp +#pth2inpdata=../input_zakynthos/${inputfile}.inp - +# ////////////////////////////////////////////////////////////////////////////// #outfiles -outfile=output.ps -out_jpg=output.jpg +# outfile=output.ps +# out_jpg=output.jpg + +# ////////////////////////////////////////////////////////////////////////////// + #colormaps landcpt=land_man.cpt bathcpt=bath_man.cpt coulombcpt=Coulomb_anatolia.cpt - +# ////////////////////////////////////////////////////////////////////////////// minlon=20.2 maxlon=20.9 minlat=37.9 maxlat=38.5 prjscale=500000 - frame=0.5 -pth2inpfile=../inp_historic/${inputfile}.inp -#pth2gpsfile=../output_files/GPS_output.csv -#pth2gpsfile=../gmt_files/${inputdata}.disp -pth2gpsfile=${inputdata}.disp -#pth2inpdata=../input_zakynthos/${inputfile}.inp - - - +# ////////////////////////////////////////////////////////////////////////////// logo_pos="BL/6c/-1.5c/DSO[at]ntua" logo_pos2="-C15.6c/15.9c" legendc="-Jx1i -R0/8/0/8 -Dx18.5c/12.6c/3.6c/3.5c/BL"