Esempio n. 1
0
    def call(self):

        self.cleanup()
        viewer = self.get_viewer()

        los = self.t_los1, self.t_los2, self.t_los3 # unit vector
        wavelength = self.t_wavelength # meter C-Band
        extent = -self.t_ext, self.t_ext, -self.t_ext, self.t_ext # meter (xmin,xmax,ymin,ymax)

        fault = okada.OkadaSource(
          strike=self.t_strike, dip=self.t_dip, rake=self.t_strike, # degree
          slip=self.t_slip, # meter
          ztop=self.t_ztop, zbottom=self.t_zbot, length=self.t_length, # meter
          xtrace=self.t_xtrace, ytrace=self.t_ytrace ) # meter

        Y, X = numpy.meshgrid(
          numpy.linspace( extent[2], extent[3], 500 ),
          numpy.linspace( extent[0], extent[1], 500 ) )

        XYZ = numpy.array([ X, Y, numpy.zeros_like(X) ]).T

        disp = fault.displacement( XYZ, poisson=.25 )

        disp_los = numpy.dot( disp, los )
        phase = ( numpy.mod( disp_los / ( .5 * wavelength ) * 2 + 1, 2 ) - 1 ) * numpy.pi

        if self.fig is None or self.fframe.closed is True or not self._live_update:
            self.fframe = self.pylab(get='figure_frame')
            self.fig = self.fframe.gcf()

        if self._live_update:
            self.fig.clf()

        ax = self.fig.add_subplot(111)
        ax.imshow( phase, extent=extent, cmap=plt.cm.jet, origin='lower' )

        if not self._live_update:
            dx = numpy.array((-.5,.5)) * fault.length * numpy.sin( fault.strike * numpy.pi / 180 )
            dy = numpy.array((-.5,.5)) * fault.length * numpy.cos( fault.strike * numpy.pi / 180 )

            ax.plot( fault.xtrace + dx, fault.ytrace + dy, 'w-', linewidth=5, solid_capstyle='round' )
            ax.plot( fault.xtrace + dx, fault.ytrace + dy, 'k--', linewidth=2, dash_capstyle='round' )

        formatter = plt.FuncFormatter( lambda x, pos: '%dkm' % int( x / 1e3 ) if x else '0' )
        ax.xaxis.set_major_formatter( formatter )
        ax.yaxis.set_major_formatter( formatter )

        ax.grid()
        self.fig.canvas.draw()

        if self._live_update:
            self.fig.canvas.show()
Esempio n. 2
0
    def save(self):
        fault = okada.OkadaSource(
          strike=self.t_strike, dip=self.t_dip, rake=self.t_strike, # degree
          slip=self.t_slip, # meter
          ztop=self.t_ztop, zbottom=self.t_zbot, length=self.t_length, # meter
          xtrace=self.t_xtrace, ytrace=self.t_ytrace ) # meter

        extent = -self.t_ext, self.t_ext, -self.t_ext, self.t_ext # meter (xmin,xmax,ymin,ymax)
        Y, X = numpy.linspace( extent[2], extent[3] ),numpy.linspace( extent[0], extent[1])

        XYZ = numpy.array([ X, Y, numpy.zeros_like(X) ]).T

        disp = fault.displacement( XYZ, poisson=.25 )
        tmint = util.str_to_time('1970-01-01 00:05:00.000')
        tr_U = trace.Trace(station='disp', channel='Z', deltat=0.5, tmin=tmint, ydata=disp[:,0])
        io.save([tr_U], 'up_displacement.mseed')
        tr_N = trace.Trace(station='disp', channel='N', deltat=0.5, tmin=tmint, ydata=disp[:,1])
        io.save([tr_N], 'north_displacement.mseed')
        tr_N = trace.Trace(station='disp', channel='E', deltat=0.5, tmin=tmint, ydata=disp[:,2])
        io.save([tr_N], 'east_displacement.mseed')