Reading multiple traces from directory of miniseed files

How can I create a stream object with all available channels for a given time interval, when the data is stored in a “standard” directory tree of 24-hour miniseed files. The files are organised like this:

mseed/NE/STA/yyyy.ddd.NE.STA.LO.CHA.mseed

I need to be able to deal with the case when the time interval spans two files.

(I don’t know enough Python yet to do this non-messily.)

You can use the SDS Client, changing the FMTSTR

from obspy.clients.filesystem.sds import Client

client = Client('/path/to/base_dir')
client.FMTSTR = 'mseed/{network}/{station}/{year}.{doy:03d}.{network}.{station}.{location}.{channel}.mseed'
client.get_waveforms(...)

You can tweak fileborder_seconds and fileborder_samples if you have trouble getting data across the day boundaries, but that should only be necessary if the data is stored on the wrong day more than usual.

1 Like

Many thanks. I’m having to learn Python at the same time as trying to use obspy.