NumPy's Unwrap function __ function

Source: Internet
Author: User

This function is used to handle the phase angle recently, so here is a little space to record my understanding.

What is the unwrap function used for? It is used to solve the wound.

As for what is winding, the online statement is:

To calculate a system phase-frequency characteristics, it is necessary to use the inverse tangent function, the computer in the inverse tangent function, in the one or two quadrant angle is 0~PI, the three or four quadrant angle is 0~-pi.
If an angle from 0 to 2pi, but the actual result is 0~pi, and then by the-pi~0, in the w=pi of the jump, jump amplitude of 2pi, which is called phase winding.


As shown in the figure above, if the phase angle from the -0.99PI, counterclockwise rotation, through the negative axis of the x-axis, to reach the third phase, then by definition, at this point its angle will be directly from Pi to-pi, there will be a 2pi jump, so, if the rotation angle is drawn into the image, In fact, the image is discontinuous and, in order to correct the jump, there is a unwrap.

What the hell did unwrap do? It only detects adjacent two values A and B, and if ABS (A-b) > tol, then revise B to eliminate this sudden jump by adding or reducing 2pi to B, where Tol is actually a parameter to the unwrap function, The default is pi.

As an example:

OUT[196]: A = Np.array ([3.13, -3.12, 3.12, 3.13, -3.11]) in
[197]: A
out[197]: Array ([3.13, -3.12,  3.12,  3.13, -3.11]) in
[198]: Np.unwrap (a)
out[198]: Array ([3.13      ,  3.16318531,  3.12      ,  3.13      ,  3.17318531])

The code above, when the angle from 3.13 to 3.12, 3.13 + 3.12 > Pi, so to 3.12 to add a 2pi correction, changed to 3.16318531, then compare 3.16318531 and 3.12, do not fix, Continue to compare 3.12 and-3.11, add a 2pi to 3.11, change to 3.17318531, and complete the correction.

The only thing you need to pay special attention to with this function is not to use this function indiscriminately .
I didn't know the market before, often with a column of no rules can be said to do the winding, similar to:

IN[207]: Phase = Np.array ([2.67, -0.92, -1.37, -0.58, 0, 0,78, -2.94])
in[208]: np.unwrap (phase)
out[208]: 
Array ([2.67      ,  5.36318531,  4.91318531,  5.70318531,  6.28318531, 6.28318531,  8.88496162,  9.62637061])

See no, the above result is not very surprising, what ghost, incredibly appeared more than PI angle.

This is because, unwrap actually contains a premise (see from the operating mechanism also), these angles have time series. For the sequence [A,b,c], the object must first be a angle, then the b angle, and then the C angle.

Above, from the 2.67->-0.92, 0.92 plus a 2pi to make corrections, get 5.36 ..., 5.36 ... Compare with-1.37, 1.37 becomes 4.91 ..., 4.91 ... Compare with-0.58, 0.58 becomes 5.70 ..., 5.70 ... Compared with 0, 0 directly adds a 2pi to 6.28 ...,......

Overall, unwrap B is corrected by comparing the adjacent A and B, taking into account A's value.

So try not to use unwrap to the random angle of correction, meaningless.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.