Does anybody have a good example of cross correlation using obspy. I am trying to cross-correlate a window around my pwave from one earthquake against all the others in the cluster. To test this I am correlating my trimmed and cosine tapered pwave window with the original waveform. When I do this I am getting a correlation value lower than I would expect. My best correlation is .77 and most are about .4. I am unclear from the documentation what the proper selection of the shift_len should be. Any examples or advice would be much appreciated.

Hi Austin,

selection of shift_len depends mainly on how good your picked times are,

I guess. If your picks are good (manual picks?) you can probably go with

a relatively small value there (half a wavelength, one wavelength?).

With increasing shift_len the window actually contributing to the

correlation values gets smaller and if your peak is not exactly at the

middle of the data, it might happen that the phase peak is not in your

window of support any more. On the other hand however, if the maximum

shift you allow is too small it can happen that your two peaks never get

aligned actually.

So yes, it can be a tricky task to find the right settings for your data.

Also try the option "full_xcorr=True" and have a look at the cross

correlation function (for a couple of different data sets, too). Usually

you can tell pretty good there if your main correlation peak is captured

by the cross correlation.

Hope that helps,

Tobias

Austin Holland wrote:

I found that both the numpy and scipy cross correlation routines are much

more straightforward and worked quite well. The biggest disadvantage to

them is that they do not currently have the ability to provide normalized

correlation coefficients, although from the bugtracking it appears this

functionality may be coming in later versions.

Well, yes. That is the advantage of the routine we have, that you are

always correlating data with data and of always the same length, too. No

padded zeros, no frequency domain wrap-around effects, no normalization

issues or blown up correlation coefficients with less support (in terms

of number of samples), i.e. the same statistics everywhere in the cross

correlation.

Anyway, if the scipy routines work for you that is fine, too, of course.

Tobias

Holland, Austin A. wrote: