def test_times(self): """ Test if the correct times array is returned for normal traces and traces with gaps. """ tr = Trace(data=np.ones(100)) tr.stats.sampling_rate = 20 start = UTCDateTime(2000, 1, 1, 0, 0, 0, 0) tr.stats.starttime = start tm = tr.times() self.assertAlmostEquals(tm[-1], tr.stats.endtime - tr.stats.starttime) tr.data = np.ma.ones(100) tr.data[30:40] = np.ma.masked tm = tr.times() self.assertTrue(np.alltrue(tr.data.mask == tm.mask))
def test_times(self): """ Test if the correct times array is returned for normal traces and traces with gaps. """ tr = Trace(data=np.ones(100)) tr.stats.sampling_rate = 20 start = UTCDateTime(2000, 1, 1, 0, 0, 0, 0) tr.stats.starttime = start tm = tr.times() self.assertAlmostEquals(tm[-1], tr.stats.endtime - tr.stats.starttime) tr.data = np.ma.ones(100) tr.data[30:40] = np.ma.masked tm = tr.times() self.assertTrue(np.alltrue(tr.data.mask == tm.mask))
shift, val = xcorr_max(cc2) print(shift) print(val) fig = plt.figure(1, figsize=(8, 12)) plt.subplot(3, 1, 1) plt.plot(t, sig1, label='Initial Signal') plt.plot(t, sig2, '.', alpha=0.4, label='2 ms Timing Error') plt.plot(t, sig1 - sig2, label='Difference') plt.xlabel('Time (s)') plt.ylabel('Amplitude (Normalized)') plt.xlim((min(t), max(t))) plt.text(-7, 1., '(a)') plt.legend(loc=2) plt.subplot(3, 1, 2) plt.plot(tr1.times(), tr1.data, label='Initial Signal at 1000 Hz') plt.plot(tr1.times(), tr2.data, '.', ms=2., alpha=0.2, label='2 ms Timing Error at 1000 Hz') plt.plot(tr1.times(), tr1.data - tr2.data, label='Difference at 1000 Hz') plt.xlabel('Time (s)') plt.xlim((min(t), max(t))) plt.text(-7, 1., '(b)') plt.legend(loc=2) plt.ylabel('Amplitude (Normalized)') plt.subplot(3, 1, 3) plt.plot((np.arange(len(cc2)) - 500) / 1000., cc2,