[SciPy-User] frequency components of a signal buried in a noisy time domain signal
Fri Feb 26 14:56:29 CST 2010
Yes, FFT can be used to visualize the frequency content of a signal buried
in the noise, especially if it is is narrowband,
even though more advanced spectral analysis is required for advanced
I cannot help you with non-uniformly spaced samples (some sort of
interpolation comes to mind), but next power of 2 should be trivial. Without
checking for the argument type, you can implement the function like this:
m_f = np.log2(n)
m_i = np.ceil(m_f)
Hope it helps,
On 26 February 2010 14:05, Nils Wagner <firstname.lastname@example.org> wrote:
> Hi all,
> A common use of Fourier transforms is to find the
> frequency components of a signal buried in a noisy time
> domain signal.
> I found a Matlab template at
> Matlab has a function
> Is there a similar build-in function in numpy/scipy ?
> I tried to convert the m-file into a pythonic form.
> What is needed to obtain a similar figure of the
> single-sided amplitude spectrum using
> numpy/scipy/matplotlib ?
> from numpy import sin, linspace, pi
> from numpy.random import randn
> from pylab import plot, show, title, xlabel, ylabel
> from scipy.fft import fft
> Fs = 1000. # Sampling frequency
> T = 1./Fs # Sample time
> L = 1000 # length of signal
> t = arange(0,L)*T
> x = 0.7*sin(2*pi*50*t)+sin(2*pi*120*t)
> y = x + 2*randn(len(t))
> title('Signal corrupted with zero-mean random noise')
> xlabel('Time (milliseconds)')
> #NFFT = 2^nextpow2(L); # Next power of 2 from length of y
> Y = fft(y,NFFT)/L
> f = Fs/2*linspace(0,1,NFFT/2+1)
> title('Single-sided amplitude spectrum of y(t)')
> xlabel('Frequency (Hz)')
> What can be done in case of nonequispaced data ?
> Thanks in advance
> SciPy-User mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the SciPy-User