obspy.core.stream.Stream.merge

Stream.merge(method=0, fill_value=None, interpolation_samples=0, **kwargs)[source]

Merge ObsPy Trace objects with same IDs.

Parameters:
  • method (int, optional) Methodology to handle overlaps/gaps of traces. Defaults to 0. See obspy.core.trace.Trace.__add__() for details on methods 0 and 1, see obspy.core.stream.Stream._cleanup() for details on method -1. Any merge operation performs a cleanup merge as a first step (method -1).
  • fill_value (int, float, str or None, optional) Fill value for gaps. Defaults to None. Traces will be converted to NumPy masked arrays if no value is given and gaps are present. The value 'latest' will use the latest value before the gap. If value 'interpolate' is provided, missing values are linearly interpolated (not changing the data type e.g. of integer valued traces). Not used for method=-1.
  • interpolation_samples (int, optional) Used only for method=1. It specifies the number of samples which are used to interpolate between overlapping traces. Default to 0. If set to -1 all overlapping samples are interpolated.

Importing waveform data containing gaps or overlaps results into a Stream object with multiple traces having the same identifier. This method tries to merge such traces inplace, thus returning nothing. Merged trace data will be converted into a NumPy MaskedArray type if any gaps are present. This behavior may be prevented by setting the fill_value parameter. The method argument controls the handling of overlapping data values.