def test_recSTALTAC(self): """ Test case for ctypes version of recursive_STALTA """ nsta, nlta = 5, 10 c1 = recursive_STALTA(self.data, nsta, nlta) self.assertAlmostEqual(c1[99], 0.80810165) self.assertAlmostEqual(c1[100], 0.75939449) self.assertAlmostEqual(c1[101], 0.91763978) self.assertAlmostEqual(c1[102], 0.97465004)
import obspy from obspy.signal.trigger import plot_trigger, recursive_STALTA trace = obspy.read("https://examples.obspy.org/ev0_6.a01.gse2")[0] df = trace.stats.sampling_rate cft = recursive_STALTA(trace.data, int(5 * df), int(10 * df)) plot_trigger(trace, cft, 1.2, 0.5)
import obspy from obspy.clients.arclink import Client from obspy.signal.trigger import recursive_STALTA, trigger_onset # Retrieve waveforms via ArcLink client = Client(host="erde.geophysik.uni-muenchen.de", port=18001, user="******") t = obspy.UTCDateTime("2009-08-24 00:19:45") st = client.get_waveforms('BW', 'RTSH', '', 'EHZ', t, t + 50) # For convenience tr = st[0] # only one trace in mseed volume df = tr.stats.sampling_rate # Characteristic function and trigger onsets cft = recursive_STALTA(tr.data, int(2.5 * df), int(10. * df)) on_of = trigger_onset(cft, 3.5, 0.5) # Plotting the results ax = plt.subplot(211) plt.plot(tr.data, 'k') ymin, ymax = ax.get_ylim() plt.vlines(on_of[:, 0], ymin, ymax, color='r', linewidth=2) plt.vlines(on_of[:, 1], ymin, ymax, color='b', linewidth=2) plt.subplot(212, sharex=ax) plt.plot(cft, 'k') plt.hlines([3.5, 0.5], 0, len(cft), color=['r', 'b'], linestyle='--') plt.axis('tight') plt.show()
import obspy from obspy.signal.trigger import plot_trigger, recursive_STALTA trace = obspy.read("http://examples.obspy.org/ev0_6.a01.gse2")[0] df = trace.stats.sampling_rate cft = recursive_STALTA(trace.data, int(5 * df), int(10 * df)) plot_trigger(trace, cft, 1.2, 0.5)