obspy.core.trace.Trace.resample
- Trace.resample(sampling_rate, window='hann', no_filter=True, strict_length=False)[source]
Resample trace data using Fourier method. Spectra are linearly interpolated if required.
- Parameters:
sampling_rate (float) – The sampling rate of the resampled signal.
window (
numpy.ndarray
, callable, str, float, or tuple, optional) – Specifies the window applied to the signal in the Fourier domain. Defaults to'hann'
window. Seescipy.signal.resample()
for details.no_filter (bool, optional) – Deactivates automatic filtering if set to
True
. Defaults toTrue
.strict_length (bool, optional) – Leave traces unchanged for which end time of trace would change. Defaults to
False
.
Note
The
Trace
object has three different methods to change the sampling rate of its data:resample()
,decimate()
, andinterpolate()
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 is not accessible anymore afterwards. To keep your original data, use
copy()
to create a copy of your trace object. This also makes an entry with information on the applied processing instats.processing
of this trace.Uses
scipy.signal.resample()
. Because a Fourier method is used, the signal is assumed to be periodic.Example
>>> tr = Trace(data=np.array([0.5, 0, 0.5, 1, 0.5, 0, 0.5, 1])) >>> len(tr) 8 >>> tr.stats.sampling_rate 1.0 >>> tr.resample(4.0) <...Trace object at 0x...> >>> len(tr) 32 >>> tr.stats.sampling_rate 4.0 >>> tr.data array([ 0.5 , 0.40432914, 0.3232233 , 0.26903012, 0.25 ...