Skip to content

Instantly share code, notes, and snippets.

@megies
Created January 16, 2014 17:02
Show Gist options
  • Save megies/8458815 to your computer and use it in GitHub Desktop.
Save megies/8458815 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from obspy.core import Stream, Trace, read, UTCDateTime
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rc('lines', linewidth=2)
alpha=0.5
# <codecell>
np.random.seed(123)
trace1 = Trace(data=np.random.random(1000))
trace1.stats.starttime = UTCDateTime(2014,1,1)
trace1.stats.sampling_rate=100
print trace1
# <codecell>
trace2 = Trace(data=np.random.random(1000))
trace2.stats.starttime = UTCDateTime(2014,1,1,0,0,10,4000)
trace2.stats.sampling_rate=100
print trace2
# <codecell>
trace3 = Trace(data=np.random.random(1000))
trace3.stats.starttime = UTCDateTime(2014,1,1,0,0,20,8000)
trace3.stats.sampling_rate=100
print trace3
# <codecell>
st = Stream(traces=[trace1, trace2, trace3])
for tr in st:
plt.plot(tr.times() + tr.stats.starttime.timestamp, tr.data, alpha=alpha)
# <codecell>
print st
# <codecell>
st.merge()
for tr in st:
plt.plot(tr.times() + tr.stats.starttime.timestamp, tr.data, "k-", alpha=alpha)
st = st.split()
for tr in st:
plt.plot(tr.times() + tr.stats.starttime.timestamp, tr.data, "c-", alpha=alpha)
# <codecell>
print st
# <codecell>
# <codecell>
plt.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment