Skip to content

Commit 888edeb

Browse files
authored
Add files via upload
Version 1.7 Including: Input of P and T axes from strain tensors obtained with fault slip analysis Version 1.8 Including: Isotropic component ratio output
1 parent 70ce072 commit 888edeb

File tree

2 files changed

+177
-21
lines changed

2 files changed

+177
-21
lines changed

FMC.py

+95-13
Original file line numberDiff line numberDiff line change
@@ -51,25 +51,33 @@
5151
# Version 1.6
5252
# Including:
5353
# Hudson et al. (1989) source-type diagram with plotting options -pd
54-
54+
#
55+
# Version 1.7
56+
# Including:
57+
# Input of P and T axes from strain tensors obtained with fault slip analysis
58+
#
59+
# Version 1.8
60+
# Including:
61+
# Isotropic component ratio output
5562

5663
import sys
5764
import argparse
5865
from argparse import RawTextHelpFormatter, ArgumentParser
59-
from numpy import c_, vstack, array, zeros, asarray, genfromtxt, atleast_2d, shape, log10, array2string
66+
from numpy import c_, vstack, array, zeros, asarray, genfromtxt, atleast_2d, shape, log10, array2string, isnan
6067
from functionsFMC import *
6168
from plotFMC import *
6269

6370
# All the command line parser thing.
6471
parser = ArgumentParser(description='Focal mechanism process\
6572
and classification.\nVersion 1.3', formatter_class=RawTextHelpFormatter)
6673
parser.add_argument('infile', nargs='?')
67-
parser.add_argument('-i', nargs=1, default=['CMT'], choices=['CMT', 'AR', 'P'],
74+
parser.add_argument('-i', nargs=1, default=['CMT'], choices=['CMT', 'AR', 'P', 'PT'],
6875
help='Input file format.\n\
6976
Choose between:\n\
7077
[CMT]: Global CMT for psmeca (GMT) [default]\n\
7178
[AR]: Aki and Richards for psmeca (GMT)\n\
72-
[P]: Old Harvard CMT with both planes for psmeca (GMT)\n ')
79+
[P]: Old Harvard CMT with both planes for psmeca (GMT)\n\
80+
[PT]: Tensor P and T axes\n')
7381
parser.add_argument(
7482
'-o', nargs=1, default=['CMT'], choices=['CMT', 'P', 'AR', 'K', 'ALL', 'CUSTOM'],
7583
help='Output file format.\n\
@@ -101,8 +109,7 @@
101109
help='If present the program will plot labels with the selected parameter on the diagram plot.\n\
102110
Type "FMC.py -helpFields" to obtain information on the data fields that can be used. \n ')
103111
parser.add_argument('-pg', nargs='?',
104-
help='If present the program will plot gridlines with the specified angular spacing on the diagram plot. [10 by default]\n\
105-
Type "FMC.py -helpFields" to obtain information on the data fields that can be used. \n ')
112+
help='If present the program will plot gridlines with the specified angular spacing on the diagram plot. [10 by default] \n ')
106113
parser.add_argument('-pt', nargs='?',
107114
help='If present the program will plot a title with the specified text on the diagram plot.\n\
108115
If no text is given, or "-pt" is not set, then the output plot file name (without extension) is used by default.\n\
@@ -187,6 +194,7 @@
187194
plungt = Plunge of T axis \n\
188195
fclvd = Compensated linear vector dipole ratio \n\
189196
iso = Isotropic component of the Moment Tensor \n\
197+
fiso = Isotropic component ratio \n\
190198
u_Hudson = u position on the Hudson diagram \n\
191199
v_Hudson = v position on the Hudson diagram \n\
192200
x_kav = x position on the Kaverina diagram \n\
@@ -196,7 +204,7 @@
196204
posX = X plotting position for GMT psmeca \n\
197205
posY = Y plotting position for GMT psmeca \n\
198206
clustID = ID number of cluster \n\
199-
\n")
207+
data1 = variable to represent any quantity to use with PT axes input \n\n")
200208
sys.exit(1)
201209

202210
if args.infile:
@@ -269,6 +277,7 @@
269277
plungt_all = zeros((n_events, 1))
270278
fclvd_all = zeros((n_events, 1))
271279
iso_all = zeros((n_events, 1))
280+
fiso_all = zeros((n_events, 1))
272281
u_Hudson_all = zeros((n_events, 1))
273282
v_Hudson_all = zeros((n_events, 1))
274283
x_kav_all = zeros((n_events, 1))
@@ -279,6 +288,7 @@
279288
posX_all = [None] * n_events
280289
posY_all = [None] * n_events
281290
clustID_all = [None] * n_events
291+
data1_all = zeros((n_events, 1))
282292

283293
# false clustID to initialize the variable
284294
clustID = 0
@@ -315,7 +325,7 @@
315325
am = asarray(([mtt, -mtf, mrt], [-mtf, mff, -mrf], [mrt, -mrf, mrr]))
316326

317327
# scalar moment and fclvd
318-
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson = moment(am)
328+
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson, fiso = moment(am)
319329
Mw = ((2.0 / 3.0) * log10(Mo)) - 10.733333
320330
mant_exp = ("%e" % Mo).split('e')
321331
mant = mant_exp[0]
@@ -377,6 +387,8 @@
377387

378388
# Focal mechanism classification Alvarez-Gomez, 2009.
379389
clas = mecclass(plungt, plungb, plungp)
390+
391+
data1=0
380392

381393
elif args.i[0] == 'AR':
382394
if fields != 10:
@@ -429,13 +441,14 @@
429441
mtf = am[0][1]
430442

431443
# scalar moment and fclvd
432-
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson = moment(am)
444+
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson, fiso = moment(am)
433445

434446
# x, y Kaverina diagram
435447
x_kav, y_kav = kave(plungt, plungb, plungp)
436448

437449
# Focal mechanism classification Alvarez-Gomez, 2009.
438450
clas = mecclass(plungt, plungb, plungp)
451+
data1=0
439452

440453
elif args.i[0] == 'P':
441454
if fields != 14:
@@ -490,7 +503,66 @@
490503
mtf = am[0][1]
491504

492505
# scalar moment and fclvd
493-
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson = moment(am)
506+
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson, fiso = moment(am)
507+
508+
# x, y Kaverina diagram
509+
x_kav, y_kav = kave(plungt, plungb, plungp)
510+
511+
# Focal mechanism classification Alvarez-Gomez, 2009.
512+
clas = mecclass(plungt, plungb, plungp)
513+
data1=0
514+
515+
elif args.i[0] == 'PT': # to work with tensors obtained from fault slip analysis
516+
if fields != 10:
517+
sys.stderr.write(
518+
"ERROR - Incorrect number of columns (should be 10). - Program aborted")
519+
sys.exit(1)
520+
else:
521+
if args.v is not None:
522+
sys.stderr.write(
523+
''.join(
524+
'\rProcessing ' + str(
525+
row + 1) + '/' + str(
526+
n_events) + ' focal mechanisms.'))
527+
lon = data[row][0]
528+
lat = data[row][1]
529+
trendp = data[row][2]
530+
plungp = data[row][3]
531+
trendt = data[row][4]
532+
plungt = data[row][5]
533+
data1 = data[row][6]
534+
posX = data[row][7]
535+
posY = data[row][8]
536+
ID = data[row][9]
537+
538+
strA, dipA, rakeA, dipdirA, strB, dipB, rakeB, dipdirB = pt2pl(trendp, plungp, trendt, plungt)
539+
540+
anX, anY, anZ, dx, dy, dz = pl2nd(strA, dipA, rakeA)
541+
px, py, pz, tx, ty, tz, bx, by, bz = nd2pt(anX, anY, anZ, dx, dy, dz)
542+
543+
slipA, plungA = slipinm(strA, dipA, rakeA)
544+
slipB, plungB = slipinm(strB, dipB, rakeB)
545+
546+
trendb, plungb = ca2ax(bx, by, bz)
547+
548+
# moment tensor from P and T
549+
Mo = 1E20 # fake scalar moment
550+
expo = 20 # fake exponent
551+
mant = 1 # fake mantissa
552+
Mw = 8 # fake Mw
553+
dep = 0 # fake depth
554+
555+
am = nd2ar(anX, anY, anZ, dx, dy, dz, Mo)
556+
am = ar2ha(am)
557+
mrr = am[2][2]
558+
mff = am[1][1]
559+
mtt = am[0][0]
560+
mrf = am[1][2]
561+
mrt = am[0][2]
562+
mtf = am[0][1]
563+
564+
# scalar moment and fclvd
565+
Mo, fclvd, val, vect, iso, u_Hudson, v_Hudson, fiso = moment(am)
494566

495567
# x, y Kaverina diagram
496568
x_kav, y_kav = kave(plungt, plungb, plungp)
@@ -534,6 +606,7 @@
534606
plungt_all[row] = "%g" % (plungt)
535607
fclvd_all[row] = "%g" % (fclvd)
536608
iso_all[row] = "%g" % (iso)
609+
fiso_all[row] = "%g" % (fiso)
537610
u_Hudson_all[row] = "%g" % (u_Hudson)
538611
v_Hudson_all[row] = "%g" % (v_Hudson)
539612
x_kav_all[row] = "%g" % (x_kav)
@@ -544,6 +617,8 @@
544617
posX_all[row] = posX
545618
posY_all[row] = posY
546619
clustID_all[row] = clustID
620+
data1_all[row] = data1
621+
547622

548623
r = row + 1
549624

@@ -579,17 +654,19 @@
579654
plungtH = vstack(((['Plunge_T']), (array(plungt_all, dtype=object))))
580655
fclvdH = vstack(((['fclvd']), (array(fclvd_all, dtype=object))))
581656
isoH = vstack(((['Isotropic']), (array(iso_all, dtype=object))))
657+
fisoH = vstack(((['Iso_ratio']), (array(fiso_all, dtype=object))))
582658
u_HudsonH = vstack(((['u_Hudson']), (array(u_Hudson_all, dtype=object))))
583659
v_HudsonH = vstack(((['v_Hudson']), (array(v_Hudson_all, dtype=object))))
584660
x_kavH = vstack(((['X_Kaverina']), (array(x_kav_all, dtype=object))))
585661
y_kavH = vstack(((['Y_Kaverina']), (array(y_kav_all, dtype=object))))
586662
IDH = vstack(((['ID']), (array(ID_all).reshape((n_events, 1)))))
587-
clasH = vstack(((['Rupture_type']), (array(clas_all).reshape((n_events, 1)))))
663+
clasH = vstack(((['rupture_type']), (array(clas_all).reshape((n_events, 1)))))
588664
posXH = vstack(
589665
((['X_position(GMT)']), (array(posX_all).reshape((n_events, 1)))))
590666
posYH = vstack(
591667
((['Y_position(GMT)']), (array(posY_all).reshape((n_events, 1)))))
592668
clustIDH = vstack(((['clustID']), (array(clustID_all).reshape((n_events, 1)))))
669+
data1H = vstack(((['data1']), (array(data1_all).reshape((n_events, 1)))))
593670

594671
dict_all = {
595672
'lon': lon_all,
@@ -623,6 +700,7 @@
623700
'plungt': plungt_all,
624701
'fclvd': fclvd_all,
625702
'iso': iso_all,
703+
'fiso': fiso_all,
626704
'u_Hudson': u_Hudson_all,
627705
'v_Hudson': v_Hudson_all,
628706
'x_kav': x_kav_all,
@@ -631,7 +709,8 @@
631709
'clas': clas_all,
632710
'posX': posX_all,
633711
'posY': posY_all,
634-
'clustID': clustID_all}
712+
'clustID': clustID_all,
713+
'data1': data1_all}
635714

636715
if args.v is not None:
637716
sys.stderr.write('\n')
@@ -706,6 +785,7 @@
706785
'plungt': plungtH,
707786
'fclvd': fclvdH,
708787
'iso': isoH,
788+
'fiso': fisoH,
709789
'u_Hudson': u_HudsonH,
710790
'v_Hudson': v_HudsonH,
711791
'x_kav': x_kavH,
@@ -714,7 +794,8 @@
714794
'clas': clasH,
715795
'posX': posXH,
716796
'posY': posYH,
717-
'clustID': clustIDH}
797+
'clustID': clustIDH,
798+
'data1': data1H}
718799

719800
#~ output
720801
if args.o[0] == 'CMT':
@@ -809,6 +890,7 @@
809890
plungtH,
810891
fclvdH,
811892
isoH,
893+
fisoH,
812894
u_HudsonH,
813895
v_HudsonH,
814896
x_kavH,

0 commit comments

Comments
 (0)