Windowing a signal in frequency space

Click For Summary
SUMMARY

This discussion focuses on the process of windowing a noisy multi-frequency signal in frequency space using Python. The user implements a Gaussian window with specific parameters: a sampling frequency of 1000 Hz, a center frequency of 120 Hz, and a Gaussian width (sigma) of 0.01. The issue arises when the inverse Fourier transform results in a signal with significant imaginary components, which the user resolves by recognizing that the multiplication of the transformed signal by the Gaussian window cancels out negative frequency components, leading to unexpected complex values in the output.

PREREQUISITES
  • Understanding of Fourier Transform and Inverse Fourier Transform
  • Familiarity with Python programming and libraries such as NumPy
  • Knowledge of Gaussian functions and their properties
  • Basic signal processing concepts, particularly in frequency domain analysis
NEXT STEPS
  • Explore the implementation of window functions in signal processing using SciPy
  • Learn about the effects of negative frequency components in Fourier Transforms
  • Investigate techniques for handling complex outputs in inverse Fourier transforms
  • Study the application of Gaussian windows in filtering noisy signals
USEFUL FOR

Signal processing engineers, data scientists, and Python developers working with frequency analysis and noise reduction in signals.

mdornfe1
Messages
3
Reaction score
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
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?
 
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.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
26
Views
6K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K