read into full SEED volume

Hello,

Has anyone had any success reading traces from a full SEED volume using obspy.core.read -> readMSEED ? I know ObsPy isn't set up for doing this, but I can actually read the first station's data like this:

from obspy.core import read
st = read('myfile.seed', format='MSEED')

This produces the correct BHN, BHE, BHZ traces for the first station. I didn't expect that this would work. I've tried to read the next set of traces using a byte offset like this:

f = open('myfile.seed', 'rb')
f.seek(mybyteoffset)
st = read(f, format='MSEED')

This, however, produces the same three traces as the previous example. No byte offset yet has produced anything different.

Does anyone know if it's possible to fool obspy.core.read into reading into a full SEED volume using byte offset and number of samples? I suspect this may require a more sophisticated interface with libmseed, but I thought I'd ask anyway...

Thanks for your help,
Jon

Hi Jon,

ObsPy should be fully capable of reading full SEED volumes as far as I am concerned.

Get a full SEED file:

from obspy import UTCDateTime
from obspy.arclink.client import Client
client = Client(user='test@obspy.org')
t = UTCDateTime(2012, 1, 1, 12, 0)
client.saveWaveform('BW.ALTM..EH.seed', 'BW', 'ALTM', '', '*',

… t, t + 20, format='FSEED')

Reading the waveform streams:

from obspy import read
st = read("BW.ALTM..EH.seed")
print st

3 Trace(s) in Stream:
BW.ALTM..EHZ | 2012-01-01T11:59:58.700000Z - 2012-01-01T12:00:21.355000Z | 200.0 Hz, 4532 samples
BW.ALTM..EHN | 2012-01-01T11:59:58.700000Z - 2012-01-01T12:00:21.355000Z | 200.0 Hz, 4532 samples
BW.ALTM..EHE | 2012-01-01T11:59:58.700000Z - 2012-01-01T12:00:21.355000Z | 200.0 Hz, 4532 samples

Reading the waveform streams with a file offset. This is slightly awkward because passing a file like object to the read function will always seek to position 0. We might need to change this so it enables offset based file reading. Although MiniSEED is probably the only file format where this is useful.

from StringIO import StringIO
from obspy import read
with open("./BW.ALTM..EH.seed", "rb") as open_file:

... open_file.seek(24576)
... f = StringIO(open_file.read())

st = read(f)
print st

2 Trace(s) in Stream:
BW.ALTM..EHN | 2012-01-01T11:59:58.700000Z - 2012-01-01T12:00:21.355000Z | 200.0 Hz, 4532 samples
BW.ALTM..EHE | 2012-01-01T11:59:58.700000Z - 2012-01-01T12:00:21.355000Z | 200.0 Hz, 4532 samples

Alternatively if you are only interested in reading a subset of the data in any full or mini seed volume you can also use the sourcename kwarg and it will match the wildcards. It will only fully read records satisfying the selection. Should be quite fast. The following example will only read eastern components:

from obspy import read
st = read("BW.ALTM..EH.seed", sourcename = "*E")
print st

1 Trace(s) in Stream:
BW.ALTM..EHE | 2012-01-01T11:59:58.700000Z - 2012-01-01T12:00:21.355000Z | 200.0 Hz, 4532 samples

Reading the metadata:

from obspy.xseed import Parser
p = Parser("BW.ALTM..EH.seed")
print p

Networks:
        BW (BayernNetz)
Stations:
        BW.ALTM (Beilngries, Bavaria, BW-Net)
Channels:
        BW.ALTM..EHE | 200.00 Hz | LE-3D | 2012-01-01 - 2012-01-01
        BW.ALTM..EHN | 200.00 Hz | LE-3D | 2012-01-01 - 2012-01-01
        BW.ALTM..EHZ | 200.00 Hz | LE-3D | 2012-01-01 - 2012-01-01

From your question I gather that some channels are not read. If that is the case can you send us an example file?

Hope it helps!

Lion

Hi Lion,

Thanks for the very helpful response. You are correct that many channels are not being read. I tried a simple "st = read('myfile.seed')" and "st = read('myfile.seed', sourcename='*BHZ'), but I'm still only able read or select from the first 3 traces. StringIO did work, however. Interestingly, I tried a simple "read" on another SEED volume and was able to read all traces. Perhaps I'm trying to read a badly-behaved SEED volume.

Since you've kindly offered a workaround, I will happily use it, though a file offset would be prettier. If you think I should file an enhancement, I'll do that.

Thank you again,
Jon

Hi Jon,

glad I could help. Could you, if possible for security/privacy/other reasons, send us the SEED file ObsPy cannot read?

Filing an enhancement proposal is always a good idea.

Cheers!

Lion