from scipy.fftpack import fft from numpy import sin,pi,cos,arange,linspace, where, reshape, size, angle from pylab import plot,show, xlabel, title, figure, stem fs=1000 #sampling frequency in Hz f1=10 #frequency of first cosine f2=20 #frequency of second cosine f3=40 #frequency of third cosine N=2000; T=1.0*N/fs #analyzed time interval t=arange(0,T,1.0/fs) s=3*cos(2*pi*t*f1+5)+2*cos(2*pi*t*f2-2)+1*cos(2*pi*t*f3+3) figure(1) plot(t,s) xlabel('Time [s]') show() S=fft(s) figure(2) f=arange(0,fs,fs/(1.0*N)) #discrete frequencies for FFT magS=abs(S); stem(f,magS); show() angleS=angle(S) figure(3) plot(f,angleS); show()