Coverage for /opt/obspy/update-docs/src/obspy/obspy/imaging/tests/test_beachball : 47%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# -*- coding: utf-8 -*- The obspy.imaging.beachball test suite. """
MomentTensor, MT2Plane, MT2Axes, Beach
""" Test cases for beachball generation. """ # directory where the test files are located
def test_Beachball(self): """ Create beachball examples in tests/output directory. """ # http://en.wikipedia.org/wiki/File:USGS_sumatra_mts.gif mt = [0.91, -0.89, -0.02, 1.78, -1.55, 0.47] Beachball(mt, outfile=os.path.join(self.path, 'bb_sumatra_mt.png')) np1 = [274, 13, 55] Beachball(np1, outfile=os.path.join(self.path, 'bb_sumatra_np1.png')) np2 = [130, 79, 98] Beachball(np2, outfile=os.path.join(self.path, 'bb_sumatra_np2.png')) # np1 = [264.98, 45.00, -159.99] Beachball(np1, outfile=os.path.join(self.path, 'bb_19950128_np1.png')) np2 = [160.55, 76.00, -46.78] Beachball(np2, outfile=os.path.join(self.path, 'bb_19950128_np2.png')) # mt = [1.45, -6.60, 5.14, -2.67, -3.16, 1.36] Beachball(mt, outfile=os.path.join(self.path, 'bb_20090102_mt.png')) np1 = [235, 80, 35] Beachball(np1, outfile=os.path.join(self.path, 'bb_20090102_np1.png')) np2 = [138, 56, 168] Beachball(np2, outfile=os.path.join(self.path, 'bb-20090102-np2.png')) # Explosion mt = [1, 1, 1, 0, 0, 0] Beachball(mt, outfile=os.path.join(self.path, 'bb_explosion.png')) # Implosion mt = [-1, -1, -1, 0, 0, 0] Beachball(mt, outfile=os.path.join(self.path, 'bb_implosion.png')) # CLVD - Compensate Linear Vector Dipole mt = [1, -2, 1, 0, 0, 0] Beachball(mt, outfile=os.path.join(self.path, 'bb_clvd.png')) # Double Couple mt = [1, -1, 0, 0, 0, 0] Beachball(mt, outfile=os.path.join(self.path, 'bb_double_couple.png')) # Lars mt = [1, -1, 0, 0, 0, -1] Beachball(mt, outfile=os.path.join(self.path, 'bb_lars.png')) # http://wwweic.eri.u-tokyo.ac.jp/yuji/Aki-nada/ np1 = [179, 55, -78] Beachball(np1, outfile=os.path.join(self.path, 'bb_geiyo_np1.png')) # np1 = [10, 42.5, 90] Beachball(np1, outfile=os.path.join(self.path, 'bb_honshu_np1.png')) np2 = [10, 42.5, 92] Beachball(np2, outfile=os.path.join(self.path, 'bb_honshu_np2.png')) # http://wwweic.eri.u-tokyo.ac.jp/yuji/tottori/ np1 = [150, 87, 1] Beachball(np1, outfile=os.path.join(self.path, 'bb_tottori_np1.png')) # http://iisee.kenken.go.jp/staff/thara/2004/09/20040905_1/2nd.html mt = [0.99, -2.00, 1.01, 0.92, 0.48, 0.15] Beachball(mt, outfile=os.path.join(self.path, 'bb_20040905_1_mt.png')) # http://iisee.kenken.go.jp/staff/thara/2004/09/20040905_0/1st.html mt = [5.24, -6.77, 1.53, 0.81, 1.49, -0.05] Beachball(mt, outfile=os.path.join(self.path, 'bb_20040905_0_mt.png')) # http://iisee.kenken.go.jp/staff/thara/miyagi.htm mt = [16.578, -7.987, -8.592, -5.515, -29.732, 7.517] Beachball(mt, outfile=os.path.join(self.path, 'bb_miyagi_mt.png')) # http://iisee.kenken.go.jp/staff/thara/20050613/chile.html mt = [-2.39, 1.04, 1.35, 0.57, -2.94, -0.94] Beachball(mt, outfile=os.path.join(self.path, 'bb_chile_mt.png'))
def test_BeachBallOutputFormats(self): """ Tests various output formats. """ fm = [115, 35, 50] data = Beachball(fm, format='pdf') self.assertEquals(data[0:4], "%PDF") # as file Beachball(fm, format='pdf', outfile=os.path.join(self.path, 'bb.pdf')) # PS data = Beachball(fm, format='ps') self.assertEquals(data[0:4], "%!PS") # as file Beachball(fm, format='ps', outfile=os.path.join(self.path, 'bb.ps')) # PNG data = Beachball(fm, format='png') self.assertEquals(data[1:4], "PNG") # as file Beachball(fm, format='png', outfile=os.path.join(self.path, 'bb.png')) # SVG data = Beachball(fm, format='svg') self.assertEquals(data[0:5], "<?xml") # as file Beachball(fm, format='svg', outfile=os.path.join(self.path, 'bb.svg'))
""" Test StrikeDip function - all values are taken from MatLab. """
""" Test AuxPlane function - all values are taken from MatLab. """ # http://en.wikipedia.org/wiki/File:USGS_sumatra_mts.gif #
""" Test TDL function - all values are taken from MatLab. """
""" Tests MT2Plane. """
""" Tests MT2Axes. """ # http://en.wikipedia.org/wiki/File:USGS_sumatra_mts.gif
def test_Beach(self): """ Tests to plot beachballs as collection into an existing axis object. The moment tensor values are taken form the test_Beachball unit test. See that test for more information about the parameters. """ mt = [[0.91, -0.89, -0.02, 1.78, -1.55, 0.47], [274, 13, 55], [130, 79, 98], [264.98, 45.00, -159.99], [160.55, 76.00, -46.78], [1.45, -6.60, 5.14, -2.67, -3.16, 1.36], [235, 80, 35], [138, 56, 168], [1, 1, 1, 0, 0, 0], [-1, -1, -1, 0, 0, 0], [1, -2, 1, 0, 0, 0], [1, -1, 0, 0, 0, 0], [1, -1, 0, 0, 0, -1], [179, 55, -78], [10, 42.5, 90], [10, 42.5, 92], [150, 87, 1], [0.99, -2.00, 1.01, 0.92, 0.48, 0.15], [5.24, -6.77, 1.53, 0.81, 1.49, -0.05], [16.578, -7.987, -8.592, -5.515, -29.732, 7.517], [-2.39, 1.04, 1.35, 0.57, -2.94, -0.94], [150, 87, 1]]
# Initialize figure fig = plt.figure(1, figsize=(6, 6), dpi=300) ax = fig.add_subplot(111, aspect='equal')
# Plot the stations or borders ax.plot([-100, -100, 100, 100], [-100, 100, -100, 100], 'rv')
x = -100 y = -100 for i, t in enumerate(mt): # add the beachball (a collection of two patches) to the axis ax.add_collection(Beach(t, width=30, xy=(x, y), linewidth=.6)) x += 50 if (i + 1) % 5 == 0: x = -100 y += 50
# Set the x and y limits and save the output ax.axis([-120, 120, -120, 120]) fig.savefig(os.path.join(self.path, 'bb_collection.png'))
if __name__ == '__main__': unittest.main(defaultTest='suite') |