Windowing a signal in frequency space

In summary, The speaker is trying to write a python script that transforms a noisy multi frequency signal from time space to frequency space, windows it with a Gaussian, and then transforms it back to time space. However, they are encountering a problem with the windowed signal having non-negligible imaginary parts. This is due to the window eliminating negative frequencies and transforming the signal to a complex signal. The speaker suggests correctly filtering the signal with the Gaussian window, but leaves it up to the listener to figure out how to do so.
  • #1
mdornfe1
3
0
I'm not sure if this is the right place to post this, but I'm trying to write a python script that takes a noisy multi frequency signal, transforms it to frequency space, windows it there with a gaussian, then transforms it back to time space. Here is what I wrote:

Code:
Fs=1000     #sampling frequency
fo=120      #center of gaussian   
sigma=0.01  #inverse width of gaussian
T=1./Fs
L=2**10     #number of samples
t=arange(0,L)*T #time vector
f=fftfreq(L,T)    #frequency vector
x=0.7*sin(2*pi*50*t) + sin(2*pi*120*t)+randn(t.size)/sqrt(t.size)   #signal
x_fft=fft(x)
W=exp(-square(2*pi*sigma*(f-fo)))   #gaussian window
y=ifft(W*x_fft)                      #windowed signal

The problem I'm running into is the windowed signal y has non negligible imaginary parts. They're about the same order as the real parts. Does anyone know why I might be getting this?
 
Engineering news on Phys.org
  • #2
MATLAB fft returns the signal spectrum both for positive and negative frequencies. Of course in your case the signal is real so its spectrum is symmetric under conjugation.
When you multiplied by a window, you eliminated the negative frequencies of the signal, thus transforming it to a complex signal (its spectrum is no longer symmetric).
For a L-point DFT (suppose L is even), the indices 1:L/2 in the vector correspond to the frequencies [0,pi), and the indices (L/2+1):L correspond to the frequencies [-pi,0) (in the same order).
I'll leave it up to you to figure out how to correctly filter the signal with the Gaussian window.
 

Related to Windowing a signal in frequency space

1. What is windowing a signal in frequency space?

Windowing a signal in frequency space is a technique used in signal processing to reduce spectral leakage and improve the frequency resolution of a signal. It involves multiplying the signal with a window function in the time domain before taking the Fourier transform to the frequency domain.

2. Why is windowing necessary in frequency space?

Windowing is necessary in frequency space because it helps to reduce the impact of spectral leakage, which can occur when a signal is not perfectly periodic. Spectral leakage can result in distorted frequency components and reduced frequency resolution, making it difficult to accurately analyze the signal.

3. What are some commonly used window functions in frequency space?

Some commonly used window functions in frequency space include the rectangular window, Hann window, Hamming window, and Blackman window. Each window function has different properties and is suitable for different types of signals and applications.

4. How do I choose the right window function for my signal in frequency space?

The choice of window function depends on the specific characteristics of the signal, such as its frequency content and time duration. Generally, a window function with a narrower mainlobe and lower sidelobes is preferred for signals with a relatively short duration, while a wider mainlobe and higher sidelobes may be more suitable for signals with a longer duration.

5. Are there any drawbacks to using windowing in frequency space?

One potential drawback of windowing in frequency space is that it can introduce spectral leakage artifacts at the edges of the window. This can be mitigated by using a window with a smooth transition or by overlapping multiple windows. Additionally, windowing can also reduce the signal-to-noise ratio, so it should be used with caution in applications where a high SNR is critical.

Similar threads

  • Electrical Engineering
Replies
4
Views
1K
  • Programming and Computer Science
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
393
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
397
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
861
Replies
1
Views
1K
  • Electrical Engineering
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
2K
  • Electrical Engineering
Replies
2
Views
2K
Back
Top