I'm trying to pad $N=16$ zeros to the DFT of a $16$ point sinewave, but something is wrong either with my code or with my method. The method is this : I create a new $32$ point DFT where $F'(0),...,F'(N/2 - 1)$ are the elements of the original DFT, $F(0),...,F(N/2 - 1)$. I start to add $16$ zeros starting from $F'(N/2)$. The remaining values of $F'(k)$ need to have the proper conjugate symmetry, so that $F'(k) = (F'(N' - k))^*$ holds. I am using Python and numpy.
# parameters
f_s = 1
f_1 = 0.25
f_2 = 0.4
t_s = 1/f_s
N = 16
# define sinewave
def sinewave(x):
return np.sin(2 * pi * f_1 * x * t_s) + 1.5*np.sin(2 * pi * f_2 * x * t_s)
y = np.zeros(N)
for i in range(0, N):
y[i] = sinewave(i)
# zero-pad in frequency domain by 16 points
zero_pad = 16
zero_padded_transform = np.zeros(N + zero_pad, dtype = complex)
zero_padded_transform[0 : 8] = np.fft.fft(y)[0 : 8] # 8 since N/2 = 16/2 = 8
zero_padded_transform[8 + zero_pad + 1:] = np.fft.fft(y)[9:]
The symmetry is correct as the inverse transform has zero imaginary part, but the number of zeros is not correct. As such, this method does not seem to interpolate the sinewave correctly in the time domain.