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

Home » Public Forums » archive » MPFIT2DPEAK with constraints
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
MPFIT2DPEAK with constraints [message #36644] Thu, 09 October 2003 15:40 Go to previous message
c.carrano is currently offline  c.carrano
Messages: 2
Registered: October 2003
Junior Member
Greetings. I'm trying to understand how Craig
Markwardt's peak fitting function MPFIT2DPEAK
works when you wish to require that certain
parameters be held constant.

Specifically, I know that my data should peak
at the origin and so I'd like to force the
fitted Gaussian to peak there as well.

Despite specifying that A[4] and A[5] be
fixed using the PARINFO structure, the fitted
Gaussian is not centered at the origin.
Supplying PARINFO to MPFIT2DPEAK does change
the fit but it actually makes it slighly worse.
Anyone know what I might be doing wrong?

Here's my sample code:

;------------------------------------------------
; Construct a sample gaussian surface in range [-5,5] centered at
[0,0]
x = findgen(100)*0.1 - 5. & y = x
xx = x # (y*0 + 1)
yy = (x*0 + 1) # y
rr = sqrt((xx-0*2.)^2 + (yy+0*3.)^2)

; Gaussian surface with sigma=0.5, peak value of 3, noise with
sigma=0.2
seed=6
z = 3.*exp(-(rr/0.5)^2) + randomn(seed,100,100)*.2

pi = replicate({value:0.D, fixed:0, limited:[0,0], $
limits:[0.D,0]}, 7)

pi(4).fixed = 1
pi(5).fixed = 1

a0=[0., 3., 1.0, 1.0, 0.0, 0.0, 0.0]
pi(*).value = a0

; Fit gaussian parameters A
zfit = mpfit2dpeak(z, a1, x, y, /tilt, PARINFO=pi)

zfit = mpfit2dpeak(z, a2, x, y, /tilt)

print,a1
print,a2
------------------------------------------------

IDL prints:

a1=[-0.000156282, 2.82180, 0.382853, 0.347286, -0.0999999, 0.0999999,
0.716917]

a2=[-0.000266513, 3.06073, 0.345753, 0.351519, -0.000407959,
0.00455947, 1.98130]
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: Different scales in the same plot
Next Topic: interpolate over bad pixels

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

Current Time: Fri Oct 10 07:24:39 PDT 2025

Total time taken to generate the page: 2.07947 seconds