PHUNWRAP Name
PHUNWRAP
Author
Craig B. Markwardt, NASA/GSFC Code 662, Greenbelt, MD 20770
craigm@lheamail.gsfc.nasa.gov
UPDATED VERSIONs can be found on my WEB PAGE:
http://cow.physics.wisc.edu/~craigm/idl/idl.html
Purpose
Unwrap phase jumps to recover cycle counts
Major Topics
Mathematics
Calling Sequence
CYCLES = PHUNWRAP(PHASE, TOLERANCE=, MAXVAL=)
Description
PHUNWRAP unwraps a sequence of phases to produce a new series of
cycle counts. Phase jumps due to crossing over the PHASE=0
boundary are removed by adding an integral number of cycles. The
algorithm is based on the MATLAB "unwrap" function.
NOTE: the unwrapping process can be ambiguous if there is a phase
jump of more than a half cycle in the series. For example, if the
phase changes by ~0.5 cycles, it is not possible to distinguish
whether there wasa +0.5 cycle or -0.5 cycle jump. The most
accurate unwrapping can be performed if the PHASE series is nearly
continuous and does not have rapid phase changes.
Users can select the tolerance used to determine the phase jump.
Users can also select the definition of "1 cycle" by changing
MAXVAL. By default, MAXVAL is 2*!DPI, which correspondes to 1
cycle = 2*!DPI radians, but other values of 1 (cycle), or 360
(degrees) are possible. Inputs
PHASE - phase series to be unwrapped. Values should range from 0
to MAXVAL. The ordering of the series is important.
Returns
A new series, expressed in cycles, with cycle jumps larger than
TOLERANCE removed. Optional Keywords
TOLERANCE - phase jump tolerance. If the phase from one sample to
the next changes by more than TOLERANCE, then a single
cycle jump is assumed to have occurred.
DEFAULT: 0.5*MAXVAL
MAXVAL - Maximum value for phase. Common values are: 2*!DPI
(radians; DEFAULT); 1 (cycle); 360 (degrees), but any
positive value may be used. Example
;; Set up some fake data
x = dindgen(100)/10d
y = x/2
ph = y MOD 1.0 ;; Mock phases
cycles = phunwrap(ph, maxval=1)
Modification History
Written and documented, CM, July 2003
Handle the case of unsigned integer input, CM, Feb 2006