def test(): sdr = [175, 75, -30] plot_farfield(sdr, points=nice_points(), plot_pt=True) plot_farfield(sdr, typ='S', points=nice_points(), plot_pt=True) mt = strikediprake_2_moments(*sdr) # NED obj = MomentTensor(mt) obj._M_to_principal_axis_system() print(obj.get_fps()) print(obj.get_p_axis(style='f')) print(obj.get_t_axis(style='f')) print(obj.get_null_axis(style='f')) print(pnt_axis(mt, out='xyz')) print(pnt_axis(mt, out='rad')) plt.show() #test()
def mt_angles(mt): """ Takes 6 components and returns fps tri-angles in degrees, with deviatoric, isotropic, DC and CLVD percentages. ______________________________________________________________________ :type mt : list or np.array. :param mt : moment tensor NM x 6 (Mxx, Myy, Mzz, Mxy, Mxz, Myz, the six independent components). :rtype : np.array [[1x3], [1x4]]. :return : full 3x3 moment tensor. .. note:: Nan value are returned for unknown parameters. The deviatoric percentage is the sum of DC and CLVD percentages. Use obspy.imaging.scripts.mopad to get correct input. ______________________________________________________________________ """ # Make sure we got np.array if np.asarray(mt) is not mt: mt = np.asarray(mt) # Getting various formats ## if given strike, dip, rake if mt.shape == (3,): strike, dip, rake = mt DC = 100 CLVD = 0 iso = 0 devi = 100 ## if given [[strike, dip, rake], [strike, dip, rake]] (e.g. by MoPad) elif mt.shape == (2,3) : strike, dip, rake = mt[0] DC = 100 CLVD = 0 iso = 0 devi = 100 ## if given [strike, dip, rake, devi] elif mt.shape == (4,): strike, dip, rake, devi = mt DC = np.nan CLVD = np.nan iso = 0 ## if given [Mxx, Myy, Mzz, Mxy, Mxz, Myz] elif mt.shape == (6,) : mt = MomentTensor(mt,'XYZ') DC = mt.get_DC_percentage() CLVD = mt.get_CLVD_percentage() iso = mt.get_iso_percentage() devi = mt.get_devi_percentage() mt = mt_angles(mt.get_fps()) strike, dip, rake = mt[0] ## if given full moment tensor elif mt.shape == (3,3) : mt = mt_angles([mt[0,0], mt[1,1], mt[2,2], mt[0,1], mt[0,2], mt[1,2]]) strike, dip, rake = mt[0] DC, CLVD, iso, devi = mt[1] else: raise Exception('I/O dimensions: only [1|2]x3, 1x[4|6] and 3x3 inputs supported.') return np.array([[strike, dip, rake], [DC, CLVD, iso, devi]])