def test_optimization(self): store_dir = self.get_pulse_store_dir() engine = gf.LocalEngine(store_dirs=[store_dir]) sources = [ gf.RectangularExplosionSource(time=0.0025, depth=depth, moment=1.0, length=100., width=0., nucleation_x=-1) for depth in [100., 200., 300.] ] targetss = [[ gf.Target(codes=('', 'STA', opt, component), north_shift=500., east_shift=125., depth=depth, interpolation='multilinear', optimization=opt) for component in 'ZNE' for depth in [0., 5., 10] ] for opt in ('disable', 'enable')] resps = [engine.process(sources, targets) for targets in targetss] iters = [resp.iter_results() for resp in resps] for i in xrange(len(sources) * len(targetss[0])): s1, t1, tr1 = iters[0].next() s2, t2, tr2 = iters[1].next() self.assertEqual(tr1.data_len(), tr2.data_len()) self.assertEqual(tr1.tmin, tr2.tmin) self.assertTrue(numeq(tr1.ydata, tr2.ydata, 0.0001))
inv_trans = ax.transData.inverted() # set the bouding point relative to the plotted axis of the beachball x0, y1 = inv_trans.transform( move_trans.transform(ax.transData.transform((x0, y1)))) # plot beachball beachball.plot_beachball_mpl(source1.pyrocko_moment_tensor(), ax, beachball_type='full', size=sz, position=(x0, y1), linewidth=1.) # create source object source2 = gf.RectangularExplosionSource(depth=35e3, strike=0., dip=90.) # set size of beachball sz = 30. # set beachball offset in points (one point from each axis) szpt = (sz / 2.) / 72. + 1. / 72. # get the bounding point (right-upper) x1 = ax.get_xlim()[1] y1 = ax.get_ylim()[1] # create a translation matrix, based on the final figure size and # beachball location move_trans = transforms.ScaledTranslation(-szpt, -szpt, fig.dpi_scale_trans) # get the inverse matrix for the axis where the beachball will be plotted