obspy.core.trace.Trace.interpolate¶
- Trace.interpolate(*args, **kwargs)[source]¶
Interpolate the data using various interpolation techniques.
No filter, antialiasing, ... is applied so make sure the data is suitable for the operation to be performed.
Note
The Trace object has three different methods to change the sampling rate of its data: resample(), decimate(), and interpolate()
Make sure to choose the most appropriate one for the problem at hand.
Note
This operation is performed in place on the actual data arrays. The raw data will no longer be accessible afterwards. To keep your original data, use copy() to create a copy of your Trace object.
Parameters: - sampling_rate The new sampling rate in Hz.
- method The kind of interpolation to perform as a string ( "linear", "nearest", "zero", "slinear", "quadratic", "cubic", or "weighted_average_slopes" where "slinear", "quadratic" and "cubic" refer to a spline interpolation of first, second or third order) or as an integer specifying the order of the spline interpolator to use. Defaults to "weighted_average_slopes" which is the interpolation technique used by SAC. Refer to weighted_average_slopes() for more details.
- starttime (UTCDateTime or int) The start time (or timestamp) for the new interpolated stream. Will be set to current start time of the trace if not given.
- npts (int) The new number of samples. Will be set to the best fitting number to retain the current end time of the trace if not given.
Usage Examples
>>> from obspy import read >>> tr = read()[0] >>> print(tr) BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples >>> tr.interpolate(sampling_rate=111.1) <obspy.core.trace.Trace object at 0x...> >>> print(tr) BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 111.1 Hz, 3332 samples
Setting starttime and/or npts will interpolate to sampling points with the given start time and/or number of samples. Extrapolation will not be performed.
>>> tr = read()[0] >>> print(tr) BW.RJOB..EHZ | 2009-08-24T00:20:03... - ... | 100.0 Hz, 3000 samples >>> tr.interpolate(sampling_rate=111.1, ... starttime=tr.stats.starttime + 10) <obspy.core.trace.Trace object at 0x...> >>> print(tr) BW.RJOB..EHZ | 2009-08-24T00:20:13... - ... | 111.1 Hz, 2221 samples