[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unwrap modulo 2pi



In the following bit of code the measured phase P is unwrapped onto
CALCPhi.
This is done by doing a 2nd order extrapolation of the three previous
points.  It works when the jumps are not too extreme.

;Correct Phi and PhiOne for 2Pi jumps. The calculated Phi is compared to
;the experimentally obtained Phi. Extrapolation with least squares fit.
NPhi=N_ELEMENTS(P)
CALCphi=DBLARR(NPhi)
FOR i=3,(NPhi-1) DO BEGIN
 CALCphi(i)=(-2*P(i-3)+P(i-2)+4*P(i-1))/3
 Njumps=NINT((CALCphi(i)-P(i))/(2*!DPi), /Long)
 P(i)=P(i)+Njumps*2*!DPi
ENDFOR

graham_wilson@my-deja.com wrote:

> IDL> a=[2,4,6,8,10,12]
> IDL> a=[2.,4.,6.,8.,10.,12.]
> IDL> b=2*!PI
> IDL> c=a mod b
> IDL> print, c
>       2.00000  4.00000   6.00000   1.71681  3.71681   5.71681
>
> What I mean by 'unwraping' is: Given I know 'c' and 'b' how do I
> explicitly find a?

--

Dr. Wim G. Bouwman             phone (++31) (0)15 2786775
Interfacultair Reactor Instituut  fax (++31) (0)15 2788303
Technische universiteit Delft    w.g.bouwman@iri.tudelft.nl
Mekelweg 15                          http://www.iri.tudelft.nl/~bouwman
2629 JB Delft                         The Netherlands