Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unwrap angle to have continuous phase

Let's say I have an array of phases similar to this:

import numpy as np
import matplotlib.pyplot as plt
phase = np.linspace(0., 100., 1000) % np.pi
plt.plot(phase)
plt.show()

(with many discontinuities like this)

How to get an array of more "continuous" phases from it?

Of course, I already tried with np.unwrap:

plt.plot(np.unwrap(phase))

or

plt.plot(np.unwrap(phase),discont=0.1)

but it stays exactly similar:

What I expected was an unwrapping like this:

enter image description here

like image 691
Basj Avatar asked Sep 12 '18 11:09

Basj


1 Answers

If you want to keep your original phase with pi-periodicity, you should first double it, unwrap it, then divide it by two:

plt.plot(np.unwrap(2 * phase) / 2)

like image 72
PAb Avatar answered Sep 22 '22 11:09

PAb