I have been working on interpolation in python from quite some time. The input signal is a sinusoid signal sampled at 933KHz. I am upsampling the signal by a factor of 5 and later using an FIR lowpass filter with Kaiser window.
I am observing two issues here:
- The output of the FIR filter is attenuated by the interpolation factor. In my case, by a factor of 5. Multiplying the FIR co-efficients by interpolation factor is fixing it. But, I would like to find out why is it so.
- Also the cut-off frequency seems to be shifted by a factor of 5 too. The FIR filter had a cutoff frequency of around 25KHz. But the upsampled signal seems to be attenuated only after 125Khz. I verified if the FIR design is fine or not by filtering the original signal(without upsampling) and it seems to be fine. When the sinusoid's frequency is above 25Khz i see the attenuation and zero attenuation if the frequency is less than 25Khz.
I am bit of novice in this and any pointers for further study would also really help.
Fin = 25 * 10 ** 3 Fs = 933.0 * 10 ** 3 N = 100 L = 7 ### input signal n = np.linspace(0, N, num=N) x_input = np.sin(2 * np.pi * Fin * 1/Fs * n) ## upsampling x_input_upsampled = up_sample(x_input, N, L) ===> just a module written by me. does simple matrix multiplication to achieve upsampling. ##### Kaiser window # The Nyquist rate of the signal. nyq_rate = Fs / 2.0 # The desired width of the transition from pass to stop, # relative to the Nyquist rate. We'll design the filter # with a 5 Hz transition width. width = 5.0/nyq_rate # The desired attenuation in the stop band, in dB. ripple_db = 100.0 # Compute the order and Kaiser parameter for the FIR filter. from scipy.signal import kaiserord numtaps, beta = kaiserord(ripple_db, width) window = ('kaiser', beta) #### FIR filter cutoff = 25 * 10 ** 3 cutoff_normalized = cutoff/nyq_rate ## firwin h_windowed = signal.firwin(numtaps, cutoff_normalized, window=window) interpolated_y = np.convolve(x_input_upsampled, h_windowed)
Regards, Pradeep M C