def __init__(self, *args):
        QFrame.__init__(self, *args)

        self.moment_tensor = mopad.MomentTensor(M=(1, 2, 3, 4, 5, 6))

        setupdata = [(LinValControl, 'Strike 1', 0., 360., 0., 0),
                     (LinValControl, 'Dip 1', 0., 90., 0., 1),
                     (LinValControl, 'Slip-Rake 1', -180., 180., 0., 2),
                     (LinValControl, 'Strike 2', 0., 360., 0., 3),
                     (LinValControl, 'Dip 2', 0., 90., 0., 4),
                     (LinValControl, 'Slip-Rake 2', -180., 180., 0., 5)]

        layout = QGridLayout()
        self.setLayout(layout)

        widgets = []
        for i, (typ, name, vmin, vmax, vcur, ind) in enumerate(setupdata):
            widget = typ()
            widget.setup(name, vmin, vmax, vcur, ind)
            widgets.append(widget)
            layout.addWidget(widget, i, 0)
            self.connect(widget, SIGNAL('valchange(PyQt_PyObject,int)'),
                         self.valchange)

        self.widgets = widgets
        self.adjust_values()
    def valchange(self, val, ind):
        strike, dip, rake = [widget.get_value() for widget in self.widgets[:3]]

        self.moment_tensor = mopad.MomentTensor(M=(strike, dip, rake))
        self.adjust_values()

        self.emit(SIGNAL('moment_tensor_changed(PyQt_PyObject)'),
                  self.moment_tensor)
Exemple #3
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()
def MT_from_eq_dict(eq_dict):

    return mp.MomentTensor(M=mt_params_from_eq_dict(eq_dict), in_system='USE')
 def __init__(self, *args):
     QWidget.__init__(self, *args)
     mt = mopad.MomentTensor(M=(1, 2, 3, 4, 5, 6))
     self.set_moment_tensor(mt)
Exemple #6
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()