The SmoothPhase Package
By Ted Ersek
      ersektr@navair.navy.mil

The (SmoothPhase.m) package provide a function by the same name which is demonstrated in the cells below.  Before the cells below are evaluated (SmoothPhase.m) should be copied to one of the folders returned by evaluating ($Path) in the next cell. I normally put packages in the \(TraditionalForm\`\(\(\\)\(AddOns\)\)\ExtraPackages\)  folder.

$Path

Once the package is copied to a suitable folder it can be loaded with the next cell.

<< SmoothPhase.m

The next cell shows the SmoothPhase usage message.

?SmoothPhase

The Discrete Phase of a list

The next cell shows a typical plot for the phase of a discrete signal. The jump from -π to π is typical for this type of plot.

PhaseList = Arg[Fourier[(((Range[50]  - 5.25))^2)]];
ListPlot[PhaseList];

In the next cell SmoothPhase adds 2π to certain samples and makes the phase more like a smooth curve.  Provided the values have units of radians the plot below is equivalent to the earlier plot.

SmoothPhaseList = SmoothPhase[PhaseList];
ListPlot[SmoothPhaseList];

The Discrete Phase of a matrix

The next cell shows the phase of a two dimensional signal.  As in the last case the phase has sudden jumps between -π and π.

PhaseMatrix = 
        Arg[Fourier[
            Table[(((x - 12))^2) (((y - 12))^2), {x, 25}, {y, 
                25}] ]];
ListPlot3D[PhaseMatrix];

In the next cell SmoothPhase adds to or subtracts from certain samples a multiple of 2π and makes the phase more like a smooth surface.  Here again the two plots are equivalent as long as the phase has units of radians.

SmoothPhaseMatrix = SmoothPhase[PhaseMatrix];
ListPlot3D[SmoothPhaseMatrix];

The Period option

The next cell shows the usage message of Period.

?Period

In the next cell an example from above is considered where the phase has units of degrees.

PhaseList2 = 
        Arg[Fourier[(((Range[50]  - 5.25))^2)]]/Degree;
ListPlot[PhaseList2];

By default SmoothPhase assumes the values are periodic with a period of 2π.  SmoothPhase can assume any other period through use of the Period option. In the next cell the setting (Period->360) is used and the phase looks like a smooth curve with values between  -288° and  0°.

SmoothPhaseList2 = 
        SmoothPhase[PhaseList2, Period -> 360];
ListPlot[SmoothPhaseList2, 
        PlotRange -> {-360, 0}];

In the next cell 360 is added to each sample to ensure each value for phase is between 0 and 360.  Then Mod[expr,360] is used to move the phase sample at 360 down to 0.

ListPlot[Mod[360 + SmoothPhaseList2, 360], 
        PlotRange -> {0, 360}];