[obspy-users] stack streams or traces

Lion Krischer krischer at geophysik.uni-muenchen.de
Tue Aug 18 10:27:26 CEST 2015


Hi Alessandro,

I am not entirely sure what exactly you want to do but if you just want to sum up all the arrays:


In [1]: import obspy

In [2]: import numpy as np

In [3]: st = obspy.read()

In [4]: print(st)
3 Trace(s) in Stream:
BW.RJOB..EHZ | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:32.990000Z | 100.0 Hz, 3000 samples
BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:32.990000Z | 100.0 Hz, 3000 samples
BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z - 2009-08-24T00:20:32.990000Z | 100.0 Hz, 3000 samples

In [5]: np.sum([tr.data for tr in st], axis=0)
Out[5]:
array([  0.00000000e+00,  -1.44343102e-03,  -2.46549511e-02, ...,
         3.76718716e+00,   1.91000834e+00,   8.94015955e-01])


Cheers!

Lion


On 18 Aug 2015 at 10:26:02, Alessandro Vuan (avuan at inogs.it) wrote:
> Dear All
> having a list of streams with the same number of samples and same dt
> (see below) what is the best way in obspy to stack all together ?
> Thanks a lot
> Alessandro
>  
> MN.AQU..BHE | 2009-03-29T23:59:55.9936Z - 2009-03-31T00:00:55.9936Z | 20.0 Hz,  
> 1729201 samples
> MN.AQU..BHN | 2009-03-29T23:59:55.9936Z - 2009-03-31T00:00:55.9936Z | 20.0 Hz,  
> 1729201 samples
> MN.AQU..BHZ | 2009-03-29T23:59:55.9936Z - 2009-03-31T00:00:55.9936Z | 20.0 Hz,  
> 1729201 samples
> IV.CAMP..BHE | 2009-03-29T23:59:53.1450Z - 2009-03-31T00:00:53.1450Z | 20.0 Hz,  
> 1729201 samples
> IV.CAMP..BHN | 2009-03-29T23:59:53.1453Z - 2009-03-31T00:00:53.1453Z | 20.0 Hz,  
> 1729201 samples
> IV.CAMP..BHZ | 2009-03-29T23:59:53.1453Z - 2009-03-31T00:00:53.1453Z | 20.0 Hz,  
> 1729201 samples
> IV.CERT..BHE | 2009-03-29T23:59:43.3850Z - 2009-03-31T00:00:43.3850Z | 20.0 Hz,  
> 1729201 samples
> IV.CERT..BHN | 2009-03-29T23:59:43.4150Z - 2009-03-31T00:00:43.4150Z | 20.0 Hz,  
> 1729201 samples
> IV.CERT..BHZ | 2009-03-29T23:59:43.3850Z - 2009-03-31T00:00:43.3850Z | 20.0 Hz,  
> 1729201 samples
> IV.FIAM..BHE | 2009-03-29T23:59:40.7350Z - 2009-03-31T00:00:40.7350Z | 20.0 Hz,  
> 1729201 samples
> IV.FIAM..BHN | 2009-03-29T23:59:40.7450Z - 2009-03-31T00:00:40.7450Z | 20.0 Hz,  
> 1729201 samples
> IV.FIAM..BHZ | 2009-03-29T23:59:40.7550Z - 2009-03-31T00:00:40.7550Z | 20.0 Hz,  
> 1729201 samples
> IV.GUAR..BHE | 2009-03-29T23:59:41.5450Z - 2009-03-31T00:00:41.5450Z | 20.0 Hz,  
> 1729201 samples
> IV.GUAR..BHN | 2009-03-29T23:59:41.5452Z - 2009-03-31T00:00:41.5452Z | 20.0 Hz,  
> 1729201 samples
> IV.GUAR..BHZ | 2009-03-29T23:59:41.5452Z - 2009-03-31T00:00:41.5452Z | 20.0 Hz,  
> 1729201 samples
> IV.INTR..BHE | 2009-03-29T23:59:42.3250Z - 2009-03-31T00:00:42.3250Z | 20.0 Hz,  
> 1729201 samples
> IV.INTR..BHN | 2009-03-29T23:59:42.2850Z - 2009-03-31T00:00:42.2850Z | 20.0 Hz,  
> 1729201 samples
> IV.INTR..BHZ | 2009-03-29T23:59:42.3250Z - 2009-03-31T00:00:42.3250Z | 20.0 Hz,  
> 1729201 samples
> IV.MNS..BHE | 2009-03-29T23:59:52.2452Z - 2009-03-31T00:00:52.2452Z | 20.0 Hz,  
> 1729201 samples
> IV.MNS..BHN | 2009-03-29T23:59:52.2450Z - 2009-03-31T00:00:52.2450Z | 20.0 Hz,  
> 1729201 samples
> IV.MNS..BHZ | 2009-03-29T23:59:52.2450Z - 2009-03-31T00:00:52.2450Z | 20.0 Hz,  
> 1729201 samples
> IV.NRCA..BHE | 2009-03-29T23:59:51.4450Z - 2009-03-31T00:00:51.4450Z | 20.0 Hz,  
> 1729201 samples
> IV.NRCA..BHN | 2009-03-29T23:59:51.4450Z - 2009-03-31T00:00:51.4450Z | 20.0 Hz,  
> 1729201 samples
> IV.NRCA..BHZ | 2009-03-29T23:59:51.4453Z - 2009-03-31T00:00:51.4453Z | 20.0 Hz,  
> 1729201 samples
> IV.TERO..BHE | 2009-03-29T23:59:47.1850Z - 2009-03-31T00:00:47.1850Z | 20.0 Hz,  
> 1729201 samples
> IV.TERO..BHN | 2009-03-29T23:59:47.1850Z - 2009-03-31T00:00:47.1850Z | 20.0 Hz,  
> 1729201 samples
> IV.TERO..BHZ | 2009-03-29T23:59:47.2150Z - 2009-03-31T00:00:47.2150Z | 20.0 Hz,  
> 1729201 samples_______________________________________________
> obspy-users mailing list
> obspy-users at lists.swapbytes.de
> http://lists.swapbytes.de/mailman/listinfo/obspy-users



More information about the obspy-users mailing list