Function Repository Resource:

# PhaseUnwrap (1.0.0)current version: 1.0.1 »

Remove phase jumps from phase angle data

Contributed by: Sander Huisman
 ResourceFunction["PhaseUnwrap"][list] removes phase jumps in consecutive elements of list by adding ±n 2π for jumps that are larger than the default tolerance of π. ResourceFunction["PhaseUnwrap"][list,τ] removes phase jumps in consecutive elements of list by adding ±n τ for jumps that are larger than the default tolerance of τ/2. ResourceFunction["PhaseUnwrap"][list,τ,tol] removes phase jumps in consecutive elements of list by adding ±n τ for jumps that are larger than the tolerance tol.

## Details and Options

list should be a one-dimensional numerical list.
The default for τ is 2π.
Common settings for τ are 2π and 360 for the use of angles measured in radians and degrees, respectively.
The default tolerance tol is τ/2.
A tolerance tol smaller than τ/2 works effectively the same as a tolerance of τ/2.
ResourceFunction["PhaseUnwrap"] could be seen as the opposite of Mod for a time series as it "unwraps" the "wrapping around" in modular arithmetic.
Possible forms for tol are:
 α uses the tolerance α Scaled[α] uses a tolerance of α τ

## Examples

### Basic Examples (2)

Remove the discontinuity in the phase:

 In[1]:=
 Out[3]=

Correct phase jumps in a list of phase angles measured in degrees:

 In[4]:=
 Out[6]=

### Scope (3)

Supply a stricter tolerance:

 In[7]:=
 Out[9]=

Supply a tolerance as a scaled version of the modulus:

 In[10]:=
 Out[12]=

Jumps of multiple times the modulus τ are also removed:

 In[13]:=
 Out[15]=

### Applications (2)

Data measured from an angular encoder on a shaft:

 In[16]:=
 Out[17]=

Unwrap data to get the absolute angle of the shaft:

 In[18]:=
 Out[18]=

### Properties and Relations (1)

PhaseUnwrap is the opposite of Mod for time series of data:

 In[19]:=
 Out[22]=

### Possible Issues (1)

If the tolerance is too high, steep parts of the function cannot be reconstructed, resulting in partial removal of the discontinuities:

 In[23]:=
 Out[26]=

### Neat Examples (2)

Show some modulated data:

 In[27]:=
 Out[28]=

Interactively change the tolerance. For a scaled tolerance of 1, the original signal is returned:

 In[29]:=
 Out[29]=

Apply it to two-dimensional data by doing row-by-row unwrapping. First create some data:

 In[30]:=
 Out[31]=

Modulate the data:

 In[32]:=
 Out[33]=

Reconstruct the data:

 In[34]:=
 Out[37]=

Check that they are the same within machine precision:

 In[38]:=
 Out[38]=

SHuisman

## Requirements

Wolfram Language 11.3 (March 2018) or above

## Version History

• 1.0.1 – 30 June 2023
• 1.0.0 – 20 March 2019