In Python numpy, there is an unwrap function that:
Unwrap radian phase p by changing absolute jumps greater than discont to their 2*pi complement along
phases = (phases + np.pi) % (2 * np.pi) - np.pi