[SciPy-user] Using mpfit

Jared Peacock jpeacock@mesoscopic.mines....
Tue Feb 27 14:54:07 CST 2007


I'm trying to use mpfit but I can't seem to get it to work.  I'm
testing the code using this program, which is similar to the example
from the mpfit text:

import mpfit2
import Numeric

x=Numeric.arange(1.,stop=100.)
p0=[5.7, 2.2, 500., 1.5, 2000.]
y=6.+3.5*x+200.*x**2+2.7*Numeric.sqrt(x)+2700.*Numeric.log(x)
err=.1

def myfunct(p,fjac=None,x=None,y=None,err=None):
    f=p[0]+p[1]*x+p[2]*x**2+p[3]*Numeric.sqrt(x)+p[4]*Numeric.log(x)
    status=0
    return [status,(y-f)/err]

fa = {'x':x, 'y':y, 'err':err}
m = mpfit2.mpfit(myfunct, xall=p0, functkw=fa)
print 'status = ', m.status
#if (m.status <= 0): print 'error message = ', m.errmsg
print 'parameters = ', m.params


But when I run it I get this error: 

    m = mpfit2.mpfit(myfunct, xall=p0, functkw=fa)
  File "mpfit2.py", line 1007, in __init__
    [self.status, fvec] = self.call(fcn, self.params, functkw)
TypeError: unpack non-sequence

I'm not sure what this means or how to fix it.  Does anybody have and
incite to this problem and using mpfit?

J. Peacock


More information about the SciPy-user mailing list