Created
February 28, 2017 13:51
-
-
Save ndvbd/dd2351d0869894c43ee20541c29aaae1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sinc_interp(x, s, u): | |
""" | |
Interpolates x, sampled at "s" instants | |
Output y is sampled at "u" instants ("u" for "upsampled") | |
""" | |
if len(x) != len(s): | |
raise Exception, 'x and s must be the same length' | |
# Find the period | |
T = s[1] - s[0] | |
transposed = np.transpose(np.tile(np.arange(len(s)), (len(u),1))) * T | |
sincM = np.tile(u, (len(s), 1)) - transposed | |
y = np.dot(x, np.sinc(sincM / T)) | |
return y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
That's a quick python implementation for the Whittaker–Shannon interpolation