Windowing a signal in frequency space

In summary, the conversation discusses a python script that transforms a noisy multi frequency signal to frequency space, windows it with a gaussian, and transforms it back to time space. The problem being encountered is that the windowed signal has non-negligible imaginary parts, which is due to the cancellation of negative frequency components. The solution is to consider the magnitude at each frequency rather than the phase information.
  • #1
mdornfe1
3
0
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=Fs*linspace(0,1,L)    #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?
 
Technology news on Phys.org
  • #2
Any chance you are getting a complex vector when you were expecting a,b as in a*cos(n*t)+b*sin(n*t)?

Or are you perhaps thinking you want the magnitude at each frequency and not the phase information?
 
  • #3
I just realized what was happening. When I multiplied the transformed signal by the gaussian, I canceled out the negative frequency components. So of course when I transformed back the signal would be complex. I was expecting it to be a real sinusoid not a complex one.
 

1. What is windowing a signal in frequency space?

Windowing a signal in frequency space is a technique used in digital signal processing to improve the accuracy of frequency analysis. It involves multiplying the time-domain signal by a mathematical function, or "window", in order to reduce the effects of spectral leakage and improve the resolution of frequency components.

2. Why is windowing necessary in frequency space?

Windowing is necessary because the Fourier transform assumes that the input signal is periodic, which is rarely true in real-world signals. This can cause spectral leakage, where the energy of a signal spreads across multiple frequency bins, resulting in inaccurate frequency analysis. Windowing helps to mitigate this issue by reducing the amplitude of the signal at the beginning and end, minimizing spectral leakage and improving frequency resolution.

3. What are some common types of windows used in frequency space?

Some common types of windows used in frequency space include the rectangular window, Hamming window, Hanning window, and Blackman window. Each of these windows has its own unique characteristics and is suited for different types of signals and analysis purposes.

4. How do you choose the right window for a signal in frequency space?

The choice of window depends on the specific characteristics of the signal and the desired frequency analysis. In general, the rectangular window is suitable for signals with sharp transitions, while the Hamming and Hanning windows are better for signals with smooth transitions. The Blackman window is often used for signals with a wide dynamic range. It is important to consider the trade-off between spectral leakage and frequency resolution when choosing a window.

5. What are some potential drawbacks of windowing a signal in frequency space?

One potential drawback of windowing is that it can introduce artifacts into the frequency analysis, especially if the wrong window is chosen for the signal. Additionally, windowing can also reduce the overall amplitude of a signal, which may affect the accuracy of amplitude measurements. It is important to carefully consider the trade-offs and choose an appropriate window for the specific signal and analysis goals.

Similar threads

  • Electrical Engineering
Replies
1
Views
1K
  • Programming and Computer Science
Replies
5
Views
2K
  • Programming and Computer Science
Replies
26
Views
4K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
1K
  • Electrical Engineering
Replies
4
Views
662
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
687
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • General Math
Replies
1
Views
703
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
10
Views
2K
Back
Top