Fitting an ellipsoid with MPFITEXPR [message #74274] |
Fri, 07 January 2011 15:53 |
johan[1]
Messages: 11 Registered: December 2010
|
Junior Member |
|
|
I need to fit an ellipsoid to data acquired. I was thinking of using
the mpfit routines and have the following:
By supplying the eigenvalues and eigenvectors I generate the ellipsoid
with the following function:
************************************************************ ****************************************************
function Ellipsoid, evals, evec
no_prof_lat = 24
no_prof_lon = 32
u = indgen(no_prof_lon)*2*!pi/(no_prof_lon-1)
v = indgen(no_prof_lat)*!pi/(no_prof_lat-1)-!pi/2
x = evals[0]*transpose(sin(u)#cos(v))
y = evals[1]*transpose(cos(u)#cos(v))
z = evals[2]*replicate_array(sin(v),no_prof_lon)
return, evec # transpose([[x[*]],[y[*]],[z[*]]])
end
************************************************************ ****************************************************
I created the following calling routine:
************************************************************ ****************************************************
pro fit_ellipsoid
restore, 'points.dat' ; a (3,768) array of extracted points
x = findgen(768)*(70./768)
y = findgen(768)*(66./768)
z = findgen(768)*(100./768)
XVal = transpose([[x],[y],[z]])
evals = [71.1, 66.1, 100.2]
evec = [ $
[-0.07, -0.10, 0.99], $
[-0.43, -0.90, -0.12], $
[ 0.90, -0.44, 0.03]]
expr = 'Ellipsoid(X, P[0:1])'
; Cannot concatenate
start = [evals, evec]
result = MPFITEXPR(expr, XVal, extracted_points, 1, start)
end
************************************************************ ****************************************************
The problem with this routine is that I cannot concatenate the start
values into a single array, maybe I on the wrong track in specifying
the start values?
The other question is whether the routine MPFITEXPR is really suited
for this problem? I do not have dependent and independent values and
created the XVal to act as the independent values but it seems a bit
superficial to me.
Am I on a wild goose chase or can this work?
|
|
|