예제 #1
0
    def show_comparison(self, nx=10):
        import matplotlib.pyplot as plt
        from mpl_toolkits.mplot3d import Axes3D  # noqa

        if nx > 1:
            plt.ion()
            plt.show()

        fig = plt.figure()
        axes1 = fig.add_subplot(2, 3, 1, aspect=1.)
        axes2 = fig.add_subplot(2, 3, 2, aspect=1.)
        axes3 = fig.add_subplot(2, 3, 3, aspect=1.)
        axes4 = fig.add_subplot(2, 3, 4, projection='3d', aspect=1.)
        axes5 = fig.add_subplot(2, 3, 5, projection='3d', aspect=1.)

        try:
            import mopad
        except ImportError:
            mopad = None

        for x in range(nx):
            mt = mtm.MomentTensor.random_mt()
            mt = mt.deviatoric()

            for axes in (axes1, axes2, axes3):
                axes.cla()
                axes.axison = False
                axes.set_xlim(-1.05, 1.05)
                axes.set_ylim(-1.05, 1.05)

            for axes in (axes4, axes5):
                axes.cla()

            axes1.set_title('Copacabana')
            axes2.set_title('Contour')
            axes3.set_title('MoPaD')
            axes4.set_title('Patches')
            axes5.set_title('Lines')

            beachball.plot_beachball_mpl(mt, axes1, size_units='data')
            beachball.plot_beachball_mpl_pixmap(mt, axes2, size_units='data')

            beachball.plot_beachball_mpl_construction(mt,
                                                      axes4,
                                                      show='patches')
            beachball.plot_beachball_mpl_construction(mt, axes5, show='lines')

            if mopad:
                try:
                    mop_mt = mopad.MomentTensor(M=mt.m6())
                    mop_beach = mopad.BeachBall(mop_mt)
                    kwargs = dict(plot_projection='lambert',
                                  plot_nodalline_width=2,
                                  plot_faultplane_width=2,
                                  plot_outerline_width=2)

                    mop_beach.ploBB(kwargs, ax=axes3)

                except Exception:
                    print(
                        'mopad failed (maybe patched mopad version is needed')

            fig.canvas.draw()

        if nx == 1:
            plt.show()
예제 #2
0
 def set_moment_tensor(self, mt):
     self.beachball = mopad.BeachBall(MT=mt)
     self.beachball._setup_BB()
     self.update()
예제 #3
0
def bb_from_eq_dict(eq_dict):

    mt = MT_from_eq_dict(eq_dict)

    return mp.BeachBall(MT=mt)
예제 #4
0
            axes.axison = False
            axes.set_xlim(-1.05, 1.05)
            axes.set_ylim(-1.05, 1.05)

        axes1.set_title('Copacabana')
        axes2.set_title('Contour')
        axes3.set_title('MoPaD')
        axes4.set_title('Patches')
        axes5.set_title('Lines')

        plot_beachball_mpl(mt, axes1)
        plot_beachball_mpl_pixmap(mt, axes2)

        plot_beachball_mpl_construction(mt, axes4, show='patches')
        plot_beachball_mpl_construction(mt, axes5, show='lines')

        if mopad:
            mop_mt = mopad.MomentTensor(M=mt.m6())
            mop_beach = mopad.BeachBall(mop_mt)
            kwargs = dict(plot_projection='ortho',
                          plot_nodalline_width=2,
                          plot_faultplane_width=2,
                          plot_outerline_width=2)

            mop_beach.ploBB(kwargs, ax=axes3)

        fig.canvas.draw()

    if nx == 1:
        plt.show()