dpnp.unwrap
- dpnp.unwrap(p, discont=None, axis=-1, *, period=6.283185307179586)[source]
Unwrap by taking the complement of large deltas with respect to the period.
This unwraps a signal p by changing elements which have an absolute difference from their predecessor of more than
max(discont, period / 2)
to their period-complementary values.For the default case where period is \(2\pi\) and discont is \(\pi\), this unwraps a radian phase p such that adjacent differences are never greater than \(\pi\) by adding \(2k\pi\) for some integer \(k\).
For full documentation refer to
numpy.unwrap
.- Parameters:
p ({dpnp.ndarray, usm_ndarray}) -- Input array.
discont ({float, None}, optional) -- Maximum discontinuity between values, default is
None
which is an alias forperiod / 2
. Values belowperiod / 2
are treated as if they wereperiod / 2
. To have an effect different from the default, discont should be larger thanperiod / 2
. Default:None
.axis (int, optional) -- Axis along which unwrap will operate, default is the last axis. Default:
-1
.period (float, optional) -- Size of the range over which the input wraps. Default:
2 * pi
.
- Returns:
out -- Output array.
- Return type:
dpnp.ndarray
See also
dpnp.rad2deg
Convert angles from radians to degrees.
dpnp.deg2rad
Convert angles from degrees to radians.
Notes
If the discontinuity in p is smaller than
period / 2
, but larger than discont, no unwrapping is done because taking the complement would only make the discontinuity larger.Examples
>>> import dpnp as np >>> phase = np.linspace(0, np.pi, num=5) >>> phase[3:] += np.pi >>> phase array([0. , 0.78539816, 1.57079633, 5.49778714, 6.28318531]) >>> np.unwrap(phase) array([ 0. , 0.78539816, 1.57079633, -0.78539816, 0. ])
>>> phase = np.array([0, 1, 2, -1, 0]) >>> np.unwrap(phase, period=4) array([0, 1, 2, 3, 4])
>>> phase = np.array([1, 2, 3, 4, 5, 6, 1, 2, 3]) >>> np.unwrap(phase, period=6) array([1, 2, 3, 4, 5, 6, 7, 8, 9])
>>> phase = np.array([2, 3, 4, 5, 2, 3, 4, 5]) >>> np.unwrap(phase, period=4) array([2, 3, 4, 5, 6, 7, 8, 9])
>>> phase_deg = np.mod(np.linspace(0 ,720, 19), 360) - 180 >>> np.unwrap(phase_deg, period=360) array([-180., -140., -100., -60., -20., 20., 60., 100., 140., 180., 220., 260., 300., 340., 380., 420., 460., 500., 540.])