|
51 | 51 | # Version 1.6
|
52 | 52 | # Including:
|
53 | 53 | # 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 |
55 | 62 |
|
56 | 63 | import sys
|
57 | 64 | import argparse
|
58 | 65 | 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 |
60 | 67 | from functionsFMC import *
|
61 | 68 | from plotFMC import *
|
62 | 69 |
|
63 | 70 | # All the command line parser thing.
|
64 | 71 | parser = ArgumentParser(description='Focal mechanism process\
|
65 | 72 | and classification.\nVersion 1.3', formatter_class=RawTextHelpFormatter)
|
66 | 73 | 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'], |
68 | 75 | help='Input file format.\n\
|
69 | 76 | Choose between:\n\
|
70 | 77 | [CMT]: Global CMT for psmeca (GMT) [default]\n\
|
71 | 78 | [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') |
73 | 81 | parser.add_argument(
|
74 | 82 | '-o', nargs=1, default=['CMT'], choices=['CMT', 'P', 'AR', 'K', 'ALL', 'CUSTOM'],
|
75 | 83 | help='Output file format.\n\
|
|
101 | 109 | help='If present the program will plot labels with the selected parameter on the diagram plot.\n\
|
102 | 110 | Type "FMC.py -helpFields" to obtain information on the data fields that can be used. \n ')
|
103 | 111 | 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 ') |
106 | 113 | parser.add_argument('-pt', nargs='?',
|
107 | 114 | help='If present the program will plot a title with the specified text on the diagram plot.\n\
|
108 | 115 | If no text is given, or "-pt" is not set, then the output plot file name (without extension) is used by default.\n\
|
|
187 | 194 | plungt = Plunge of T axis \n\
|
188 | 195 | fclvd = Compensated linear vector dipole ratio \n\
|
189 | 196 | iso = Isotropic component of the Moment Tensor \n\
|
| 197 | +fiso = Isotropic component ratio \n\ |
190 | 198 | u_Hudson = u position on the Hudson diagram \n\
|
191 | 199 | v_Hudson = v position on the Hudson diagram \n\
|
192 | 200 | x_kav = x position on the Kaverina diagram \n\
|
|
196 | 204 | posX = X plotting position for GMT psmeca \n\
|
197 | 205 | posY = Y plotting position for GMT psmeca \n\
|
198 | 206 | clustID = ID number of cluster \n\
|
199 |
| -\n") |
| 207 | +data1 = variable to represent any quantity to use with PT axes input \n\n") |
200 | 208 | sys.exit(1)
|
201 | 209 |
|
202 | 210 | if args.infile:
|
|
269 | 277 | plungt_all = zeros((n_events, 1))
|
270 | 278 | fclvd_all = zeros((n_events, 1))
|
271 | 279 | iso_all = zeros((n_events, 1))
|
| 280 | +fiso_all = zeros((n_events, 1)) |
272 | 281 | u_Hudson_all = zeros((n_events, 1))
|
273 | 282 | v_Hudson_all = zeros((n_events, 1))
|
274 | 283 | x_kav_all = zeros((n_events, 1))
|
|
279 | 288 | posX_all = [None] * n_events
|
280 | 289 | posY_all = [None] * n_events
|
281 | 290 | clustID_all = [None] * n_events
|
| 291 | +data1_all = zeros((n_events, 1)) |
282 | 292 |
|
283 | 293 | # false clustID to initialize the variable
|
284 | 294 | clustID = 0
|
|
315 | 325 | am = asarray(([mtt, -mtf, mrt], [-mtf, mff, -mrf], [mrt, -mrf, mrr]))
|
316 | 326 |
|
317 | 327 | # 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) |
319 | 329 | Mw = ((2.0 / 3.0) * log10(Mo)) - 10.733333
|
320 | 330 | mant_exp = ("%e" % Mo).split('e')
|
321 | 331 | mant = mant_exp[0]
|
|
377 | 387 |
|
378 | 388 | # Focal mechanism classification Alvarez-Gomez, 2009.
|
379 | 389 | clas = mecclass(plungt, plungb, plungp)
|
| 390 | + |
| 391 | + data1=0 |
380 | 392 |
|
381 | 393 | elif args.i[0] == 'AR':
|
382 | 394 | if fields != 10:
|
|
429 | 441 | mtf = am[0][1]
|
430 | 442 |
|
431 | 443 | # 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) |
433 | 445 |
|
434 | 446 | # x, y Kaverina diagram
|
435 | 447 | x_kav, y_kav = kave(plungt, plungb, plungp)
|
436 | 448 |
|
437 | 449 | # Focal mechanism classification Alvarez-Gomez, 2009.
|
438 | 450 | clas = mecclass(plungt, plungb, plungp)
|
| 451 | + data1=0 |
439 | 452 |
|
440 | 453 | elif args.i[0] == 'P':
|
441 | 454 | if fields != 14:
|
|
490 | 503 | mtf = am[0][1]
|
491 | 504 |
|
492 | 505 | # 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) |
494 | 566 |
|
495 | 567 | # x, y Kaverina diagram
|
496 | 568 | x_kav, y_kav = kave(plungt, plungb, plungp)
|
|
534 | 606 | plungt_all[row] = "%g" % (plungt)
|
535 | 607 | fclvd_all[row] = "%g" % (fclvd)
|
536 | 608 | iso_all[row] = "%g" % (iso)
|
| 609 | + fiso_all[row] = "%g" % (fiso) |
537 | 610 | u_Hudson_all[row] = "%g" % (u_Hudson)
|
538 | 611 | v_Hudson_all[row] = "%g" % (v_Hudson)
|
539 | 612 | x_kav_all[row] = "%g" % (x_kav)
|
|
544 | 617 | posX_all[row] = posX
|
545 | 618 | posY_all[row] = posY
|
546 | 619 | clustID_all[row] = clustID
|
| 620 | + data1_all[row] = data1 |
| 621 | + |
547 | 622 |
|
548 | 623 | r = row + 1
|
549 | 624 |
|
|
579 | 654 | plungtH = vstack(((['Plunge_T']), (array(plungt_all, dtype=object))))
|
580 | 655 | fclvdH = vstack(((['fclvd']), (array(fclvd_all, dtype=object))))
|
581 | 656 | isoH = vstack(((['Isotropic']), (array(iso_all, dtype=object))))
|
| 657 | +fisoH = vstack(((['Iso_ratio']), (array(fiso_all, dtype=object)))) |
582 | 658 | u_HudsonH = vstack(((['u_Hudson']), (array(u_Hudson_all, dtype=object))))
|
583 | 659 | v_HudsonH = vstack(((['v_Hudson']), (array(v_Hudson_all, dtype=object))))
|
584 | 660 | x_kavH = vstack(((['X_Kaverina']), (array(x_kav_all, dtype=object))))
|
585 | 661 | y_kavH = vstack(((['Y_Kaverina']), (array(y_kav_all, dtype=object))))
|
586 | 662 | 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))))) |
588 | 664 | posXH = vstack(
|
589 | 665 | ((['X_position(GMT)']), (array(posX_all).reshape((n_events, 1)))))
|
590 | 666 | posYH = vstack(
|
591 | 667 | ((['Y_position(GMT)']), (array(posY_all).reshape((n_events, 1)))))
|
592 | 668 | clustIDH = vstack(((['clustID']), (array(clustID_all).reshape((n_events, 1)))))
|
| 669 | +data1H = vstack(((['data1']), (array(data1_all).reshape((n_events, 1))))) |
593 | 670 |
|
594 | 671 | dict_all = {
|
595 | 672 | 'lon': lon_all,
|
|
623 | 700 | 'plungt': plungt_all,
|
624 | 701 | 'fclvd': fclvd_all,
|
625 | 702 | 'iso': iso_all,
|
| 703 | + 'fiso': fiso_all, |
626 | 704 | 'u_Hudson': u_Hudson_all,
|
627 | 705 | 'v_Hudson': v_Hudson_all,
|
628 | 706 | 'x_kav': x_kav_all,
|
|
631 | 709 | 'clas': clas_all,
|
632 | 710 | 'posX': posX_all,
|
633 | 711 | 'posY': posY_all,
|
634 |
| - 'clustID': clustID_all} |
| 712 | + 'clustID': clustID_all, |
| 713 | + 'data1': data1_all} |
635 | 714 |
|
636 | 715 | if args.v is not None:
|
637 | 716 | sys.stderr.write('\n')
|
|
706 | 785 | 'plungt': plungtH,
|
707 | 786 | 'fclvd': fclvdH,
|
708 | 787 | 'iso': isoH,
|
| 788 | + 'fiso': fisoH, |
709 | 789 | 'u_Hudson': u_HudsonH,
|
710 | 790 | 'v_Hudson': v_HudsonH,
|
711 | 791 | 'x_kav': x_kavH,
|
|
714 | 794 | 'clas': clasH,
|
715 | 795 | 'posX': posXH,
|
716 | 796 | 'posY': posYH,
|
717 |
| - 'clustID': clustIDH} |
| 797 | + 'clustID': clustIDH, |
| 798 | + 'data1': data1H} |
718 | 799 |
|
719 | 800 | #~ output
|
720 | 801 | if args.o[0] == 'CMT':
|
|
809 | 890 | plungtH,
|
810 | 891 | fclvdH,
|
811 | 892 | isoH,
|
| 893 | + fisoH, |
812 | 894 | u_HudsonH,
|
813 | 895 | v_HudsonH,
|
814 | 896 | x_kavH,
|
|
0 commit comments