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 scipy.io import savemat
import obspy
st = obspy.read("https://examples.obspy.org/BW.BGLD..EH.D.2010.037")
for i, tr in enumerate(st):
mdict = {k: str(v) for k, v in tr.stats.items()}
mdict['data'] = tr.data
savemat(f"data-{i}.mat", mdict)