correlate_stream_template(stream, template, template_time=None, **kwargs)[source]

Calculate cross-correlation of traces in stream with traces in template.

Only matching seed ids are correlated, other traces are silently discarded. The template stream and data stream might have traces of different length and different start times. The data stream must not have gaps and will be sliced as necessary.

  • stream – Stream with data traces.

  • template – Stream with template traces (should be shorter than data).

  • template_time – UTCDateTime associated with template event (e.g. origin time, default is the start time of the template stream). The start times of the returned Stream will be shifted by the given template time minus the template start time.

  • kwargs – kwargs are passed to correlate_template() function.


Stream with cross-correlations.


Use correlation_detector() for detecting events based on their similarity. The returned stream of cross-correlations is suitable for use with coincidence_trigger(), though.


>>> from obspy import read, UTCDateTime
>>> data = read().filter('highpass', freq=5)
>>> pick = UTCDateTime('2009-08-24T00:20:07.73')
>>> template = data.slice(pick, pick + 10)
>>> ccs = correlate_stream_template(data, template)
>>> print(ccs)  
3 Trace(s) in Stream:
BW.RJOB..EHE | 2009-08-24T00:20:03.000000Z - ... | 100.0 Hz, 2000 samples
BW.RJOB..EHN | 2009-08-24T00:20:03.000000Z - ... | 100.0 Hz, 2000 samples
BW.RJOB..EHZ | ... - 2009-08-24T00:20:22.990000Z | 100.0 Hz, 2000 samples