-
Notifications
You must be signed in to change notification settings - Fork 361
/
pscoupe.c
1658 lines (1497 loc) · 69.7 KB
/
pscoupe.c
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
/*--------------------------------------------------------------------
*
* Copyright (c) 2013-2022 by the GMT Team (https://www.generic-mapping-tools.org/team.html)
* See LICENSE.TXT file for copying and redistribution conditions.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; version 3 or any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* Contact info: www.generic-mapping-tools.org
*--------------------------------------------------------------------*/
/*
* Copyright (c) 1996-2012 by G. Patau
* Donated to the GMT project by G. Patau upon her retirement from IGPG
*--------------------------------------------------------------------*/
/*
pscoupe will read focal mechanisms from input file and plot beachballs on a cross-section.
Focal mechanisms are specified in double couple, moment tensor, or principal axis.
PostScript code is written to stdout.
Author: Genevieve Patau
Date: 9 September 1992
Version: 5
Roots: based on psxy.c version 3.0, Ported to GMT 5 by P. Wessel
*/
#include "gmt_dev.h"
#include "meca.h"
#include "utilmeca.h"
#define THIS_MODULE_CLASSIC_NAME "pscoupe"
#define THIS_MODULE_MODERN_NAME "coupe"
#define THIS_MODULE_LIB "seis"
#define THIS_MODULE_PURPOSE "Plot cross-sections of focal mechanisms"
#define THIS_MODULE_KEYS "<D{,>?}"
#define THIS_MODULE_NEEDS "JR"
#define THIS_MODULE_OPTIONS "-:>BJKOPRUVXYdehipqt" GMT_OPT("c")
#define DEFAULT_FONTSIZE 9.0 /* In points */
#define DEFAULT_OFFSET 3.0 /* In points */
#define DEFAULT_SYMBOL_SIZE 6.0 /* In points */
#define READ_CMT 0
#define READ_AKI 1
#define READ_PLANES 2
#define READ_AXIS 4
#define READ_TENSOR 8
#define PLOT_DC 1
#define PLOT_AXIS 2
#define PLOT_TRACE 4
#define PLOT_TENSOR 8
/* Control structure for pscoupe */
struct PSCOUPE_CTRL {
struct PSCOUPE_A { /* -Aa|b|c|d<params>[+c[t|n]][+d<dip>][+r[a|e|<dx>]][+w<width>][+z[s]a|e|<dz>|<min>/<max>] */
bool active, frame, polygon, force, exact[2];
int fuseau;
int report; /* GMT_IS_FLOAT: print w e s n, GMT_IS_TEXT: print "-Rw/e/s/n" based on -A+r */
char proj_type;
double p_width, p_length, dmin, dmax, dz, dx;
double lon1, lat1, lon2, lat2;
double xlonref, ylatref;
struct GMT_PEN pen;
struct nodal_plane PREF;
char newfile[PATH_MAX], extfile[PATH_MAX];
} A;
struct PSCOUPE_C { /* -C<cpt> */
bool active;
char *file;
} C;
struct PSCOUPE_E { /* -E<fill> */
bool active;
struct GMT_FILL fill;
} E;
struct PSCOUPE_F { /* Repeatable -F<mode>[<args>] */
bool active;
} F;
struct PSCOUPE_G { /* -G<fill> */
bool active;
struct GMT_FILL fill;
} G;
struct PSCOUPE_H { /* -H read overall scaling factor for symbol size and pen width */
bool active;
unsigned int mode;
double value;
} H;
struct PSCOUPE_I { /* -I[<intensity>] */
bool active;
unsigned int mode; /* 0 if constant, 1 if read from file */
double value;
} I;
struct PSCOUPE_L { /* -L<pen> */
bool active;
struct GMT_PEN pen;
} L;
struct PSCOUPE_N { /* -N */
bool active;
} N;
struct PSCOUPE_Q { /* -Q */
bool active;
} Q;
struct PSCOUPE_S { /* -S<format>[<scale>][+a<angle>][+f<font>][+j<justify>][+l][+m][+o<dx>[/<dy>]][+s<ref>] and -Fs */
#include "meca_symbol.h"
/* Extra parameters for coupe */
bool zerotrace;
int symbol;
} S;
struct PSCOUPE_T { /* -T<nplane>[/<pen>] */
bool active;
unsigned int n_plane;
struct GMT_PEN pen;
} T;
struct PSCOUPE_W { /* -W<pen> */
bool active;
struct GMT_PEN pen;
} W;
struct PSCOUPE_A2 { /* -Fa[<size>[/<Psymbol>[<Tsymbol>]]] */
bool active;
char P_symbol, T_symbol;
double size;
} A2;
struct PSCOUPE_E2 { /* -Fe<fill> */
bool active;
struct GMT_FILL fill;
} E2;
struct PSCOUPE_G2 { /* -Fg<fill> */
bool active;
struct GMT_FILL fill;
} G2;
struct PSCOUPE_P2 { /* -Fp[<pen>] */
bool active;
struct GMT_PEN pen;
} P2;
struct PSCOUPE_R2 { /* -Fr[<fill>] */
bool active;
struct GMT_FILL fill;
} R2;
struct PSCOUPE_T2 { /* -Ft[<pen>] */
bool active;
struct GMT_PEN pen;
} T2;
};
enum Pscoupe_scaletype {
PSCOUPE_READ_SCALE = 0,
PSCOUPE_CONST_SCALE = 1};
static void *New_Ctrl (struct GMT_CTRL *GMT) { /* Allocate and initialize a new control structure */
struct PSCOUPE_CTRL *C;
C = gmt_M_memory (GMT, NULL, 1, struct PSCOUPE_CTRL);
/* Initialize values whose defaults are not 0/false/NULL */
C->A.PREF.dip = 90.0; /* Vertical is the default dip */
C->A.p_width = 20000; /* Infinity, basically */
C->A.exact[GMT_X] = true; /* We want exact distance range by default if +r is given */
C->A.exact[GMT_Y] = true; /* We want approximate depth range by default if +r is given */
C->L.pen = C->T.pen = C->P2.pen = C->T2.pen = C->W.pen = GMT->current.setting.map_default_pen;
/* Set width temporarily to -1. This will indicate later that we need to replace by W.pen */
C->L.pen.width = C->T.pen.width = C->P2.pen.width = C->T2.pen.width = -1.0;
//C->L.active = true;
gmt_init_fill (GMT, &C->E.fill, 1.0, 1.0, 1.0);
gmt_init_fill (GMT, &C->G.fill, 0.0, 0.0, 0.0);
C->S.font = GMT->current.setting.font_annot[GMT_PRIMARY];
C->S.font.size = DEFAULT_FONTSIZE;
C->S.justify = PSL_TC;
C->S.reference = SEIS_MAG_REFERENCE;
C->A2.size = DEFAULT_SYMBOL_SIZE * GMT->session.u2u[GMT_PT][GMT_INCH];
C->A2.P_symbol = C->A2.T_symbol = PSL_CIRCLE;
return (C);
}
static void Free_Ctrl (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *C) { /* Deallocate control structure */
if (!C) return;
gmt_M_str_free (C->C.file);
gmt_M_free (GMT, C);
}
GMT_LOCAL void pscoupe_rot_axis (struct AXIS A, struct nodal_plane PREF, struct AXIS *Ar) {
/*
* Change coordinates of axis from
* north,east,down
* to
* x1 = steepest descent upwards
* x2 = strike direction of reference plane
* x3 = x1^x2
*
* new strike is angle counted from x1 (0 <= strike < 360)
* new dip is counted from strike in x3 direction (0 <= dip <= 90)
* 19 April 1999
*
*/
double xn, xe, xz, x1, x2, x3, meca_zero_360();
xn = cosd (A.dip) * cosd (A.str);
xe = cosd (A.dip) * sind (A.str);
xz = sind (A.dip);
x1 = xn * sind (PREF.str) * cosd (PREF.dip) - xe * cosd (PREF.str) * cosd (PREF.dip) - xz * sind (PREF.dip);
x2 = xn * cosd (PREF.str) + xe * sind (PREF.str);
x3 = xn * sind (PREF.str) * sind (PREF.dip) - xe * cosd (PREF.str) * sind (PREF.dip) + xz * cosd (PREF.dip);
Ar->dip = asind (x3);
Ar->str = atan2d (x2, x1);
if (Ar->dip < 0.0) {
Ar->dip += 180.0;
Ar->str = meca_zero_360 ((Ar->str += 180.0));
}
}
GMT_LOCAL void pscoupe_rot_tensor (struct M_TENSOR mt, struct nodal_plane PREF, struct M_TENSOR *mtr) {
/*
*
* Change coordinates from
* (r,t,f) (upwards, south, east)
* to
* x1 = x2^x3
* x2 = steepest descent downwards
* x3 = strike direction of reference plane
*
* 19 April 1999
*
*/
double a = PREF.str * D2R, d = PREF.dip * D2R;
double sa, ca, s2a, c2a, sa2, ca2, sd, cd, s2d, c2d, sd2, cd2;
sincos (a, &sa, &ca);
sincos (2.0 * a, &s2a, &c2a);
sincos (d, &sd, &cd);
sincos (2.0 * d, &s2d, &c2d);
sa2 = sa * sa; ca2 = ca * ca;
sd2 = sd * sd; cd2 = cd * cd;
mtr->f[0] = cd2*mt.f[0] + sa2*sd2*mt.f[1] + ca2*sd2*mt.f[2] +
sa*s2d*mt.f[3] + ca*s2d*mt.f[4] + s2a*sd2*mt.f[5];
mtr->f[1] = sd2*mt.f[0] + sa2*cd2*mt.f[1] + ca2*cd2*mt.f[2] -
sa*s2d*mt.f[3] - ca*s2d*mt.f[4] + s2a*cd2*mt.f[5];
mtr->f[2] = ca2*mt.f[1] + sa2*mt.f[2] - s2a*mt.f[5];
mtr->f[3] = s2d*(- mt.f[0] + sa2*mt.f[1] + ca2*mt.f[2])/2. +
c2d*(sa*mt.f[3] + ca*mt.f[4]) + s2a*s2d*mt.f[5]/2.;
mtr->f[4] = s2a*sd*(- mt.f[1] + mt.f[2])/2. - ca*cd*mt.f[3] +
sa*cd*mt.f[4] - c2a*sd*mt.f[5];
mtr->f[5] = s2a*cd*(- mt.f[1] + mt.f[2])/2. + ca*sd*mt.f[3] -
sa*sd*mt.f[4] - c2a*cd*mt.f[5];
}
GMT_LOCAL void pscoupe_rot_nodal_plane (struct nodal_plane PLAN, struct nodal_plane PREF, struct nodal_plane *PLANR) {
/*
Calcule l'azimut, le pendage, le glissement relatifs d'un
mecanisme par rapport a un plan de reference PREF
defini par son azimut et son pendage.
On regarde la demi-sphere derriere le plan.
Les angles sont en degres.
Genevieve Patau, 8 septembre 1992.
*/
double dfi = PLAN.str - PREF.str;
double sd, cd, sdfi, cdfi, srd, crd;
double sir, cor, cdr, sr, cr;
sincosd (PLAN.dip, &sd, &cd);
sincosd (dfi, &sdfi, &cdfi);
sincosd (PREF.dip, &srd, &crd);
sincosd (PLAN.rake, &sir, &cor);
cdr = cd * crd + cdfi * sd * srd;
cr = - sd * sdfi;
sr = (sd * crd * cdfi - cd * srd);
PLANR->str = d_atan2d (sr, cr);
if (cdr < 0.) PLANR->str += 180.0;
PLANR->str = meca_zero_360 (PLANR->str);
PLANR->dip = acosd (fabs (cdr));
cr = cr * (sir * (cd * crd * cdfi + sd * srd) - cor * crd * sdfi) + sr * ( cor * cdfi + sir * cd * sdfi);
sr = (cor * srd * sdfi + sir * (sd * crd - cd * srd * cdfi));
PLANR->rake = d_atan2d (sr, cr);
if (cdr < 0.) {
PLANR->rake += 180.0;
if (PLANR->rake > 180.0) PLANR->rake -= 360.0;
}
}
GMT_LOCAL void pscoupe_rot_meca (st_me meca, struct nodal_plane PREF, st_me *mecar) {
/*
Projection d'un mecanisme sur un plan donne PREF.
C'est la demi-sphere derriere le plan qui est representee.
Les angles sont en degres.
Genevieve Patau, 7 septembre 1992.
*/
if (fabs (meca.NP1.str - PREF.str) < EPSIL && fabs (meca.NP1.dip - PREF.dip) < EPSIL) {
mecar->NP1.str = 0.;
mecar->NP1.dip = 0.;
mecar->NP1.rake = meca_zero_360 (270. - meca.NP1.rake);
}
else
pscoupe_rot_nodal_plane (meca.NP1, PREF, &mecar->NP1);
if (fabs (meca.NP2.str - PREF.str) < EPSIL && fabs (meca.NP2.dip - PREF.dip) < EPSIL) {
mecar->NP2.str = 0.;
mecar->NP2.dip = 0.;
mecar->NP2.rake = meca_zero_360 (270. - meca.NP2.rake);
}
else
pscoupe_rot_nodal_plane (meca.NP2, PREF, &mecar->NP2);
if (cosd (mecar->NP2.dip) < EPSIL && fabs (mecar->NP1.rake - mecar->NP2.rake) < 90.0) {
mecar->NP1.str += 180.0;
mecar->NP1.rake += 180.0;
mecar->NP1.str = meca_zero_360 (mecar->NP1.str);
if (mecar->NP1.rake > 180.0) mecar->NP1.rake -= 360.0;
}
mecar->magms = meca.magms;
mecar->moment.mant = meca.moment.mant;
mecar->moment.exponent = meca.moment.exponent;
}
GMT_LOCAL int pscoupe_gutm (double lon, double lat, double *xutm, double *yutm, int fuseau) {
double ccc = 6400057.7, eprim = 0.08276528;
double alfe = 0.00507613, bete = 0.429451e-4;
double game = 0.1696e-6;
double aj2, aj4, aj6, amo, al, arcme;
double si, co, ecoxi, eta, gn, uuu, vvv, xi;
if (fuseau == 0) fuseau = irint (floor ((lon + 186.) / 6.));
/* calcul des coordonnees utm */
amo = ((double)fuseau * 6. - 183.);
al = lat * D2R;
sincos (al, &si, &co);
xi = co * sind (lon - amo);
xi = 0.5 * log((1. + xi) / (1. - xi));
eta = atan2 (si, co * cosd (lon - amo)) - al;
gn = ccc / sqrt(1. + (eprim * co) * (eprim * co));
ecoxi = (eprim * co * xi) * (eprim * co * xi);
*xutm = gn * xi * (1. + ecoxi / 6.);
*yutm = gn * eta * (1. + ecoxi / 2.);
/* calcul de arcme (longueur de l'arc de meridien) */
uuu = co * si;
vvv = co * co;
aj2 = al + uuu;
aj4 = (3. * aj2 + 2. * uuu * vvv) / 4.;
aj6 = (5. * aj4 + 2. * uuu * vvv * vvv) / 3.;
arcme = ccc * (al - alfe * aj2 + bete * aj4 - game * aj6);
*xutm = (500000. + 0.9996 * *xutm) * 0.001;
*yutm = (0.9996 * (*yutm + arcme)) * 0.001;
return (fuseau);
}
GMT_LOCAL int pscoupe_dans_coupe (double lon, double lat, double depth, double xlonref, double ylatref, int fuseau, double str, double dip, double p_length, double p_width, double *distance, double *n_dep) {
/* if fuseau < 0, cartesian coordinates */
double xlon, ylat, largeur, sd, cd, ss, cs;
if (fuseau >= 0)
pscoupe_gutm (lon, lat, &xlon, &ylat, fuseau);
else {
xlon = lon;
ylat = lat;
}
sincosd (dip, &sd, &cd);
sincosd (str, &ss, &cs);
largeur = (xlon - xlonref) * cs - (ylat - ylatref) * ss;
*n_dep = depth * sd + largeur * cosd (dip);
largeur = depth * cosd (dip) - largeur * sd;
*distance = (ylat - ylatref) * cs + (xlon - xlonref) * ss;
return (*distance >= 0. && *distance <= p_length && fabs (largeur) <= p_width);
}
#define CONSTANTE2 0.9931177
#define RAYON 6371.0
#define COORD_DEG 0
#define COORD_RAD 1
#define COORD_KM 2
GMT_LOCAL void pscoupe_distaz (double lat1, double lon1, double lat2, double lon2, double *distkm, double *azdeg, int syscoord) {
/*
Coordinates in degrees : syscoord = 0
Coordinates in radians : syscoord = 1
Cartesian coordinates in km : syscoord = 2
*/
double slat1, clat1, slon1, clon1, slat2, clat2, slon2, clon2;
double a1, b1, g1, h1, a2, b2, c1, c3, c4, distrad;
if (syscoord == COORD_KM) {
*distkm = hypot (lon2 - lon1, lat2 - lat1);
*azdeg = atan2d (lon2 - lon1, lat2 - lat1);
}
else {
if (syscoord == COORD_DEG) {
lat1 *= D2R;
lon1 *= D2R;
lat2 *= D2R;
lon2 *= D2R;
if ((M_PI_2 - fabs(lat1)) > EPSIL) lat1 = atan(CONSTANTE2 * tan(lat1));
if ((M_PI_2 - fabs(lat2)) > EPSIL) lat2 = atan(CONSTANTE2 * tan(lat2));
}
sincos (lat1, &slat1, &clat1);
sincos (lon1, &slon1, &clon1);
sincos (lat2, &slat2, &clat2);
sincos (lon2, &slon2, &clon2);
a1 = clat1 * clon1;
b1 = clat1 * slon1;
g1 = slat1 * clon1;
h1 = slat1 * slon1;
a2 = clat2 * clon2;
b2 = clat2 * slon2;
c1 = a1 * a2 + b1 * b2 + slat1 * slat2;
if (fabs(c1) < 0.94)
distrad = acos(c1);
else if (c1 > 0.)
distrad = asin(sqrt((a1 - a2) * (a1 - a2) + (b1 - b2) * (b1 - b2) + (slat1 - slat2) * (slat1 - slat2)) / 2.) * 2.;
else
distrad = acos(sqrt((a1 + a2) * (a1 + a2) + (b1 + b2) * (b1 + b2) + (slat1 + slat2) * (slat1 + slat2)) / 2.) * 2.;
*distkm = distrad * RAYON;
c3 = (a2 - slon1) * (a2 - slon1) + (b2 + clon1) * (b2 + clon1) + slat2 * slat2 - 2.;
c4 = (a2 - g1) * (a2 - g1) + (b2 - h1) * (b2 - h1) + (slat2 + clat1) * (slat2 + clat1) - 2.;
*azdeg = atan2d (c3, c4);
}
if (*azdeg < 0.) *azdeg += 360.0;
return;
}
static int usage (struct GMTAPI_CTRL *API, int level) {
/* This displays the pscoupe synopsis and optionally full usage information */
struct GMT_FONT font;
const char *name = gmt_show_name_and_purpose (API, THIS_MODULE_LIB, THIS_MODULE_CLASSIC_NAME, THIS_MODULE_PURPOSE);
if (level == GMT_MODULE_PURPOSE) return (GMT_NOERROR);
GMT_Usage (API, 0, "usage: %s [<table>] -Aa|b|c|d<params>[+c[n|t]][+d<dip>][+r[a|e|<dx>]][+w<width>][+z[s]a|e|<dz>|<min>/<max>] "
"%s %s -S<format>[<scale>][+a<angle>][+f<font>][+j<justify>][+l][+m][+o<dx>[/<dy>]][+s<ref>] "
"[%s] [-C<cpt>] [-E<fill>] [-Fa[<size>[/<Psymbol>[<Tsymbol>]]]] [-Fe<fill>] [-Fg<fill>] [-Fr<fill>] [-Fp[<pen>]] [-Ft[<pen>]] "
"[-Fs<symbol><size>] [-G<fill>] [-H[<scale>]] [-I[<intens>]] %s[-L<pen>] [-N] %s%s "
"[-Q] [-T<nplane>[/<pen>]] [%s] [%s] [-W<pen>] [%s] [%s] %s[%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s] [%s]\n",
name, GMT_J_OPT, GMT_Rgeo_OPT, GMT_B_OPT, API->K_OPT, API->O_OPT, API->P_OPT, GMT_U_OPT, GMT_V_OPT, GMT_X_OPT, GMT_Y_OPT,
API->c_OPT, GMT_di_OPT, GMT_e_OPT, GMT_h_OPT, GMT_i_OPT, GMT_p_OPT, GMT_qi_OPT, GMT_tv_OPT, GMT_colon_OPT, GMT_PAR_OPT);
if (level == GMT_SYNOPSIS) return (GMT_MODULE_SYNOPSIS);
font = API->GMT->current.setting.font_annot[GMT_PRIMARY];
font.size = DEFAULT_FONTSIZE;
GMT_Message (API, GMT_TIME_NONE, " REQUIRED ARGUMENTS:\n");
GMT_Option (API, "<");
GMT_Usage (API, 1, "\n-Aa|b|c|d<params>[+c[n|t]][+d<dip>][+r[a|e|<dx>]][+w<width>][+z[s]a|e|<dz>|<min>/<max>]");
GMT_Usage (API, -2, "Specify cross-section parameters. Choose directive and append parameters:");
GMT_Usage (API, 3, "a: Geographic start and end points, append <lon1>/<lat1>/<lon2>/<lat2>.");
GMT_Usage (API, 3, "b: Geographic start point and strike, length: Append <lon1>/<lat1>/<strike>/<length>.");
GMT_Usage (API, 3, "c: Cartesian start and end points, append <x1>/<y1>/<x2>/<y2>.");
GMT_Usage (API, 3, "d: Cartesian start point and strike, length, Append <x1>/<y1>/<strike>/<length>.");
GMT_Usage (API, -2, "Several optional modifiers are available:");
GMT_Usage (API, 3, "+c No plotting; print the region as a -Rw/e/s/n string (+ct) or numbers (+c[n] or Default).");
GMT_Usage (API, 3, "+d Set the <dip> of the plane [90].");
GMT_Usage (API, 3, "+r Determine and set plot domain (-R) from the cross-section parameters [Use -R as given]. "
"Optionally, append a to adjust domain to suitable multiples of dx/dz, e for the exact domain, or <dx> to quantize distances.");
GMT_Usage (API, 3, "+w Set the <width> of cross-section on each side of a vertical plane or above and under an oblique plane [infinity].");
GMT_Usage (API, 3, "+z Adjust the z-range. Append a for a sensible rounding, e for the exact range, <dz> to quantize depths, or "
"distance min/max from horizontal plane in km, along steepest descent direction [no limit]. Optionally prepend s to clamp minimum depth at surface (0).");
GMT_Usage (API, -2, "Note: <width>, <length>, <dx>, <dz>, <min> and <max> must all be given in km.");
GMT_Usage (API, -2, "Use CPT to assign colors based on depth-value in 3rd column.");
GMT_Option (API, "J-,R");
GMT_Usage (API, 1, "\n-S<format>[<scale>][+a<angle>][+f<font>][+j<justify>][+l][+m][+o<dx>[/<dy>]][+s<ref>]");
GMT_Usage (API, -2, "Select format directive and optional symbol modifiers:");
GMT_Usage (API, 3, "a: Focal mechanism in Aki & Richard's convention:");
GMT_Usage (API, 4, "X Y depth strike dip rake mag [newX newY] [event_title].");
GMT_Usage (API, 3, "c: Focal mechanism in Global CMT convention");
GMT_Usage (API, 4, "X Y depth strike1 dip1 rake1 strike2 dip2 rake2 moment [newX newY] [event_title], "
"with moment in 2 columns : mantissa and exponent corresponding to seismic moment in dynes-cm.");
GMT_Usage (API, 3, "d: Closest double couple defined from seismic moment tensor (zero trace and zero determinant):");
GMT_Usage (API, 4, "X Y depth mrr mtt mff mrt mrf mtf exp [newX newY] [event_title].");
GMT_Usage (API, 3, "p: Focal mechanism defined with:");
GMT_Usage (API, 4, "X Y depth strike1 dip1 strike2 fault mag [newX newY] [event_title]. "
"fault = -1/+1 for a normal/inverse fault.");
GMT_Usage (API, 3, "m: Seismic (full) moment tensor:");
GMT_Usage (API, 4, "X Y depth mrr mtt mff mrt mrf mtf exp [newX newY] [event_title].");
GMT_Usage (API, 3, "t: Zero trace moment tensor defined from principal axis:");
GMT_Usage (API, 4, "X Y depth T_value T_azim T_plunge N_value N_azim N_plunge P_value P_azim P_plunge exp [newX newY] [event_title].");
GMT_Usage (API, 3, "x: Principal axis:");
GMT_Usage (API, 4, "X Y depth T_value T_azim T_plunge N_value N_azim N_plunge P_value P_azim P_plunge exp [newX newY] [event_title].");
GMT_Usage (API, 3, "y: Best double couple defined from principal axis:");
GMT_Usage (API, 4, "X Y depth T_value T_azim T_plunge N_value N_azim N_plunge P_value P_azim P_plunge exp [newX newY] [event_title].");
GMT_Usage (API, 3, "z: Deviatoric part of the moment tensor (zero trace):");
GMT_Usage (API, 4, "X Y depth mrr mtt mff mrt mrf mtf exp [newX newY] [event_title].");
GMT_Usage (API, -2, "If <scale> is not given then it is read from the first column after the required columns. Optional modifiers for the label:");
GMT_Usage (API, 3, "+a Set the label angle [0].");
GMT_Usage (API, 3, "+f Set font attributes for the label [%s].", gmt_putfont (API->GMT, &font));
GMT_Usage (API, 3, "+j Set the label <justification> [TC].");
GMT_Usage (API, 3, "+l Use linear symbol scaling based on moment [magnitude].");
GMT_Usage (API, 3, "+m Use <scale> as fixed size for any magnitude or moment.");
GMT_Usage (API, 3, "+o Set the label offset <dx>[/<dy>] [0/0].");
GMT_Usage (API, 3, "+s Set reference magnitude [%g] or moment [%ge%d] (if +l) for symbol size.", SEIS_MAG_REFERENCE, SEIS_MOMENT_MANT_REFERENCE, SEIS_MOMENT_EXP_REFERENCE);
GMT_Usage (API, -2, "Note: If fontsize = 0 (+f0) then no label written; offset is from the limit of the beach ball.");
GMT_Message (API, GMT_TIME_NONE, "\n OPTIONAL ARGUMENTS:\n");
GMT_Option (API, "B-");
GMT_Usage (API, 1, "\n-C<cpt>");
gmt_fill_syntax (API->GMT, 'E', NULL, "Set color used for extensive parts [Default is white].");
GMT_Usage (API, 1, "\n-F<directive><parameters> (repeatable)");
GMT_Usage (API, -2, "Set various attributes of symbols depending on directive:");
GMT_Usage (API, 3, "a: Plot axis. Optionally append <size>[/<Psymbol>[<Tsymbol>] [Default symbols are circles].");
GMT_Usage (API, 3, "e: Append color used for <Tsymbol> [Default as set by -E].");
GMT_Usage (API, 3, "g: Append color used for <Psymbol> [default as set by -G].");
GMT_Usage (API, 3, "p: Draw <Psymbol> outline using the current pen (see -W; or append alternative pen).");
GMT_Usage (API, 3, "r: Fill box behind labels with appended color.");
GMT_Usage (API, 3, "s: Select symbol type and symbol size (in %s). Choose between "
"st(a)r, (c)ircle, (d)iamond, (h)exagon, (i)nvtriangle, (s)quare, (t)riangle.",
API->GMT->session.unit_name[API->GMT->current.setting.proj_length_unit]);
GMT_Usage (API, 3, "t: Draw <Tsymbol> outline using the current pen (see -W; or append alternative pen).");
gmt_fill_syntax (API->GMT, 'G', NULL, "Set color used for compressive parts [Default is black].");
GMT_Usage (API, 1, "\n-H[<scale>]");
GMT_Usage (API, -2, "Scale symbol sizes (set via -S or input column) and pen attributes by factors read from scale column. "
"The scale column follows the symbol size column. Alternatively, append a fixed <scale>.");
GMT_Usage (API, 1, "\n-I[<intens>]");
GMT_Usage (API, -2, "Use the intensity to modulate the compressive fill color (requires -C or -G). "
"If no intensity is given we expect it to follow the required columns in the data record.");
GMT_Option (API, "K");
GMT_Usage (API, 1, "\n-L<pen>");
GMT_Usage (API, -2, "Draw line or symbol outline using the current pen (see -W; or append alternative pen).");
GMT_Usage (API, 1, "\n-N Do Not skip/clip symbols that fall outside map border [Default will ignore those outside].");
GMT_Option (API, "O,P");
GMT_Usage (API, 1, "\n-Q Do not print cross-section information to files.");
GMT_Usage (API, 1, "\n-T<plane>[/<pen>]");
GMT_Usage (API, -2, "Draw specified nodal <plane>(s) and circumference only to provide a transparent beach ball "
"using the current pen (see -W; or append alternative pen):");
GMT_Usage (API, 3, "1: Only the first nodal plane is plotted.");
GMT_Usage (API, 3, "2: Only the second nodal plane is plotted.");
GMT_Usage (API, 3, "0: Both nodal planes are plotted.");
GMT_Usage (API, -2, "Note: If moment tensor is required, nodal planes overlay moment tensor.");
GMT_Option (API, "U,V");
GMT_Usage (API, 1, "\n-W<pen>");
GMT_Usage (API, -2, "Set pen attributes [%s].", gmt_putpen (API->GMT, &API->GMT->current.setting.map_default_pen));
GMT_Option (API, "X,c,di,e,h,i,p,qi,T,:,.");
return (GMT_MODULE_USAGE);
}
GMT_LOCAL unsigned int pscoupe_parse_old_A (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, char *arg) {
int n;
char *p = NULL;
gmt_M_unused (GMT);
if ((p = strstr (arg, "+f"))) { /* Get the frame from the cross-section parameters */
Ctrl->A.frame = true;
p[0] = '\0'; /* Chop off modifier */
}
else if (arg[strlen(arg)-1] == 'f') /* Very deprecated GMT3-4 syntax */
Ctrl->A.frame = true;
if (Ctrl->A.proj_type == 'a' || Ctrl->A.proj_type == 'c') {
n = sscanf (&arg[1], "%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf",
&Ctrl->A.lon1, &Ctrl->A.lat1, &Ctrl->A.lon2, &Ctrl->A.lat2, &Ctrl->A.PREF.dip, &Ctrl->A.p_width, &Ctrl->A.dmin, &Ctrl->A.dmax);
}
else {
n = sscanf (&arg[1], "%lf/%lf/%lf/%lf/%lf/%lf/%lf/%lf",
&Ctrl->A.lon1, &Ctrl->A.lat1, &Ctrl->A.PREF.str, &Ctrl->A.p_length, &Ctrl->A.PREF.dip, &Ctrl->A.p_width, &Ctrl->A.dmin, &Ctrl->A.dmax);
}
if (n != 8) {
GMT_Report (GMT->parent, GMT_MSG_ERROR, "Parsing of old format %s only recovered %d items but 8 was expected - formatting/unexpected unit problem?\n", &arg[1], n);
return GMT_PARSE_ERROR;
}
return GMT_NOERROR;
}
static int parse (struct GMT_CTRL *GMT, struct PSCOUPE_CTRL *Ctrl, struct GMT_OPTION *options) {
/* This parses the options provided to pscoupe and sets parameters in Ctrl.
* Note Ctrl has already been initialized and non-zero default values set.
* Any GMT common options will override values set previously by other commands.
* It also replaces any file names specified as input or output with the data ID
* returned when registering these sources/destinations with the API.
*/
unsigned int n_errors = 0;
char txt_a[GMT_LEN256] = {""}, txt_b[GMT_LEN256] = {""}, txt_c[GMT_LEN256] = {""}, txt_d[GMT_LEN256] = {""}, *p = NULL;
struct GMT_OPTION *opt = NULL;
struct GMTAPI_CTRL *API = GMT->parent;
for (opt = options; opt; opt = opt->next) { /* Process all the options given */
switch (opt->option) {
case '<': /* Skip input files */
if (GMT_Get_FilePath (API, GMT_IS_DATASET, GMT_IN, GMT_FILE_REMOTE, &(opt->arg))) n_errors++;
break;
/* Processes program-specific parameters */
case 'A': /* Cross-section definition */
n_errors += gmt_M_repeated_module_option (API, Ctrl->A.active);
n_errors += gmt_get_required_char (GMT, opt->arg, opt->option, 0, &Ctrl->A.proj_type);
if (strstr (opt->arg, "+f") || gmt_count_char (GMT, opt->arg, '/') == 7) /* Old deprecated syntax */
n_errors += pscoupe_parse_old_A (GMT, Ctrl, opt->arg);
else { /* New, modifier-equipped syntax */
if ((p = gmt_first_modifier (GMT, opt->arg, "drwz"))) { /* Process any modifiers */
if (gmt_get_modifier (p, 'd', txt_a))
Ctrl->A.PREF.dip = atof (txt_a);
if (gmt_get_modifier (p, 'r', txt_a)) { /* +r[a|e|<dx>] */
Ctrl->A.frame = true;
switch (txt_a[0]) {
case 'a': /* Auto for both axes */
Ctrl->A.exact[GMT_X] = Ctrl->A.exact[GMT_Y] = false;
break;
case 'e': /* Exact data range for both axes [Default] */
case '\0':
Ctrl->A.exact[GMT_X] = Ctrl->A.exact[GMT_Y] = true;
break;
default: /* Got a <dx> argument in km so exact in x, auto in */
Ctrl->A.dx = atof (txt_a);
Ctrl->A.exact[GMT_X] = true;
break;
}
}
if (gmt_get_modifier (p, 'c', txt_a)) /* Check if +c, +cn [Default], or +ct */
Ctrl->A.report = (txt_a[0] == 't') ? GMT_IS_TEXT : GMT_IS_FLOAT;
if (gmt_get_modifier (p, 'w', txt_a))
Ctrl->A.p_width = atof (txt_a);
if (gmt_get_modifier (p, 'z', txt_a)) { /* +z[s]a|e|<dz>|<z0/z1> */
unsigned k = 0;
if (txt_a[0] == 's') { /* Force zmin to be at surface (0) */
Ctrl->A.force = true;
k++;
}
switch (txt_a[k]) {
case 'a': /* Auto-depths */
case '\0': /* Which is also the default */
Ctrl->A.exact[GMT_Y] = false; /* Determine good depth range */
break;
case 'e': /* Want exact depth range */
Ctrl->A.exact[GMT_Y] = true; /* Determine exact depth range */
break;
default:
if (strchr (txt_a, '/')) /* Gave min/max */
sscanf (&txt_a[k], "%lf/%lf", &Ctrl->A.dmin, &Ctrl->A.dmax);
else /* Gave dz increment */
Ctrl->A.dz = atof (&txt_a[k]);
Ctrl->A.exact[GMT_Y] = true; /* Determine exact rounded depth range */
break;
}
}
p[0] = '\0'; /* Chop off modifiers */
}
/* Process the first 4 args */
if (sscanf (&opt->arg[1], "%[^/]/%[^/]/%[^/]/%s", txt_a, txt_b, txt_c, txt_d) != 4) {
GMT_Report (API, GMT_MSG_ERROR, "-A requires 4 arguments before modifiers.\n");
n_errors++;
}
switch (Ctrl->A.proj_type) {
case 'a':
n_errors += gmt_verify_expectations (GMT, GMT_IS_LON, gmt_scanf (GMT, txt_a, GMT_IS_LON, &Ctrl->A.lon1), txt_a);
n_errors += gmt_verify_expectations (GMT, GMT_IS_LAT, gmt_scanf (GMT, txt_b, GMT_IS_LAT, &Ctrl->A.lat1), txt_b);
n_errors += gmt_verify_expectations (GMT, GMT_IS_LON, gmt_scanf (GMT, txt_c, GMT_IS_LON, &Ctrl->A.lon2), txt_c);
n_errors += gmt_verify_expectations (GMT, GMT_IS_LAT, gmt_scanf (GMT, txt_d, GMT_IS_LAT, &Ctrl->A.lat2), txt_d);
break;
case 'b':
n_errors += gmt_verify_expectations (GMT, GMT_IS_LON, gmt_scanf (GMT, txt_a, GMT_IS_LON, &Ctrl->A.lon1), txt_a);
n_errors += gmt_verify_expectations (GMT, GMT_IS_LAT, gmt_scanf (GMT, txt_b, GMT_IS_LAT, &Ctrl->A.lat1), txt_b);
Ctrl->A.PREF.str = atof (txt_c);
Ctrl->A.p_length = atof (txt_d);
break;
case 'c':
n_errors += gmt_verify_expectations (GMT, GMT_IS_FLOAT, gmt_scanf (GMT, txt_a, GMT_IS_FLOAT, &Ctrl->A.lon1), txt_a);
n_errors += gmt_verify_expectations (GMT, GMT_IS_FLOAT, gmt_scanf (GMT, txt_b, GMT_IS_FLOAT, &Ctrl->A.lat1), txt_b);
n_errors += gmt_verify_expectations (GMT, GMT_IS_FLOAT, gmt_scanf (GMT, txt_c, GMT_IS_FLOAT, &Ctrl->A.lon2), txt_c);
n_errors += gmt_verify_expectations (GMT, GMT_IS_FLOAT, gmt_scanf (GMT, txt_d, GMT_IS_FLOAT, &Ctrl->A.lat2), txt_d);
break;
case 'd':
n_errors += gmt_verify_expectations (GMT, GMT_IS_LON, gmt_scanf (GMT, txt_a, GMT_IS_LON, &Ctrl->A.lon1), txt_a);
n_errors += gmt_verify_expectations (GMT, GMT_IS_LAT, gmt_scanf (GMT, txt_b, GMT_IS_LAT, &Ctrl->A.lat1), txt_b);
Ctrl->A.PREF.str = atof (txt_c);
Ctrl->A.p_length = atof (txt_d);
break;
default:
GMT_Report (API, GMT_MSG_ERROR, "Option -A: Unrecognized mode %c.\n", Ctrl->A.proj_type);
n_errors++;
break;
}
}
if (Ctrl->A.proj_type == 'a' || Ctrl->A.proj_type == 'c') {
pscoupe_distaz (Ctrl->A.lat1, Ctrl->A.lon1, Ctrl->A.lat2, Ctrl->A.lon2, &Ctrl->A.p_length, &Ctrl->A.PREF.str, Ctrl->A.proj_type == 'a' ? COORD_DEG : COORD_KM);
sprintf (Ctrl->A.newfile, "A%c%.1f_%.1f_%.1f_%.1f_%.0f_%.0f_%.0f_%.0f",
Ctrl->A.proj_type, Ctrl->A.lon1, Ctrl->A.lat1, Ctrl->A.lon2, Ctrl->A.lat2, Ctrl->A.PREF.dip, Ctrl->A.p_width, Ctrl->A.dmin, Ctrl->A.dmax);
sprintf (Ctrl->A.extfile, "A%c%.1f_%.1f_%.1f_%.1f_%.0f_%.0f_%.0f_%.0f_map",
Ctrl->A.proj_type, Ctrl->A.lon1, Ctrl->A.lat1, Ctrl->A.lon2, Ctrl->A.lat2, Ctrl->A.PREF.dip, Ctrl->A.p_width, Ctrl->A.dmin, Ctrl->A.dmax);
}
else {
sprintf (Ctrl->A.newfile, "A%c%.1f_%.1f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f",
Ctrl->A.proj_type, Ctrl->A.lon1, Ctrl->A.lat1, Ctrl->A.PREF.str, Ctrl->A.p_length, Ctrl->A.PREF.dip, Ctrl->A.p_width, Ctrl->A.dmin, Ctrl->A.dmax);
sprintf (Ctrl->A.extfile, "A%c%.1f_%.1f_%.0f_%.0f_%.0f_%.0f_%.0f_%.0f_map",
Ctrl->A.proj_type, Ctrl->A.lon1, Ctrl->A.lat1, Ctrl->A.PREF.str, Ctrl->A.p_length, Ctrl->A.PREF.dip, Ctrl->A.p_width, Ctrl->A.dmin, Ctrl->A.dmax);
}
if (Ctrl->A.proj_type == 'a' || Ctrl->A.proj_type == 'b')
Ctrl->A.fuseau = pscoupe_gutm (Ctrl->A.lon1, Ctrl->A.lat1, &Ctrl->A.xlonref, &Ctrl->A.ylatref, 0);
else {
Ctrl->A.fuseau = -1;
Ctrl->A.xlonref = Ctrl->A.lon1;
Ctrl->A.ylatref = Ctrl->A.lat1;
}
Ctrl->A.polygon = true;
break;
case 'Z': /* Backwards compatibility */
if (gmt_M_compat_check (GMT, 6))
GMT_Report (API, GMT_MSG_COMPAT, "-Z<cpt> is deprecated; use -C<cpt> instead.\n");
else { /* Hard error */
n_errors += gmt_default_option_error (GMT, opt);
continue;
}
/* Deliberate fall-through here (no break) */
case 'C': /* Vary symbol color with z */
n_errors += gmt_M_repeated_module_option (API, Ctrl->C.active);
if (opt->arg[0]) Ctrl->C.file = strdup (opt->arg);
break;
case 'E': /* Set color for extensive parts */
n_errors += gmt_M_repeated_module_option (API, Ctrl->E.active);
if (!opt->arg[0] || (opt->arg[0] && gmt_getfill (GMT, opt->arg, &Ctrl->E.fill))) {
gmt_fill_syntax (GMT, 'E', NULL, " ");
n_errors++;
}
Ctrl->A.polygon = true;
break;
case 'F': /* Set various symbol parameters */
Ctrl->F.active = true;
switch (opt->arg[0]) {
case 'a': /* plot axis */
Ctrl->A2.active = true;
strncpy (txt_a, &opt->arg[1], GMT_LEN256-1);
if ((p = strchr (txt_a, '/')) != NULL) p[0] = '\0';
if (txt_a[0]) Ctrl->A2.size = gmt_M_to_inch (GMT, txt_a);
if (p) {
p++;
switch (strlen (p)) {
case 1:
Ctrl->A2.P_symbol = Ctrl->A2.T_symbol = p[0];
break;
case 2:
Ctrl->A2.P_symbol = p[0], Ctrl->A2.T_symbol = p[1];
break;
}
}
break;
case 'e': /* Set color for T axis symbol */
Ctrl->E2.active = true;
if (gmt_getfill (GMT, &opt->arg[1], &Ctrl->E2.fill)) {
gmt_fill_syntax (GMT, ' ', "Fe", " ");
n_errors++;
}
break;
case 'g': /* Set color for P axis symbol */
Ctrl->G2.active = true;
if (gmt_getfill (GMT, &opt->arg[1], &Ctrl->G2.fill)) {
gmt_fill_syntax (GMT, ' ', "Fg", " ");
n_errors++;
}
break;
case 'p': /* Draw outline of P axis symbol [set outline attributes] */
Ctrl->P2.active = true;
if (opt->arg[1] && gmt_getpen (GMT, &opt->arg[1], &Ctrl->P2.pen)) {
gmt_pen_syntax (GMT, ' ', "Fp", " ", NULL, 0);
n_errors++;
}
break;
case 'r': /* draw box around text */
Ctrl->R2.active = true;
if (opt->arg[1] && gmt_getfill (GMT, &opt->arg[1], &Ctrl->R2.fill)) {
gmt_fill_syntax (GMT, ' ', "Fr", " ");
n_errors++;
}
break;
case 's': /* Only points : get symbol [and size] */
Ctrl->S.active = true;
Ctrl->S.symbol = opt->arg[1];
if (gmt_found_modifier (GMT, opt->arg, "fjo")) {
/* New syntax: -Fs<symbol>[<size>]+f<font>+o<dx>/<dy>+j<justify> */
char word[GMT_LEN256] = {""}, *c = NULL;
/* parse beachball size */
if ((c = strchr (opt->arg, '+'))) c[0] = '\0'; /* Chop off modifiers for now */
if (opt->arg[2]) Ctrl->S.scale = gmt_M_to_inch (GMT, &opt->arg[2]);
if (c) c[0] = '+'; /* Restore modifiers */
if (gmt_get_modifier (opt->arg, 'j', word) && strchr ("LCRBMT", word[0]) && strchr ("LCRBMT", word[1]))
Ctrl->S.justify = gmt_just_decode (GMT, word, Ctrl->S.justify);
if (gmt_get_modifier (opt->arg, 'f', word)) {
if (word[0] == '-' || (word[0] == '0' && (word[1] == '\0' || word[1] == 'p')))
Ctrl->S.font.size = 0.0;
else
n_errors += gmt_getfont (GMT, word, &(Ctrl->S.font));
}
if (gmt_get_modifier (opt->arg, 'o', word)) {
if (gmt_get_pair (GMT, word, GMT_PAIR_DIM_DUP, Ctrl->S.offset) < 0) n_errors++;
} else { /* Set default offset */
if (Ctrl->S.justify%4 != 2) /* Not center aligned */
Ctrl->S.offset[0] = DEFAULT_OFFSET * GMT->session.u2u[GMT_PT][GMT_INCH];
if (Ctrl->S.justify/4 != 1) /* Not middle aligned */
Ctrl->S.offset[1] = DEFAULT_OFFSET * GMT->session.u2u[GMT_PT][GMT_INCH];
}
if (Ctrl->S.font.size <= 0.0) Ctrl->S.no_label = true;
} else { /* Old syntax: -Fs<symbol>[<size>[/fontsize[/offset[+u]]]] */
Ctrl->S.offset[1] = DEFAULT_OFFSET * GMT->session.u2u[GMT_PT][GMT_INCH]; /* Set default offset */
if ((p = strstr (opt->arg, "+u"))) { /* Plot label under symbol [over] */
Ctrl->S.justify = PSL_BC;
p[0] = '\0'; /* Chop off modifier */
}
else if (opt->arg[strlen(opt->arg)-1] == 'u') {
Ctrl->S.justify = PSL_BC;
opt->arg[strlen(opt->arg)-1] = '\0';
}
txt_a[0] = txt_b[0] = txt_c[0] = '\0';
sscanf (&opt->arg[2], "%[^/]/%[^/]/%s", txt_a, txt_b, txt_c);
if (txt_a[0]) Ctrl->S.scale = gmt_M_to_inch (GMT, txt_a);
if (txt_b[0]) Ctrl->S.font.size = gmt_convert_units (GMT, txt_b, GMT_PT, GMT_PT);
if (txt_c[0]) Ctrl->S.offset[1] = gmt_convert_units (GMT, txt_c, GMT_PT, GMT_INCH);
if (Ctrl->S.font.size < 0.0) Ctrl->S.no_label = true;
if (p) p[0] = '+'; /* Restore modifier */
}
if (gmt_M_is_zero (Ctrl->S.scale)) Ctrl->S.read = true; /* Must get size from input file */
break;
case 't': /* Draw outline of T axis symbol [set outline attributes] */
Ctrl->T2.active = true;
if (opt->arg[1] && gmt_getpen (GMT, &opt->arg[1], &Ctrl->T2.pen)) {
gmt_pen_syntax (GMT, ' ', "Ft", " ", NULL, 0);
n_errors++;
}
break;
}
break;
case 'G': /* Set color for compressive parts */
n_errors += gmt_M_repeated_module_option (API, Ctrl->G.active);
if (!opt->arg[0] || (opt->arg[0] && gmt_getfill (GMT, opt->arg, &Ctrl->G.fill))) {
gmt_fill_syntax (GMT, 'G', NULL, " ");
n_errors++;
}
Ctrl->A.polygon = true;
break;
case 'H': /* Overall symbol/pen scale column provided */
n_errors += gmt_M_repeated_module_option (API, Ctrl->H.active);
if (opt->arg[0]) { /* Gave a fixed scale - no reading from file */
Ctrl->H.value = atof (opt->arg);
Ctrl->H.mode = PSCOUPE_CONST_SCALE;
}
break;
case 'I': /* Adjust symbol color via intensity */
n_errors += gmt_M_repeated_module_option (API, Ctrl->I.active);
if (opt->arg[0])
Ctrl->I.value = atof (opt->arg);
else
Ctrl->I.mode = 1;
break;
case 'L': /* Draw outline [set outline attributes] */
n_errors += gmt_M_repeated_module_option (API, Ctrl->L.active);
if (opt->arg[0] && gmt_getpen (GMT, opt->arg, &Ctrl->L.pen)) {
gmt_pen_syntax (GMT, 'L', NULL, " ", NULL, 0);
n_errors++;
}
break;
case 'M': /* Same size for any magnitude [Deprecated 8/14/2021 6.3.0 - use -S+m instead] */
if (gmt_M_compat_check (GMT, 6)) {
GMT_Report (API, GMT_MSG_COMPAT, "-M is deprecated from 6.3.0; use -S modifier +m instead.\n");
Ctrl->S.fixed = true;
}
else
n_errors += gmt_default_option_error (GMT, opt);
break;
case 'N': /* Do not skip points outside border */
n_errors += gmt_M_repeated_module_option (API, Ctrl->N.active);
n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
break;
case 'Q': /* Switch of production of mechanism files */
n_errors += gmt_M_repeated_module_option (API, Ctrl->Q.active);
n_errors += gmt_get_no_argument (GMT, opt->arg, opt->option, 0);
break;
case 'S': /* Mechanisms : get format [and size] */
n_errors += gmt_M_repeated_module_option (API, Ctrl->S.active);
switch (opt->arg[0]) { /* parse format */
case 'c':
Ctrl->S.readmode = READ_CMT; Ctrl->S.n_cols = 11;
Ctrl->S.plotmode = PLOT_DC;
break;
case 'a':
Ctrl->S.readmode = READ_AKI; Ctrl->S.n_cols = 7;
Ctrl->S.plotmode = PLOT_DC;
break;
case 'p':
Ctrl->S.readmode = READ_PLANES; Ctrl->S.n_cols = 8;
Ctrl->S.plotmode = PLOT_DC;
break;
case 'x':
Ctrl->S.readmode = READ_AXIS; Ctrl->S.n_cols = 13;
Ctrl->S.plotmode = PLOT_TENSOR;
break;
case 'y':
Ctrl->S.readmode = READ_AXIS; Ctrl->S.n_cols = 13;
Ctrl->S.plotmode = PLOT_DC;
break;
case 't':
Ctrl->S.readmode = READ_AXIS; Ctrl->S.n_cols = 13;
Ctrl->S.plotmode = PLOT_TRACE;
break;
case 'm':
Ctrl->S.readmode = READ_TENSOR; Ctrl->S.n_cols = 10;
Ctrl->S.plotmode = PLOT_TENSOR;
Ctrl->S.zerotrace = true;
break;
case 'd':
Ctrl->S.readmode = READ_TENSOR; Ctrl->S.n_cols = 10;
Ctrl->S.plotmode = PLOT_DC;
Ctrl->S.zerotrace = true;
break;
case 'z':
Ctrl->S.readmode = READ_TENSOR; Ctrl->S.n_cols = 10;
Ctrl->S.plotmode = PLOT_TRACE;
Ctrl->S.zerotrace = true;
break;
default:
n_errors++;
break;
}
if (gmt_found_modifier (GMT, opt->arg, "afjlmos")) {
/* New syntax: -S<format>[<scale>][+a<angle>][+f<font>][+j<justify>][+l][+m][+o<dx>[/<dy>]][+s<ref>] */
char word[GMT_LEN256] = {""}, *c = NULL;
/* Parse beachball size */
if ((c = strchr (opt->arg, '+'))) c[0] = '\0'; /* Chop off modifiers for now */
Ctrl->S.scale = gmt_M_to_inch (GMT, &opt->arg[1]);
if (c) c[0] = '+'; /* Restore modifiers */
if (gmt_get_modifier (opt->arg, 'a', word))
Ctrl->S.angle = atof(word);
if (gmt_get_modifier (opt->arg, 'j', word) && strchr ("LCRBMT", word[0]) && strchr ("LCRBMT", word[1]))
Ctrl->S.justify = gmt_just_decode (GMT, word, Ctrl->S.justify);
if (gmt_get_modifier (opt->arg, 'f', word)) {
if (word[0] == '-' || (word[0] == '0' && (word[1] == '\0' || word[1] == 'p')))
Ctrl->S.font.size = 0.0;
else
n_errors += gmt_getfont (GMT, word, &(Ctrl->S.font));
}
if (gmt_get_modifier (opt->arg, 'o', word)) {
if (gmt_get_pair (GMT, word, GMT_PAIR_DIM_DUP, Ctrl->S.offset) < 0) n_errors++;
} else { /* Set default offset */
if (Ctrl->S.justify%4 != 2) /* Not center aligned */
Ctrl->S.offset[0] = DEFAULT_OFFSET * GMT->session.u2u[GMT_PT][GMT_INCH];
if (Ctrl->S.justify/4 != 1) /* Not middle aligned */
Ctrl->S.offset[1] = DEFAULT_OFFSET * GMT->session.u2u[GMT_PT][GMT_INCH];
}
if (Ctrl->S.font.size <= 0.0) Ctrl->S.no_label = true;
if (gmt_get_modifier (opt->arg, 'l', word)) {
Ctrl->S.linear = true;
Ctrl->S.reference = SEIS_MOMENT_MANT_REFERENCE * pow (10.0, SEIS_MOMENT_EXP_REFERENCE); /* May change if +s is given */
}
if (gmt_get_modifier (opt->arg, 'm', word))
Ctrl->S.fixed = true;
if (gmt_get_modifier (opt->arg, 's', word))
Ctrl->S.reference = atof (word);
} else { /* Old syntax: -S<format><scale>[/fontsize[/offset]][+u] */
Ctrl->S.offset[1] = DEFAULT_OFFSET * GMT->session.u2u[GMT_PT][GMT_INCH]; /* Set default offset */
if ((p = strstr (opt->arg, "+u"))) { /* Plot label under symbol [over] */
Ctrl->S.justify = PSL_BC;
p[0] = '\0'; /* Chop off modifier */
}
else if (opt->arg[strlen(opt->arg)-1] == 'u') {
Ctrl->S.justify = PSL_BC;
opt->arg[strlen(opt->arg)-1] = '\0';
}
txt_a[0] = txt_b[0] = txt_c[0] = '\0';
sscanf (&opt->arg[1], "%[^/]/%[^/]/%s", txt_a, txt_b, txt_c);
if (txt_a[0]) Ctrl->S.scale = gmt_M_to_inch (GMT, txt_a);
if (txt_b[0]) Ctrl->S.font.size = gmt_convert_units (GMT, txt_b, GMT_PT, GMT_PT);
if (txt_c[0]) Ctrl->S.offset[1] = gmt_convert_units (GMT, txt_c, GMT_PT, GMT_INCH);
if (Ctrl->S.font.size < 0.0) Ctrl->S.no_label = true;
if (p) p[0] = '+'; /* Restore modifier */
}
if (gmt_M_is_zero (Ctrl->S.scale)) Ctrl->S.read = true; /* Must get size from input file */
break;
case 'T':
n_errors += gmt_M_repeated_module_option (API, Ctrl->T.active);
sscanf (opt->arg, "%d", &Ctrl->T.n_plane);
if (strlen (opt->arg) > 2 && gmt_getpen (GMT, &opt->arg[2], &Ctrl->T.pen)) { /* Set transparent attributes */