Sunday 24 May 2015

fft - Basic question about chirp signal


Suppose I generate chirp signal with the following python code:


 t = np.linspace(0, 10, 512)
f0 = 2
f1 = 5
fs = 2*f1

w = chirp(t, f0=f0, f1=f1, t1=10, method='linear')
result = rfft(w)
phase = np.zeros(257)
mag = np.zeros(257)
for binnum in range(len(result)):
mag[binnum] = abs(result[binnum])
phase[binnum] = np.arctan2(result[binnum].imag, result[binnum].real)
plt.plot(fs * np.linspace(0, 0.5, 257),np.unwrap(phase))
plt.show()
plt.plot(fs * np.linspace(0, 0.5, 257),mag)

plt.show()

And the phase plot is:enter image description here


Magnitude plot is: enter image description here


But it is very different from what is described here.


Well, looking at the phase graph I can see parabola from 0 to 0.8. The magnitude is definitly not a constant.


What I'm doing wrong or misunderstood?


Thanks in advance.



Answer



I dont understand the definition of the chirp in the link you provided (perhaps chirp in frequency domain?), but maybe the following explanation could help.



In general, a linear chirp with a varying frequency given by $$f(t) = \alpha + \beta t$$ is defined by $$ x_1(t) = e^{2\pi j (\alpha t + 0.5\beta t^2)} $$


In that case, the phase of $x_1(t)$, the signal in time-domain, is indeed parabolic and the magnitude is constant and equals to 1.
Now, I am not familiar with python, but the chirp function in matlab produces a real signal rather than complex one. That is $$ x_2(t) = \sin(2\pi (\alpha t + 0.5\beta t^2)) $$ In that case, you will get different results. However, you can use the Hilbert transform (I guess this is in python) which, given $x_1(t)$ will produce $x_2(t)$ using fft.


No comments:

Post a Comment

readings - Appending 内 to a company name is read ない or うち?

For example, if I say マイクロソフト内のパートナーシップは強いです, is the 内 here read as うち or ない? Answer 「内」 in the form: 「Proper Noun + 内」 is always read 「ない...