numpy.unwrap(p, discont=3.141592653589793, axis=-1)
函數通過將增量更改為2 * pi補碼值來幫助用戶解開給定的數組。它通過將絕對跳變更改為沿給定軸的2 * pi補碼來改變絕對跳變,從而解開弧度相位p。結果是未包裝的數組。
參數:
p : [array like] input array
discont : [float, optional] Maximum discontinuity between values, default is pi
axis : [int, optional] Axis along which unwrap will operate, default is last axis
返回: [ndarray] output array
注意:如果p中的不連續性小於pi,但大於不連續,則不進行解包,因為采用2 * pi補碼隻會使不連續性變大。
import numpy as np
l1 =[1, 2, 3, 4, 5]
print("Result 1: ", np.unwrap(l1))
l2 =[0, 0.78, 5.49, 6.28]
print("Result 2: ", np.unwrap(l2))
輸出:
Result 1: array([1., 2., 3., 4., 5.]) Result 2: array([ 0., 0.78, -0.79318531, -0.00318531])
在l2中,discont> 2 * pi(介於0.78和5.49之間),因此更改了數組值。
代碼2:自定義值有效
import numpy as np
l1 =[5, 7, 10, 14, 19, 25, 32]
print("Result 1: ", np.unwrap(l1, discont = 4))
l2 =[0, 1.34237486723, 4.3453455, 8.134654756, 9.3465456542]
print("Result 2: ", np.unwrap(l2, discont = 3.1))
輸出:
Result 1: [ 5., 7., 10., 7.71681469, 6.43362939, 6.15044408, 6.86725877]
Result 2: [0., 1.34237487, 4.3453455, 1.85146945, 3.06336035]
參考文獻: https://docs.scipy.org/doc/numpy-1.15.1/reference/generated/numpy.unwrap.html
相關用法
注:本文由純淨天空篩選整理自rajatg98大神的英文原創作品 numpy.unwrap() in Python。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。