I am trying to upsample a signal using sinc interpolation. I have written a way to do this in python.
@staticmethod
def sinc_interp(x, s, u):
"""
Interpolates x, sampled at "s" instants
Output y is sampled at "u" instants ("u" for "upsampled")
from Matlab:
http://phaseportrait.blogspot.com/2008/06/sinc-interpolation-in-matlab.html
"""
if len(x) != len(s):
raise Exception('x and s must be the same length')
# Find the sampling period of the undersampled signal
T = s[1] - s[0]
y = []
for i in range(len(u)):
y.append(np.sum(np.multiply(x, np.sinc((1 / T) * (u[i] - s)))))
y = np.reshape(y, len(u))
return y
Here is an image of part of the undersampled signal with dots showing where the samples are.
And here is an image of the upsampled waveform. Upsampled by a lot to get a smooth waveform to test with.
You can see that in some of the peaks or troughs, there is a dip in the middle up or down. The data is from a sensor and I used an oscilloscope, with a much higher sample rate than needed to view the sensor output as well to get the true signal, and those artifacts are not truly there. So there must be something wrong with my sinc interpolation or there is some errors in my sample waveforms data.
The original sample period is 400uS per sample.
Upsampled sample period is 10uS per sample.
The scope I used to confirm the true signal has a 2uS sample period with Sin X interpolation enabled.
Can anyone see any issues with my sinc_interp method or know why those artifacts are showing up?