# read into full SEED volume

**URL:** <https://discourse.obspy.org/t/read-into-full-seed-volume/170>\
**Category:** Users Mailing List Archive\
**Tags:** archive\
**Created:** [February 25, 2013, 3:55pm UTC](https://discourse.obspy.org/t/read-into-full-seed-volume/170 "2013-02-25T15:55:48Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan\_K\_Maccarthy](https://discourse.obspy.org/user_avatar/discourse.obspy.org/jonathan_k_maccarthy/32/266_2.png) [@Jonathan\_K\_Maccarthy](https://discourse.obspy.org/u/Jonathan_K_Maccarthy)\
**Post date:** [February 25, 2013, 3:55pm UTC](https://discourse.obspy.org/t/read-into-full-seed-volume/170/1 "2013-02-25T15:55:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)\
**Post date:** [February 25, 2013, 4:56pm UTC](https://discourse.obspy.org/t/read-into-full-seed-volume/170/2 "2013-02-25T16:56:30Z")

</div>

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:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BW (BayernNetz)  
Stations:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BW.ALTM (Beilngries, Bavaria, BW-Net)  
Channels:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BW.ALTM..EHE | 200.00 Hz | LE-3D | 2012-01-01 - 2012-01-01  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;BW.ALTM..EHN | 200.00 Hz | LE-3D | 2012-01-01 - 2012-01-01  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;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

---

<div class="post-metadata">

**Author:** ![Jonathan\_K\_Maccarthy](https://discourse.obspy.org/user_avatar/discourse.obspy.org/jonathan_k_maccarthy/32/266_2.png) [@Jonathan\_K\_Maccarthy](https://discourse.obspy.org/u/Jonathan_K_Maccarthy)\
**Post date:** [February 25, 2013, 9:41pm UTC](https://discourse.obspy.org/t/read-into-full-seed-volume/170/3 "2013-02-25T21:41:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![LionKrischer](https://discourse.obspy.org/user_avatar/discourse.obspy.org/lionkrischer/32/219_2.png) [@LionKrischer](https://discourse.obspy.org/u/LionKrischer)\
**Post date:** [February 26, 2013, 9:38am UTC](https://discourse.obspy.org/t/read-into-full-seed-volume/170/4 "2013-02-26T09:38:08Z")

</div>

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
