-
Notifications
You must be signed in to change notification settings - Fork 5
/
coulomb2gmt.sh
executable file
·1214 lines (1045 loc) · 34.3 KB
/
coulomb2gmt.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env bash
# //////////////////////////////////////////////////////////////////////////////
# ==============================================================================
#
# |===========================================|
# |** DIONYSOS SATELLITE OBSERVATORY **|
# |** HIGHER GEODESY LABORATORY **|
# |** National Tecnical University of Athens**|
# |===========================================|
#
# filename : coulomb2gmt.sh
# NAME=coulomb2gmt
# version : v-1.0
# VERSION=v1.0
# RELEASE=rc1.0
# licence : MIT
# created : SEP-2015
# usage :
# GMT Modules :
# UNIX progs :
# exit code(s) : 0 -> success
# : 1 -> error
# discription :
# uses :
# notes :
# update list : LAST_UPDATE=OCT-2017
# OCT-2017 : Re-format script with functions. Cross plots
# OCT-2016 : Add logos, default parameters etc, 'didimoteixo v.'
# NOV-2015 : Strain plots, gps velocities, add topography
# SEP-2015 : First release, stress plots, help, conversions
# contact : Demitris Anastasiou ([email protected])
# ----------------------------------------------------------------------
# ==============================================================================
# //////////////////////////////////////////////////////////////////////////////
# #BASH settings
# set -o errexit
# set -o pipefail
# set -o nounset
# set -o xtrace
# //////////////////////////////////////////////////////////////////////////////
# pre define parameters
# program version
VERSION="v.1.0-rc1.0"
# verbosity level for GMT, see http://gmt.soest.hawaii.edu/doc/latest/gmt.html#v-full
#
export VRBLEVM=n
# //////////////////////////////////////////////////////////////////////////////
# Source function files
source functions/checknum.sh # check number functions
source functions/messages.sh
source functions/gen_func.sh
source functions/clbplots.sh
# //////////////////////////////////////////////////////////////////////////////
# GMT parameters
#gmtset MAP_FRAME_TYPE fancy
gmt gmtset PS_PAGE_ORIENTATION portrait
gmt gmtset FONT_ANNOT_PRIMARY 8 FONT_LABEL 8 MAP_FRAME_WIDTH 0.10c FONT_TITLE 15p
gmt gmtset PS_MEDIA 19cx22c
# //////////////////////////////////////////////////////////////////////////////
# Pre-defined parameters for bash script switches
TOPOGRAPHY=0
# LABELS=0
OUTFILES=0
# LEGEND=0
export FAULTS=0
LOGOGMT=0
LOGOCUS=0
MTITLE=0
CTEXT=0
EQDIST=0
RANGE=0
OVERTOPO=0
export CSTRESS=0
export SSTRESS=0
export NSTRESS=0
STREXX=0
STREYY=0
STREZZ=0
STREYZ=0
STREXZ=0
STREXY=0
STRDIL=0
FPROJ=0
FSURF=0
FDEP=0
FCROSS=0
CMT=0
DGPSHO=0
DGPSHM=0
DGPSVO=0
DGPSVM=0
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
# //////////////////////////////////////////////////////////////////////////////
# GET COMMAND LINE ARGUMENTS
if [ "$#" -eq 0 ]; then
# no arguments call help function
help
elif [ "$#" -eq 1 ]; then
# one argument call help or version
if [ "${1}" == "-h" ] || [ "${1}" == "--help" ]; then
help
elif [ "${1}" == "-v" ] || [ "${1}" == "--version" ]; then
echo "version: "${VERSION}
exit 1
else
echo "[ERROR] Not enough input arguments."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
elif [ "$#" -eq 2 ]; then
echo "[ERROR] Not enough input arguments."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
elif [ -f ${pth2inpdir}/${1}.inp ]; then
echo "...get command line arguments..."
inputfile=${1}.inp
pth2inpfile=${pth2inpdir}/${1}.inp
inputdata=${2}
echo "[STATUS] input file exist"
echo "[STATUS] input coulomb file:" ${inputfile} " input data files code:" ${inputdata}
while [ $# -gt 2 ]; do
case "${3}" in
-d | --debug)
_DEBUG="on"
# set -x
PS4='L ${LINENO}: '
shift
;;
-r | --region)
DEBUG echo "[DEBUG:${LINENO}] -r next arguments:" ${4} ${5} ${6} ${7} ${8}
if [ $# -ge 8 ];
then
# check min longtitute is a number
isNumber ${4}; if [ $? -eq 0 ]; then
# check max longtitude is a number and greater than min longtitude
isNumber ${5}; if [ $? -eq 0 ] && [ $(echo "${5} >${4}" | bc) -eq 1 ]; then
# check min latitude is a number
isNumber ${6}; if [ $? -eq 0 ]; then
# check max latitude is a nuber and greater than min latitude
isNumber ${7}; if [ $? -eq 0 ] && [ $(echo "${7} > ${6}" | bc) -eq 1 ]; then
# check projection scale is a positive number
isNumber ${8}; if [ $? -eq 0 ] && [ $(echo "${8} > 0" | bc) -eq 1 ]; then
DEBUG echo "[DEBUG:${LINENO}] test if $?"
RANGE=1
minlon=${4}
maxlon=${5}
minlat=${6}
maxlat=${7}
prjscale=${8}
shift
shift
shift
shift
shift
else
echo "[ERROR] \"${3}\": projscale must be a number and greater than 0."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
else
echo "[ERROR] \"${3}\": maxlat must be a number and greater than minlat."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
else
echo "[ERROR] \"${3}\": minlat must be a number."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
else
echo "[ERROR] \"${3}\": maxlon must be number and greater than minlon."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
else
echo "[ERROR] \"${3}\": minlon must be number."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
else
echo "[ERROR] Not enough input arguments at \"${3}\" option."
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
shift # for -r
;;
-t | --topography)
TOPOGRAPHY=1
shift
;;
-o | --output)
DEBUG echo "[DEBUG:${LINENO}] ${3}: next argument:" ${4}
if [ $# -gt 3 ] && [ ${4:0:1} != \- ]; then
OUTFILES=1
outfile=${4}.ps
shift
shift
elif [ $# -gt 3 ] && [ ${4:0:1} == \- ]; then
echo "[WARNING] No output file name set. Default name used."
shift
elif [ $# -eq 3 ]; then
echo "[WARNING] No output file name set. Default name used."
shift
fi
;;
-lg | --logo_gmt)
LOGOGMT=1
shift
;;
-lc | --logo_custom)
LOGOCUS=1
shift
;;
-cmt | --moment_tensor)
DEBUG echo "[DEBUG:${LINENO}] ${3}: next argument:" ${4}
if [ $# -ge 4 ] && [ ${4:0:1} != \- ]; then
CMT=1
inpcmt=${pth2eqdir}/${4}
DEBUG echo "cmt file is: ${inpcmt}"
shift
elif [ $# -ge 4 ] && [ ${4:0:1} == \- ]; then
echo "[WARNING] CMT file does not set! CMT will not be plotted"
elif [ $# -eq 3 ]; then
echo "[WARNING] CMT file \""${4}"\" does not exist! CMT will not be plotted"
fi
shift #shift for arg -cmt
;;
-fl | --faults_db)
FAULTS=1
shift
;;
-mt| --map_title)
DEBUG echo "[DEBUG:${LINENO}] ${3}: next argument:" ${4}
if [ $# -ge 4 ] && [ ${4:0:1} != \- ]; then
MTITLE=1
mtitle=${4}
shift
elif [ $# -ge 4 ] && [ ${4:0:1} == \- ]; then
echo "[WARNING] No map title defined. Default title will be printed"
elif [ $# -eq 3 ]; then
echo "[WARNING] No map title defined. Default title will be printed"
fi
shift #shift for the argument -mt
;;
-ct | --custom_text)
DEBUG echo "[DEBUG:${LINENO}] ${3}: next argument:" ${4}
if [ $# -ge 4 ] && [ -f ${4} ]; then
CTEXT=1
pth2ctextfile=${4}
DEBUG echo "custom text file is: ${pth2ctextfile}"
shift
elif [ $# -ge 4 ] && [ ${4:0:1} == \- ]; then
echo "[WARNING] Custom text file does not set! Custom text will not be plotted"
elif [ $# -ge 4 ] && [ ! -f ${4} ]; then
echo "[WARNING] Custom text file \""${4}"\" does not exist! Custom text will not be plotted"
shift
elif [ $# -eq 3 ]; then
echo "[WARNING] Custom text file does not set! Custom text will not be plotted"
fi
shift # shift for the arg -ctext
;;
-ed | --eq_distribution)
DEBUG echo "[DEBUG:${LINENO}] ${3}: next argument: "${4}
if [ $# -ge 4 ] && [ ${4:0:1} != \- ]; then
EQDIST=1
pth2eqdistfile=${pth2eqdir}/${4}
shift
elif [ $# -ge 4 ] && [ ${4:0:1} == \- ]; then
echo "[WARNING] No earthquake data file defined."
elif [ $# -eq 3 ]; then
echo "[WARNING] No earthquake data file defined."
fi
shift #shift for the argument -eqdist
;;
-cstress*)
CSTRESS=1
check_arg_ot ${3:8:10}
shift
;;
-sstress*)
SSTRESS=1
check_arg_ot ${3:8:10}
shift
;;
-nstress*)
NSTRESS=1
check_arg_ot ${3:8:10}
shift
;;
-strexx*)
STREXX=1
check_arg_ot ${3:7:9}
shift
;;
-streyy*)
STREYY=1
check_arg_ot ${3:7:9}
shift
;;
-strezz*)
STREZZ=1
check_arg_ot ${3:7:9}
shift
;;
-streyz*)
STREYZ=1
check_arg_ot ${3:7:9}
shift
;;
-strexz*)
STREXZ=1
check_arg_ot ${3:7:9}
shift
;;
-strexy*)
STREXY=1
check_arg_ot ${3:7:9}
shift
;;
-strdil*)
STRDIL=1
check_arg_ot ${3:7:9}
shift
;;
-fproj)
FPROJ=1
shift
;;
-fsurf)
FSURF=1
shift
;;
-fdep)
FDEP=1
shift
;;
-fcross)
FCROSS=1
shift
;;
-dgpsho)
DGPSHO=1
shift
;;
-dgpshm)
DGPSHM=1
shift
;;
-dgpsvo)
DGPSVO=1
shift
;;
-dgpsvm)
DGPSVM=1
shift
;;
-l)
LABELS=1
shift
;;
-leg)
LEGEND=1
shift
;;
-outjpg)
OUTJPG=1
shift
;;
-outpng)
OUTPNG=1
shift
;;
-outeps)
OUTEPS=1
shift
;;
-outpdf)
OUTPDF=1
shift
;;
-h | --help )
help
;;
-v | --version)
echo "version: "$VERSION
exit 1
shift
;;
*)
echo "[ERROR] Bad argument structure. argument \"${3}\" is not right"
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
esac
done
else
echo "[ERROR] Input file does not exist! use corret input file"
echo "[STATUS] Script Finished Unsuccesful! Exit Status 1"
exit 1
fi
# //////////////////////////////////////////////////////////////////////////////
# Check confilcts for input arguments
# Only one of stress or strain components will plot.
inpconflict=$(echo print ${CSTRESS} + ${SSTRESS} + ${NSTRESS} + ${STREXX} \
+ ${STREYY} + ${STREZZ} + ${STREYZ} + ${STREXZ} + ${STREXY} | python)
DEBUG echo "[DEBUG:${LINENO}] input conflict=" ${inpconflict}
if [ "${inpconflict}" -ne 1 ] && [ "${inpconflict}" -ne 0 ]; then
echo "[ERROR] Chose only one stress or strain component to plot"
exit 1
fi
### check fcross plot only with stress change
if [ "${STREXX}" -eq 1 ] || [ "${STREYY}" -eq 1 ] || [ "${STREZZ}" -eq 1 ] \
|| [ "${STREYZ}" -eq 1 ] || [ "${STREXZ}" -eq 1 ] || [ "${STREXY}" -eq 1 ] \
&& [ "${FCROSS}" -eq 1 ]; then
echo "[WARNING] Cross section is in conflict with strain options"
echo " Only strain component will plotted in map"
DEBUG echo "[DEBUG:${LINENO}] fcross set it "
FCROSS=0
fi
# //////////////////////////////////////////////////////////////////////////////
# Output file name definition
if [ "${OUTFILES}" -eq 0 ]; then
export outfile=${inputdata}.ps
fi
# //////////////////////////////////////////////////////////////////////////////
# Paths to all input files
pth2fprojfile=${pth2datdir}/${inputdata}-gmt_fault_map_proj.dat
pth2fsurffile=${pth2datdir}/${inputdata}-gmt_fault_surface.dat
pth2fdepfile=${pth2datdir}/${inputdata}-gmt_fault_calc_dep.dat
pth2coutfile=${pth2datdir}/${inputdata}-coulomb_out.dat
pth2dcfffile=${pth2coudir}/${inputdata}-dcff.cou
pth2strnfile=${pth2coudir}/${inputdata}-Strain.cou
pth2gpsdfile=${pth2gpsdir}/${inputdata}-gps.disp
pth2crossdat=${pth2coudir}/${inputdata}-Cross_section.dat
pth2crossdcf=${pth2coudir}/${inputdata}-dcff_section.cou
pth2crossdil=${pth2coudir}/${inputdata}-dilatation_section.cou
# //////////////////////////////////////////////////////////////////////////////
# Check if all input file exist
echo "...check all input files and paths"
### check fault map projection file
if [ "${FPROJ}" -eq 1 ] && [ ! -f "${pth2fprojfile}" ]; then
echo "[WARNING] fault map projection file: "${pth2fprojfile}" does not exist"
FPROJ=0
fi
### check fault surface file
if [ "${FSURF}" -eq 1 ] && [ ! -f "${pth2fsurffile}" ]; then
echo "[WARNING] fault surface file: "${pth2fsurffile}" does not exist"
FSURF=0
fi
### check fault surface file
if [ "${FDEP}" -eq 1 ] && [ ! -f "${pth2fdepfile}" ]; then
echo "[WARNING] fault Depth file: "${pth2fdepfile}" does not exist"
FDEP=0
fi
### check dems
if [ "${TOPOGRAPHY}" -eq 1 ] || [ "${OVERTOPO}" -eq 1 ]; then
if [ ! -f "${inputTopoB}" ] || [ ! -f "${inputTopoL}" ]; then
echo "[WARNING] grd file for topography toes not exist, var turn to coastline"
TOPOGRAPHY=0; OVERTOPO=0;
fi
fi
### check NOA FAULT catalogue
if [ "${FAULTS}" -eq 1 ] && [ ! -f "${pth2faults}" ]; then
echo "[WARNING] NOA Faults database does not exist"
echo "[WARNING] please download it and then use this switch"
FAULTS=0
fi
### check cmt file
if [ "${CMT}" -eq 1 ] && [ ! -f "${inpcmt}" ]; then
echo "[WARNING] CMT file does not exist, moment tensors will not plot"
CMT=0
fi
### check eqarthquake data file
if [ "${EQDIST}" -eq 1 ] && [ ! -f "${pth2eqdistfile}" ]; then
echo "[WARNING] earthquake data file does not exist, earthquakes will not plot"
EQDIST=0
fi
### set logogmt position
if [ "${LOGOGMT}" -eq 0 ]; then
logogmt_pos=""
else
DEBUG echo "[DEBUG:${LINENO}] logo gmt position set: ${logogmt_pos}"
fi
### check LOGO file
if [ ! -f "${pth2logo}" ]; then
echo "[WARNING] Logo file does not exist"
LOGO=0
fi
### check pth2coutfile
if [ "${CSTRESS}" -eq 1 ] || [ "${SSTRESS}" -eq 1 ] || [ "${NSTRESS}" -eq 1 ]; then
if [ ! -f "${pth2coutfile}" ] || [ ! -f "${pth2dcfffile}" ]; then
echo "[WARNING] "${pth2coutfile}" or "${pth2dcfffile}" does not exist!"
echo "[WARNING] Stress output will not plot"
CSTRESS=0; SSTRESS=0; NSTRESS=0; FCROSS=0;
elif [ "${FCROSS}" -eq 1 ]; then
if [ ! -f "${pth2crossdat}" ] && [ ! -f "${pth2crossdcf}" ]; then
echo "[WARNING] "${pth2crossdat}" or "${pth2crossdcf}" does not exist!"
echo "[WARNING] Cross section will not plot"
FCROSS=0;
fi
fi
fi
### check pth2strnfile
if [ "${STREXX}" -eq 1 ] || [ "${STREYY}" -eq 1 ] || [ "${STREZZ}" -eq 1 ] \
|| [ "${STREYZ}" -eq 1 ] || [ "${STREXZ}" -eq 1 ] || [ "${STREXY}" -eq 1 ] \
|| [ "${STRDIL}" -eq 1 ]; then
if [ ! -f "${pth2coutfile}" ] || [ ! -f "${pth2strnfile}" ]; then
echo "[WARNING] "${pth2coutfile}" or "${pth2strnfile}" does not exist!"
echo "[WARNING] Stress or Strain output will not plot"
STREXX=0; STREYY=0; STREZZ=0; STREYZ=0; STREXZ=0; STREXY=0; STRDIL=0;
fi
fi
### check pth2crossdat pth2crossdil
if [ "${STRDIL}" -eq 1 ] && [ "${FCROSS}" -eq 1 ]; then
if [ ! -f "${pth2crossdat}" ] && [ ! -f "${pth2crossdil}" ]; then
echo "[WARNING] "${pth2crossdat}" or "${pth2crossdil}" does not exist!"
echo "[WARNING] Cross section will not plot"
FCROSS=0;
fi
fi
### check for displacements file
if [ "${DGPSHO}" -eq 1 ] || [ "${DGPSHM}" -eq 1 ] || [ "${DGPSVO}" -eq 1 ] \
|| [ "${DGPSVM}" -eq 1 ]; then
if [ ! -f "${pth2gpsdfile}" ]; then
echo "[WARNING] "${pth2gpsdfile}" does no exist. Velocities will not plotted."
DGPSHO=0; DGPSHM=0; DGPSVO=0; DGPSVM=0;
fi
fi
# //////////////////////////////////////////////////////////////////////////////
# Configure Map Range
if [ -z ${minlon+x} ] || [ -z ${maxlon+x} ] || [ -z ${minlat+x} ] || \
[ -z ${maxlat+x} ] || [ -z ${prjscale} ] && [ "${RANGE}" -eq 0 ]; then
minlon=$(grep "min. lon" ${pth2inpfile} | awk '{print $6}')
maxlon=$(grep "max. lon" ${pth2inpfile} | awk '{print $6}')
minlat=$(grep "min. lat" ${pth2inpfile} | awk '{print $6}')
maxlat=$(grep "max. lat" ${pth2inpfile} | awk '{print $6}')
prjscale=1500000 ##DEF 1000000
fi
# tmp_scrate=$(python -c "print((${prjscale}/150000000.)*10.)")
tmp_scrate=$(calc_scale_rate 10.)
sclat=$(echo print ${minlat} + ${tmp_scrate} | python)
tmp_scrate=$(calc_scale_rate 27.)
sclon=$(echo print ${maxlon} - ${tmp_scrate} | python)
tmp_msclat=$(python -c "print int((${minlat} + ${maxlat})/2)")
tmp_msclon=$(python -c "print int((${minlon} + ${maxlon})/2)")
export scale=-Lf${sclon}/${sclat}/${tmp_msclat}:${tmp_msclon}/${sclength}+l+jr
export range=-R${minlon}/${maxlon}/${minlat}/${maxlat}
export proj=-Jm${minlon}/${minlat}/1:${prjscale}
DEBUG echo "[DEBUG:${LINENO}] scale set: ${scale}"
DEBUG echo "[DEBUG:${LINENO}] range set: ${range}"
DEBUG echo "[DEBUG:${LINENO}] projection set: ${proj}"
### Set calculation depth
if [ -z ${CALC_DEPTH+x} ]; then
echo "[WARNING] CALC_DEPTH variable is not set. Input file will used."
export CALC_DEPTH=$(grep "DEPTH=" ${pth2inpfile} | awk '{print $6}')
echo "[STATUS] Calculation depth set to: "${CALC_DEPTH}" km"
else
echo "[STATUS] Calculation depth set to: "${CALC_DEPTH}" km"
fi
# //////////////////////////////////////////////////////////////////////////////
# Configure Map title
if [ "${MTITLE}" -eq 1 ]; then
echo "...set custom Map title..."
elif [ "${CSTRESS}" -eq 1 ]; then
mtitle="Coulomb Stress Change"
elif [ "${SSTRESS}" -eq 1 ]; then
mtitle="Shear Stress Change"
elif [ "${NSTRESS}" -eq 1 ]; then
mtitle="Normal Stress Change"
elif [ "${STREXX}" -eq 1 ]; then
mtitle="Strain Component Exx"
elif [ "${STREYY}" -eq 1 ]; then
mtitle="Strain Component Eyy"
elif [ "${STREZZ}" -eq 1 ]; then
mtitle="Strain Component Ezz"
elif [ "${STREYZ}" -eq 1 ]; then
mtitle="Strain Component Eyz"
elif [ "${STREXZ}" -eq 1 ]; then
mtitle="Strain Component Exz"
elif [ "${STREXY}" -eq 1 ]; then
mtitle="Strain Component Exy"
elif [ "${STRDIL}" -eq 1 ]; then
mtitle="Dilatation (Exx + Eyy + Ezz)"
elif [ "${DGPSHO}" -eq 1 ] || [ "${DGPSHM}" -eq 1 ]; then
mtitle="Horizontal Displacements"
elif [ "${DGPSVO}" -eq 1 ] || [ "${DGPSVM}" -eq 1 ]; then
mtitle="Vertical Displacements"
else
mtitle="Plots of Coulomb outputs"
fi
# //////////////////////////////////////////////////////////////////////////////
# Define to plot coastlines or topography
if [ "${CSTRESS}" -eq 0 ] && [ "${SSTRESS}" -eq 0 ] && [ "${NSTRESS}" -eq 0 ] \
&& [ "${STREXX}" -eq 0 ] && [ "${STREYY}" -eq 0 ] && [ "${STREZZ}" -eq 0 ] \
&& [ "${STREXZ}" -eq 0 ] && [ "${STREYZ}" -eq 0 ] && [ "${STREXY}" -eq 0 ] \
&& [ "${STRDIL}" -eq 0 ] && [ "${TOPOGRAPHY}" -eq 0 ]; then
# Plot Coastlines
gmt pscoast ${range} ${proj} -Df -W0.25p,black -G240 -Y4.5c \
-K -V${VRBLEVM} > ${outfile}
gmt psbasemap -R -J -B${frame}:."${mtitle}": ${scale} ${logogmt_pos} \
-O -K -V${VRBLEVM} >> ${outfile}
# Plot faults database
plot_faults
fi
if [ "${CSTRESS}" -eq 0 ] && [ "${SSTRESS}" -eq 0 ] && [ "${NSTRESS}" -eq 0 ] \
&& [ "${STREXX}" -eq 0 ] && [ "${STREYY}" -eq 0 ] && [ "${STREZZ}" -eq 0 ] \
&& [ "${STREXZ}" -eq 0 ] && [ "${STREYZ}" -eq 0 ] && [ "${STREXY}" -eq 0 ] \
&& [ "${STRDIL}" -eq 0 ] && [ "${TOPOGRAPHY}" -eq 1 ]; then
# ####################### TOPOGRAPHY ###########################
# bathymetry
gmt makecpt -Cgebco.cpt -T-7000/0/50 -Z -V${VRBLEVM} > ${bathcpt}
gmt grdimage ${inputTopoB} ${range} ${proj} -C${bathcpt} -K -V${VRBLEVM} > ${outfile}
gmt pscoast ${proj} -P ${range} -Df -Gc -K -O -V${VRBLEVM} >> ${outfile}
# land
gmt makecpt -Cgray.cpt -T-6000/1800/50 -Z -V${VRBLEVM} > ${landcpt}
gmt grdimage ${inputTopoL} ${range} ${proj} -C${landcpt} -K -O -V${VRBLEVM} >> ${outfile}
gmt pscoast -R -J -O -K -Q -V${VRBLEVM} >> ${outfile}
#------- coastline -------------------------------------------
gmt psbasemap -R -J -O -K -B${frame}:."${mtitle}": ${scale} -V${VRBLEVM} >> ${outfile}
gmt pscoast -J -R -Df -W0.25p,black -K -O ${logogmt_pos} -V${VRBLEVM} >> ${outfile}
# Plot faults database
plot_faults
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT COULOMB STRESS CHANGE
if [ "${CSTRESS}" -eq 1 ]; then
echo "...plot Coulomb Stress Change map... "
# Plot stress/strain raster
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo ${pth2coutfile}
else
plotstr ${pth2coutfile}
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
rm tmp* ## clear temporary files
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT SHEAR STRESS CHANGE
if [ "${SSTRESS}" -eq 1 ]; then
echo "...plot Shear Stress Change map..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpcou1
awk 'NR>3{print $5}' ${pth2dcfffile} > tmpcou2
paste -d" " tmpcou1 tmpcou2 >tmpcouall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpcouall
else
plotstr tmpcouall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT NORMAL STRESS CHANGE
if [ "${NSTRESS}" -eq 1 ]; then
echo "...plot Normal Stress Change map..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpcou1
awk 'NR>3 {print $6}' ${pth2dcfffile} > tmpcou2
paste -d" " tmpcou1 tmpcou2 > tmpcouall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpcouall
else
plotstr tmpcouall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT STRAIN COMPONENT Exx
if [ "${STREXX}" -eq 1 ]; then
echo "...plot Strain Component Exx..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $4*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT STRAIN COMPONENT Eyy
if [ "${STREYY}" -eq 1 ]; then
echo "...plot Strain Component Eyy..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $5*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT STRAIN COMPONENT Ezz
if [ "${STREZZ}" -eq 1 ]; then
echo "...plot Strain Component Ezz..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $6*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT STRAIN COMPONENT Eyz
if [ "${STREYZ}" -eq 1 ]; then
echo "...plot Strain Component Eyz..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $7*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmpstr1 tmpstr2 tmpstrall tmpgrd tmpgrd_sample.grd tmpcpt.cpt
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT STRAIN COMPONENT Exz
if [ "${STREXZ}" -eq 1 ]; then
echo "...plot Strain Component Exz..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $8*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp* ## clear temporary files
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT STRAIN COMPONENT Exy
if [ "${STREXY}" -eq 1 ]; then
echo "...plot Strain Component Exy..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $9*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT DILATATION STRAIN
if [ "${STRDIL}" -eq 1 ]; then
echo "...plot Dilatation (Exx + Eyy + Ezz)..."
# MAKE INPUT FILE........
awk '{print $1, $2}' ${pth2coutfile} > tmpstr1
awk 'NR>3 {print $10*10^'${strainscale}'}' ${pth2strnfile} > tmpstr2
paste -d" " tmpstr1 tmpstr2 > tmpstrall
if [ "${OVERTOPO}" -eq 1 ]; then
plotstr_overtopo tmpstrall
else
plotstr tmpstrall
fi
# Plot faults database
plot_faults
# Plot scale bar
plot_barscale
# clear temporary files
rm tmp*
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT gmt fault geometry
if [ "${FPROJ}" -eq 1 ]; then
echo "...plot fault projection..."
gmt psxy ${pth2fprojfile} -Jm -R -W1,red -O -K -V${VRBLEVM} >> ${outfile}
fi
if [ "${FSURF}" -eq 1 ]; then
echo "...plot fault surface..."
gmt psxy ${pth2fsurffile} -Jm -R -W0.5,green -O -K -V${VRBLEVM} >> ${outfile}
fi
if [ "${FDEP}" -eq 1 ]; then
echo "...plot depth calculation..."
gmt psxy ${pth2fdepfile} -Jm -R -W0.5,black -O -K -V${VRBLEVM} >> ${outfile}
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT earthquakes distributions
if [ "${EQDIST}" -eq 1 ]; then
echo "...plot earthquakes distribution..."
awk 'NR>2 {print $8, $7}' ${pth2eqdistfile} \
| gmt psxy -Jm -R -Sc0.09c -Gblack -O -K -V${VRBLEVM} >> ${outfile}
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT CMT of earthquakes
if [ "${CMT}" -eq 1 ]; then
echo "...plot Centroid Moment Tensor file..."
awk '{print $1,$2}' ${inpcmt} \
| gmt psxy -Jm -R -Sa0.3c -Gred -O -K -V${VRBLEVM} >> ${outfile}
awk '{print $1,$2,$3,$4,$5,$6,$7,$8,$9}' ${inpcmt} \
| gmt psmeca -R -Jm -Sa0.4 -CP0.05 -K -O -V${VRBLEVM} >> ${outfile}
fi
# //////////////////////////////////////////////////////////////////////////////
# PLOT GPS OBSERVED AND MODELED OKADA SURF DESPLACEMENTS
scdhlatl=${sclat}
scdhlonl=${sclon}
# Plot horizontal modeled displacements
if [ "${DGPSHM}" -eq 1 ]; then
echo "...plot Horizontal Modeled Displacements..."