Merging Seismograms

The following example shows how to merge and plot three seismograms with overlaps, the longest one is taken to be the right one. Please also refer to the documentation of the merge() method.

import matplotlib.pyplot as plt
import matplotlib
import obspy

# Read in all files starting with dis.
st ="")
st +="")
st +="")

# sort
# start time in plot equals 0
dt = st[0].stats.starttime.timestamp

# Go through the stream object, determine time range in julian seconds
# and plot the data with a shared x axis
ax = plt.subplot(4, 1, 1)  # dummy for tying axis
for i in range(3):
    plt.subplot(4, 1, i + 1, sharex=ax)
    plt.plot(st[i].times(), st[i].data)

# Merge the data together and show plot in a similar way
plt.subplot(4, 1, 4, sharex=ax)
plt.plot(st[0].times(), st[0].data, 'r')

(Source code)