I would like to resample (downsample) a signal using python in order to get an even spacing and fill gaps.
About the signal:
- It consists of a vector for y (amplitude) and x (timestamps)
- Very slow; $F_s$ is probably >100 times higher than needed (for the desired content; steps and noise are present)
- The samples aren't exactly equally spaced
- The signal has gaps with missing samples
- The signal is not periodic (FFT resampling should be fine though, I can trim off beginning and end)
- It doesn't really matter how the gaps are filled, a linear interpolation would do
In matlab could likely just use y = resample(x,tx,fs)
, however, scipy.signal.resample()
can take a vector for x but still doesn't work for signals with non-uniform spacing.
It is probably a bad idea to use scipy.interpolate.interp1d()
for filling gaps and downsampling in one step because of aliasing. Filtering before interpolating is likely not a good idea either, since the discrete filters wouldn't work with a non-uniform spacing of the samples.
Should I first interpolate()
to the approximate sample frequency and then downsample using resample()
?