I computed spectrum analysis of sine wave (without windowing and zero-padding) and I got plots as follows:

dft analysis of sine wave

As far as I know they are correct. When I learnt about DSP, I got the huge problem with understanding what is the phase spectrum. Recently I realised that "phases" are translations along time axis of each sinusoidal component. So I don't see any point to get them out of range $\langle -\pi, \pi \rangle$. I computed my spectrums with python and to get the phase spectrum I used unwrap function from numpy. As I understand this documentation correctly, it is impossible to get the result larger than $\pi$ or less than $-\pi$ unless I set the discount parameter. It does make sense for me.

Could you explain me:

  • whether I understand the phase spectrum correctly?

  • why the values of phase spectrum are out of range $\langle -\pi, \pi \rangle$?

  • how does the function unwrap work?


Yes you can think of phases as describing translations.

If you (kind of passively) wrap the phase to ⟨−π,π⟩ you may be introducing discontinuities that are not truly there considering that −π and π are equivalent. Such artificial discontinuities will hinder calculation of things like group delay.

Unwrapping the phase properly is not trivial. One way to do it properly is to factor the system into such small component systems (connected in series) that you can track the phase frequency response of each without any wrapping ambiguities. The phase frequency response of the composite system will be the sum of those of the component systems. Calculated this way, the phase naturally get values outside of ⟨−π,π⟩. Computationally, the factorization can be done by finding the z-plane zeros of the system. My guess is that numpy.unwrap does nothing of the sort but simply looks for big jumps of the wrapped phase as function of frequency and tries to make those jumps shorter by adding or subtracting 2π. That will easily fail do do a proper job if the frequency response has two zeros at the same frequency, as that gives a jump of 2π that phase unwrapping ought to preserve.

| improve this answer | |
  • $\begingroup$ @ramdas1989 no I don't know any $\endgroup$ – Olli Niemitalo May 6 '16 at 12:06

The diagram is somewhat misleading. What you're actually displaying is the phase of the fourier components, not only the phase of your signal. You could regard every component that is not part of the amplitude peak as an artifact. The picture might become clearer when you add a little noise that swamps low amplitude signals, and/or if you add a second component.

"Unwrap" just adds even multiples of $\pi$ so that any border discontinuities (at $-\pi$ and $\pi$) in a phase signal are removed, which may be a sensible thing to do or not, depending on the situation.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.