Can't merge traces

Dear all!

I am trying to merge traces of a stream:

from obspy import read

st=read(“JAVS.*”)

st.merge(method=1, fill_value=0)

But I get the error:
Exception: Can’t merge traces with same ids but differing sampling rates!

when I call tr.stats.sampling_rate the problem is clear:

200.0
200.0
200.0
200.0
200.0
200.0
200.0
200.0
200.0
200.0
200.0
199.999984741
200.0
200.0
200.0
200.0
200.0
200.0
200.0
200.0
200.0

link to mseed
https://www.dropbox.com/s/alrgajlz00j7x5e/day130.tar.gz?dl=0



|

day130.tar.gz
www.dropbox.com
Shared with Dropbox
|

  • | - |

Is there something I can do about that faulty trace? Maybe some idea why data got corupted in this way?
Thank you very much,
Blaz

Can you read the file in, set the sample rate in the header (tr.stats.sampling_rate) and
write it back out ? Then try again to merge it.

Hi Blaz,

You can just give the sampling rate value of the rest of the traces to that faulty one. Something like:

for tr in st:

if tr.stats.sampling_rate != 200:

tr.stats.sampling_rate = 200

st.merge(method=1, fill_value=0)

This not-so-clean way of resampling your trace should work in this case as the sampling rate differs in a very small fraction.

I can’t really explaint why data got corrupted.

Yes, thank you very much, this solved the problem.
Cheers,
Blaz