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

# http://pyrocko.org - GPLv3 

# 

# The Pyrocko Developers, 21st Century 

# ---|P------/S----------~Lg---------- 

from __future__ import absolute_import 

import numpy as num 

 

from pyrocko import moment_tensor as pmt 

 

 

def project(mt): 

'''Calculate Hudson's (u, v) coordinates for a given moment tensor. 

 

The moment tensor can be given as a 

:py:class:`pyrocko.moment_tensor.MomentTensor` object, or by anything that 

can be converted to a 3x3 NumPy matrix, or as the six independent moment 

tensor entries as ``(mnn, mee, mdd, mne, mnd, med)``. 

''' 

 

mt = pmt.values_to_matrix(mt) 

eig_m = pmt.eigh_check(mt)[0] 

m3, m2, m1 = eig_m / num.max(num.abs(eig_m)) 

u = -2./3. * (m1 + m3 - 2.0*m2) 

v = 1./3. * (m1 + m2 + m3) 

return u, v 

 

 

def draw_axes(axes, color='black', fontsize=12, linewidth=1.5): 

 

'''Plot axes and annotations of Hudson's MT decomposition diagram.''' 

 

axes.set_axis_off() 

axes.set_aspect(1.0) 

 

axes.set_xlim(-4./3.-0.1, 4./3.+0.1) 

axes.set_ylim(-1.1, 1.1) 

 

axes.plot( 

[-4./3., 0., 4./3., 0., -4/3.], 

[-1./3., -1., 1./3., 1., -1./3.], 

zorder=-1, 

linewidth=linewidth, 

color=color) 

 

axes.plot( 

[-1.0, 1.0], 

[0., 0.], 

zorder=-1, 

linewidth=linewidth, 

color=color) 

 

axes.plot( 

[0., 0.], 

[-1., 1.], 

zorder=-1, 

linewidth=linewidth, 

color=color) 

 

d = fontsize/3. 

for txt, pos, off, va, ha in [ 

('+Isotropic', (0., 1.), (-d, d), 'bottom', 'right'), 

('-Isotropic', (0., -1.), (d, -d), 'top', 'left'), 

('-CLVD', (+1.0, 0.), (d, -d), 'top', 'left'), 

('+CLVD', (-1.0, 0.), (-d, d), 'bottom', 'right')]: 

 

axes.plot( 

pos[0], pos[1], 'o', 

color=color, 

markersize=fontsize/2.) 

 

axes.annotate( 

txt, 

xy=pos, 

xycoords='data', 

xytext=off, 

textcoords='offset points', 

verticalalignment=va, 

horizontalalignment=ha, 

rotation=0.) 

 

for txt, pos, off, va, ha in [ 

('-Dipole', (2./3., -1./3.), (d, -d), 'top', 'left'), 

('+Dipole', (-2./3., 1./3.), (-d, d), 'bottom', 'right'), 

('-Crack', (4./9., -5./9.), (d, -d), 'top', 'left'), 

('+Crack', (-4./9., 5./9.), (-d, d), 'bottom', 'right')]: 

 

axes.plot( 

pos[0], pos[1], 'o', 

color=color, 

markersize=fontsize/2.) 

 

axes.annotate( 

txt, 

xy=pos, 

xycoords='data', 

xytext=off, 

textcoords='offset points', 

verticalalignment=va, 

horizontalalignment=ha, 

rotation=0.)