Adapting Unwrapping Techniques for Plotting Phase Values

  • Context: Mathematica 
  • Thread starter Thread starter Swamp Thing
  • Start date Start date
  • Tags Tags
    Phase Plot
Click For Summary
SUMMARY

This discussion focuses on adapting unwrapping techniques for plotting phase values in Mathematica, specifically using the function fnUnwrap2 to create a jump-free graph. The implementation involves maintaining state information through variables unwrap`old and unwrap`cumu to track previous inputs and accumulated jumps. The current approach results in spikes around jump points and an offset, indicating potential issues with the plotting algorithm's evaluation sequence. Suggestions are sought for improving the function to eliminate these artifacts.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of phase unwrapping techniques
  • Knowledge of plotting functions in Mathematica, specifically Plot and ListPlot
  • Basic concepts of modular arithmetic and its application in phase calculations
NEXT STEPS
  • Explore advanced techniques for phase unwrapping in Mathematica
  • Investigate the use of ListPlot versus Plot for phase data visualization
  • Learn about state management in Mathematica for maintaining variable history
  • Research methods to optimize plotting algorithms to handle non-linear evaluations
USEFUL FOR

Mathematica users, data visualization specialists, and anyone involved in signal processing or phase analysis who seeks to create accurate and visually appealing plots without artifacts.

Swamp Thing
Insights Author
Messages
1,047
Reaction score
780
TL;DR
Plotting Arg[ f[x] ] gives output that has jumps of +/- 2Pi and is limited to +-Pi.
Can we unwrap this into a jumpless plot?
This discussion https://community.wolfram.com/groups/-/m/t/1340126 includes some ideas to unwrap a list of wrapped-around values such as phase (e.g. Arg[ f[N] ] ). You can use this to ListPlot a jump-free graph.

I'm trying to adapt this to work in Plot rather than ListPlot. The idea is to plot fnUnwrap [ myPhase[t] ], where fnUnwrap is called whenever the plotter wants to evaluate the Y value.

Now fnUnwrap needs to use two successive phase values, and also maintain a cumulative total of all the jumps. So we store some "state information" in the variables unwrap`old and unwrap`cumu, i.e. the previous input and the accumulated jumps. Here is my attempt:
Code:
fnUnwrap2[new_,\[CapitalDelta]_,tol_]:=Module[{jmp},
                                    jmp=new-unwrap`old;
                                    jmp=-Sign[jmp] Unitize[        Chop [ Abs[jmp],tol      ]   ];
                                    jmp= jmp *  \[CapitalDelta];
                                    unwrap`cumu=unwrap`cumu+jmp;
                                    unwrap`old=new;
                                    new + unwrap`cumu
                                                                                  ]

This code "sort of" works, but has these spikes around the jump points and has an offset as well:

Code:
unwrap`old=0
unwrap`cumu=0

Plot[{ fnUnwrap2[Mod[ x, 2],2,1.75],
           x
        
    },{x,0,12},PlotRange->All,PlotPoints->250]

Output:
1635757404617.png


Can this be fixed , or is there a better approach?
 
Last edited:
Physics news on Phys.org
Perhaps part of the problem is that the plotting algorithm often evaluates Arg[f[x]] in a random sequence of X. Maybe we need to store not only old_Arg but also old_X, and somehow use that to avoid confusing the plotting algorithm.

Any suggestions much appreciated.
 
Last edited:

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K