def test_AuxPlane735(self): """ Test AuxPlane precision issue #735 """ s, d, r = AuxPlane(164, 90, -32) self.assertAlmostEqual(s, 254.) self.assertAlmostEqual(d, 58.) self.assertAlmostEqual(r, -180.)
def test_AuxPlane(self): """ Test AuxPlane function - all values are taken from MatLab. """ # http://en.wikipedia.org/wiki/File:USGS_sumatra_mts.gif s1 = 132.18005257215460 d1 = 84.240987194376590 r1 = 98.963372641038790 (s2, d2, r2) = AuxPlane(s1, d1, r1) self.assertAlmostEqual(s2, 254.64386091007400) self.assertAlmostEqual(d2, 10.641291652406172) self.assertAlmostEqual(r2, 32.915578422454380) # s1 = 160.55 d1 = 76.00 r1 = -46.78 (s2, d2, r2) = AuxPlane(s1, d1, r1) self.assertAlmostEqual(s2, 264.98676854650216) self.assertAlmostEqual(d2, 45.001906942415623) self.assertAlmostEqual(r2, -159.99404307049076)
def mt2parameters(MTx, M, gfscale): #Iso Mo MoIso = (MTx[0][0] + MTx[1][1] + MTx[2][2]) / 3 c = MomentTensor(MTx[2][2], MTx[0][0], MTx[1][1], MTx[0][2], -MTx[1][2], -MTx[0][1], gfscale) # Principal axes (T, N, P) = MT2Axes(c) # Nodal planes np0 = MT2Plane(c) np2 = AuxPlane(np0.strike, np0.dip, np0.rake) # Convention rake: up-down if (np0.rake > 180): np0.rake = np0.rake - 360 if (np0.rake < -180): np0.rake = np0.rake + 360 np1 = np.zeros(3.) np1 = [np0.strike, np0.dip, np0.rake] # Compute Eigenvectors and Eigenvalues # Seismic Moment and Moment Magnitude (EigVal, EigVec) = np.linalg.eig(MTx) b = copy.deepcopy(EigVal) b.sort() Mo = (abs(b[0]) + abs(b[2])) / 2. Mw = math.log10(Mo) / 1.5 - 10.73 # Compute double-couple, CLVD & iso d = copy.deepcopy(EigVal) d[0] = abs(d[0]) d[1] = abs(d[1]) d[2] = abs(d[2]) d.sort() eps = abs(d[0]) / abs(d[2]) pcdc = 100.0 * (1.0 - 2.0 * eps) pcclvd = 200.0 * eps pcdc = pcdc / 100.0 pcclvd = pcclvd / 100.0 pciso = abs(MoIso) / Mo pcsum = pcdc + pcclvd + pciso pcdc = 100.0 * pcdc / pcsum pcclvd = 100.0 * pcclvd / pcsum pciso = 100.0 * pciso / pcsum Pdc = pcdc Pclvd = pcclvd return (Mo, Mw, Pdc, Pclvd, EigVal, EigVec, T, N, P, np1, np2)
def test_stereo(azimuths,takeoffs,polarities,sdr=[]): ''' Plots points with given azimuths, takeoff angles, and polarities on a stereonet. Will also plot both planes of a double-couple given a strike/dip/rake ''' import matplotlib.pyplot as plt import mplstereonet from obspy.imaging.beachball import AuxPlane fig = plt.figure() ax = fig.add_subplot(111, projection='stereonet') up = polarities > 0 dn = polarities < 0 h_rk = ax.rake(azimuths[up]-90.,takeoffs[up],90, 'ro') h_rk = ax.rake(azimuths[dn]-90.,takeoffs[dn],90, 'b+') if sdr: s2,d2,r2 = AuxPlane(*sdr) h_rk = ax.plane(sdr[0],sdr[1],'g') h_rk = ax.rake(sdr[0],sdr[1],-sdr[2], 'go') h_rk = ax.plane(s2,d2, 'g') plt.show()