16. Export Seismograms to MATLABΒΆ

The following example shows how to read in a waveform file with Python and save each Trace in the resulting Stream object to one MATLAB .MAT file. The data can the be loaded from within MATLAB with the load function.

from obspy.core import read
from scipy.io import savemat

st = read("http://examples.obspy.org/BW.BGLD..EH.D.2010.037")
for i, tr in enumerate(st):
    mdict = dict([[j, str(k)] for j, k in tr.stats.iteritems()])
    mdict['data'] = tr.data
    savemat("data-%d.mat" % i, mdict)

This Page