[SciPy-user] Phase Unwrapping Algorithm

Anne Archibald peridot.faceted@gmail....
Thu Mar 8 16:28:57 CST 2007

On 08/03/07, Jared Peacock <jpeacock@mesoscopic.mines.edu> wrote:
> Does anybody know of a good phase unwrapping algorithm in Python?

If by phase unwrapping you mean taking values that have been reduced
modulo 1 (say) and trying to reconstitute the originals, the problem
is in principle underdetermined - we really can't distinguish big
jumps in the data from the results of phase wrapping. Still, for
reasonable data it's often enough to consider every jump bigger than
0.5 a phase wrap:

def unwrap(a):
     return a-numpy.concatenate(([0],numpy.cumsum(numpy.round(a[1:]-a[:-1]))))

That is, a[1:]-a[:-1] extracts the first difference, round converts
anything less than -0.5 to -1 and anything more than 0,5 to 1, we
concatenate a zero on the front, and then we subtract (because a jump
down of 0.6 is rounded to -1 and we want it to be a jump up) the
result from our original data.

I suppose this could be made more efficient by rewriting more of the
operations to be in-place.


More information about the SciPy-user mailing list