Windowing a signal in frequency space

Click For Summary
SUMMARY

This discussion focuses on the implementation of a Python script for processing a noisy multi-frequency signal using Fast Fourier Transform (FFT) and Gaussian windowing. The user encounters an issue where the inverse FFT (IFFT) results in a signal with significant imaginary components. The discussion highlights that applying a Gaussian window alters the symmetry of the signal's spectrum, leading to complex values. It emphasizes the importance of correctly filtering the signal to maintain its real-valued nature.

PREREQUISITES
  • Understanding of Fast Fourier Transform (FFT) and Inverse Fast Fourier Transform (IFFT)
  • Familiarity with Gaussian windowing techniques in signal processing
  • Knowledge of Python programming, specifically using libraries like NumPy for numerical computations
  • Basic concepts of signal frequency representation and symmetry in the frequency domain
NEXT STEPS
  • Research the implementation of Gaussian windows in signal processing using Python
  • Learn about the properties of the Discrete Fourier Transform (DFT) and its implications on signal symmetry
  • Explore techniques for filtering signals in the frequency domain to preserve real-valued outputs
  • Investigate the differences between FFT outputs in Python and MATLAB, particularly regarding complex signal handling
USEFUL FOR

This discussion is beneficial for signal processing engineers, data scientists working with time-series data, and Python developers interested in audio and signal analysis techniques.

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

Similar threads

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