Breaking my brain all morning with this reading previous questions and googling ...
I have made an RRC filter from the equation on wikipedia. It works fine and I compared it to commpy library in python.
But what I dont understand is the frequency amplitudes.
- Should the RRC filter have normalised gain, i.e. 0 dB by dividing the impulse response by sum(impulse response)?
- Or should I be dividing the FFT result by fftsize?
- Or should I infact be doing neither of these two?
I browse the internet and many images have lots of different gains, none of which I can recreate ... but I can recreate the impulse and general frequency shape. The frequency response is just not shifted vertically correct (in dB scale) to show same gain as other images. What am I missing :(
#Define all parameters needed for RRC alpha = 0.35 Fs = Fs span = 10 sps = 10 num_taps = span*sps Rs = Fs / sps #taps must be odd for impulse to be symmetrical on time zero if not num_taps % 2: num_taps += 1 #time vector t = np.arange(-((num_taps-1)/2) , (((num_taps-1)/2)+1) , 1) * (1/Fs) #Root Raised Cosine and deal with special cases h = np.zeros(len(t)) for element in enumerate(t): i,x = element #i holds array index, x holds value of t if x == 0: h[i] = (1 - alpha + (4 * alpha / np.pi)) elif (alpha != 0 and x == (1 / Rs) / (4 * alpha)) or (alpha != 0 and x == -(1 / Rs) / (4 * alpha)) : h[i] = alpha / np.sqrt(2) * ( ((1 + 2 / np.pi) * np.sin(np.pi / (4 * alpha))) + ((1 - 2 / np.pi) * np.cos(np.pi / (4 * alpha)))) else: #not special cases h[i] = (np.sin(np.pi * x * Rs * (1 - alpha) ) + \ 4 * alpha * x * Rs * np.cos(np.pi * x * Rs * (1 + alpha))) / \ (np.pi * x * Rs * (1 - (4 * alpha * x *Rs) ** 2 )) h = h # / np.sum(h) #Should I divide to normalise gain? #Fourier Transform fftsize = 4096 f = np.linspace(-Fs / 2, Fs / 2, fftsize) H = np.fft.fft(h,fftsize) #Should I divide by fftsize here?! H = 10*np.log10( np.abs(H)**2) H = np.fft.fftshift(H) #Make the plots fig = plt.figure() ax = fig.add_subplot(211) ax.title.set_text('Raised Cosine Impulse Response') ax.plot(t,h) ax.grid(True) ax = fig.add_subplot(212) ax.title.set_text('Raised Cosine Frequency Response') ax.plot(f,H) ax.grid(True)