There is an unwrap function in numpy. Doesn't it work for you? Nadav ________________________________________ From: numpy-discussion-boun...@scipy.org [numpy-discussion-boun...@scipy.org] on behalf of Neal Becker [ndbeck...@gmail.com] Sent: 11 January 2013 17:40 To: numpy-discussion@scipy.org Subject: [Numpy-discussion] phase unwrapping (1d)
np.unwrap was too slow, so I rolled by own (in c++). I wanted to be able to handle the case of unwrap (arg (x1) + arg (x2)) Here, phase can change by more than 2pi. I came up with the following algorithm, any thoughts? In the following, y is normally set to pi. o points to output i points to input nint1 finds nearest integer value_t prev_o = init; for (; i != e; ++i, ++o) { *o = cnt * 2 * y + *i; value_t delta = *o - prev_o; if (delta / y > 1 or delta / y < -1) { int i = nint1<int> (delta / (2*y)); *o -= 2*y*i; cnt -= i; } prev_o = *o; } _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion