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

Home » Public Forums » archive » GAUSS2DFIT - TILT ?
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
GAUSS2DFIT - TILT ? [message #22787] Mon, 11 December 2000 05:45 Go to next message
Zeschke is currently offline  Zeschke
Messages: 2
Registered: December 2000
Junior Member
Why does the following example not work correctly ?
This program use the "GAUSS2DFIT.PRO" - Routine. The "Tilt"-Parameter-Fit
does not work.
What can I do ?


Thanks for any help
Thomas



;******************************
loadct,39

; Define array dimensions.
nx = 128 & ny = 128
; Define input function parameters.
A = [ 5., 100., nx/8., ny/20., nx/2., .6*ny]

; Create X and Y arrays.
X = FINDGEN(nx) # REPLICATE(1.0, ny)
Y = REPLICATE(1.0, nx) # FINDGEN(ny)


;Tilt
T=1.

h=A[4]
k=A[5]
x1 = (x - h) * cos(T) - (y - k) * sin(T)
y1 = (x - h) * sin(T) + (y - k) * cos(T)
U = (X1/A[2])^2 + (Y1/A[3])^2; Create an ellipse.
xvec=x[*,0]
yvec=y[0,*]
yvec=transpose(yvec)

Z = A[0] + A[1] * EXP(-U/2) ; Create gaussian Z.
Z = Z + RANDOMN(seed, nx, ny) ; Add random noise, SD = 1.
yfit = GAUSS2DFIT(Z,B,xvec,yvec, /tilt) ; Fit the function with rotation.

PRINT, ' constant scale width_x width_y center_x center_y tilt'
PRINT, 'Should:', STRING(A,T, FORMAT='(6f8.3)')
PRINT, 'Is: ', STRING(B(0:6), FORMAT='(6f8.3)')
contour,z,x,y,/fill,nlevels=30
contour,yfit,x,y,/noerase

;******************************
Re: GAUSS2DFIT - TILT ? [message #22923 is a reply to message #22787] Mon, 11 December 2000 10:42 Go to previous message
Craig Markwardt is currently offline  Craig Markwardt
Messages: 1869
Registered: November 1996
Senior Member
Hi Thomas--

I get problems with your program as well, as shown here.

constant scale width_x width_y center_x center_y tilt
Should: 5.000 100.000 16.000 6.400 64.000 76.800 1.000
Is: 4.841 100.218 7.378 10.076 63.884 76.800 0.000

This exact subject came up a few months ago by Ken Bowman. I
suggested he try MPFIT2DPEAK, available from my IDL library. So far I
have found this routine to be a little more robust in finding peaks
and establishing rotations.

In your example I obtained the "right" answer with MPFIT2DPEAK:

IDL> yfit = mpfit2dpeak(z, b,xvec,yvec,/tilt)
Should: 5.000 100.000 16.000 6.400 64.000 76.800 1.000
Is: 4.999 100.004 6.386 16.007 63.995 76.814 2.571

Note that the fitted X and Y axes are flipped from your initial
definition, hence the fitted value of 2.571 = 1.000 + !dpi/2. Of
course you can easily put the semi-major axis under the X column with
a simple transformation.

http://cow.physics.wisc.edu/~craigm/idl/idl.html

Craig

IDL> print, !version
{ x86 linux unix 5.2.1 Jun 4 1999}


"Zeschke" <zeschke@bessy.de> writes:

> Why does the following example not work correctly ?
> This program use the "GAUSS2DFIT.PRO" - Routine. The "Tilt"-Parameter-Fit
> does not work.
> What can I do ?
>
>
> Thanks for any help
> Thomas

--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: IDLgrLegend broken
Next Topic: postscript file sizes

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

Current Time: Sat Oct 11 08:03:31 PDT 2025

Total time taken to generate the page: 0.40015 seconds