comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » mpfit of parametric data?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: mpfit of parametric data? [message #40508 is a reply to message #40290] Mon, 16 August 2004 11:14 Go to previous messageGo to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
"jamiesmyth_uni@yahoo.ca" <jamiesmyth_uni@yahoo.ca> writes:
> After two weeks of vacation I'm back at this. I've de-trended the
> original time series by fitting to a quadratic, and estimated the
> frequencies of the components by looking at the power spectrum.
> Unfortunately, I still cannot fit the amplitude and phase of a trivial
> sinusoid such as 'A*sin(2*!dpi*w*t+phi)'. How do I go about estimating
> the phase of the following trivial example?
>
> IDL> n = 2048
> IDL> t = dindgen(n) * 0.125 ; time
> IDL> freq = dindgen(n)/(n*0.128)
> IDL> p0 = [0.03, 0.06923, 2.3]
> IDL> data = p0(0)*sin( 2*!dpi*p0(1)*t + p0(2) )
> IDL> plot, t, data
> IDL> Ft_data = fft(data)
> IDL> plot, freq, abs(Ft_data)^2, xrange=[0,0.5] ; frequency estimate
> IDL> plot, freq, atan(double(Ft_data),imaginary(Ft_data)),
> xrange=[0,0.5] ; ?phase estimate?
>
> I think I understand what Craig said about a local-minimum but I'm a
> little surprised that such a simple problem (i.e. estimating the
> amplitude, frequency and phase of a sine wave) would be so difficult?
> How is it that my Lecroy/Tektronix scope can solve this in real time
> but I cannot do it with IDL and a dual xeon? Surely I must be missing
> something...

Jamie, since you don't have any call to MPFIT here, I am a little
confused about how your question relates to MPFIT.

Also, you have a mismatch in your FREQ and T variables, right?

The 2-argument version of ATAN accepts variables as ATAN(Y,X), not
ATAN(X,Y), so shouldn't you swap the order of the imaginary and real
components?

Finally, you are plotting the spectrum of phases. Don't you want the
phase at the maximum Fourier power? And, how do you know the phase is
wrong?

Craig

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@REMOVEcow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: ENVI: how to avoid stretching in image displays?
Next Topic: animate loaded images

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sun Oct 12 02:33:41 PDT 2025

Total time taken to generate the page: 1.60019 seconds