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

GAUSS2DFIT - TILT ?



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

;******************************