signal processing - fft amplitude of chirp in python -


i have seen similar questions beeing asked can't seem right. hope guess can if misunderstanding conceptually or code-wise. making chirp 1khz 10khz of duration 1s 48khz fs. want plot frequency spetrum/fft of chirp right amplitude. code is:

from scipy.fftpack import fft  n = 48000 fs = 48000.0 sine_list_x = [] k = (10000.0 - 1000.0)/(48000.0) x in range(n):     sine_list_x.append(sin(2*pi*(1000.0*(x/48000.0)+(k/2.0)*(x**2)/(48000.0))))  xf = np.linspace(0.0, fs/2.0, n/2) yf = fft(sine_list_x) yf = yf / sqrt(n) #yf = yf / n  fig3 = pl.figure() ax3 = fig3.add_subplot(111) ax3.plot(xf, abs(yf[0:n/2])) 

the plot above code shown here enter image description here

i know fft function not normalize kind of conflicting info similar questions normalize sqrt(n), n , other things..

what expected see in plot if had normalized correctly amplitude of 1 in since amplitude of chirp. wrong assumption? or wrong in normalization?

in time-domain , sweep varying frequency, sum of squared samples of integer number of cycles (or of sufficiently large number of cycles) can approximated by

     0.5*n*at*at 

where n number of samples, , at sweep's amplitude. given parameters (n=48000, at=1), 24000 comes pretty close exact value of ~23999.9986331 provided in @tom10's answer.

on other hand in frequency-domain (looking @ graph of frequency spectrum), complete spectrum can approximated 2 boxes (as expected linear frequency sweep):

  • one 1000 10000 show on graph
  • and 38000 47000 arises out of hermitian symmetry of frequency spectrum of real signals.

the sum of squared (frequency-domain) samples in case approximated by

     2*((10000-1000)+(47000-38000))*af*af == 18000*af*af  

now parseval's theorem disrete fourier transform states that:

\sum_{n=0}^{n-1} \left|x[n]\right|^2 = \frac{1}{n} \sum_{n=0}^{n-1} \left|x[k]\right|^2

which after accounting 1/sqrt(n) normalization , substituting approximate values found above yields:

     24000 = 18000*af*af 

thus af should approximately equal sqrt(24000/18000) = 1.1547..., consistent graph plotted.


Comments

Popular posts from this blog

javascript - AngularJS custom datepicker directive -

javascript - jQuery date picker - Disable dates after the selection from the first date picker -