[SciPy-user] mpfit questions
Scott Ransom
sransom at nrao.edu
Thu Jul 6 11:53:30 EDT 2006
Running numpy/lib/convertcode.py on mpfit.py worked fine for me.
I don't think I needed to make any other changes.
Scott
On Thu, Jul 06, 2006 at 02:58:48PM +0200, Steve Schmerler wrote:
> Jean-Francois Moulin wrote:
> > Hi all,
> >
> > I am trying to get mpfit to work and I have some questions:
> >
> > 0) cutting and pasting the doc example which goes like
> > ...
> > m = mpfit('myfunct', p0, functkw=fa)
> > ...
> > I get a "module not callable" error
> >
> > I changed the call to m = mpfit.mpfit('myfunct', p0, functkw=fa)
> > and it seems to work (until I reach the prblem below).
> >
> > 1) I get this message when trying to call mpfit
> > File "c:\Python24\lib\site-packages\mpfit.py", line 2249, in __init__
> > self.maxlog = log(self.maxnum)
> > NameError: global name 'log' is not defined
> > (I did import Numeric and mpfit before my call)
> >
>
> I think the line should be
>
> self.maxlog = Numeric.log(self.maxnum)
>
>
> > 2) how to have it working with numpy/scipy (rather than Numeric)
> > -I tried putting a from scipy import * clause in mpfit.py and remove
> > all refs to numeric but I get the same message as above message.
> >
>
> This will be a bit of work. At first you have to change the import
> statememts in mpfit.py:
>
> ##import Numeric
> import numpy
> # you don't have to replace Numeric with numpy everywhere
> Numeric = numpy
> Numeric.Float = numpy.float64
> Numeric.Int = numpy.int64
>
> But then you will probably run into problems like
>
> Traceback (most recent call last):
> File "./trans.py", line 173, in ?
> x, dy = fit_transient(tt, yy, method = method, x_start = x_start,
> ret_all = 1, red_data = red_data)
> File "/home/schmerler/sim/transient_fitting.py", line 89, in
> fit_transient
> x = lmFit(array([t, y]), func = model, args = (dy,), limits =
> bounds, ig = x_start)
> File "/home/schmerler/Python/lmfit.py", line 198, in lmFit
> fit = mpfit.mpfit(residualFunction, parinfo = parameter_infos,
> quiet = 1, ftol = 1e-15, xtol = 1e-15, gtol = 1e-15, maxiter = niter)
> File "/home/schmerler/Python/mpfit.py", line 1062, in __init__
> functkw=functkw, ifree=ifree, xall=self.params)
> File "/home/schmerler/Python/mpfit.py", line 1563, in fdjac2
> mask = mask or (ulimited and (x > ulimit-h))
> ValueError: The truth value of an array with more than one element is
> ambiguous. Use a.any() or a.all()
>
> Since I'm not using mpfit ATM, I didn't try to adapt the mpfit code to
> numpy ...
>
> Have you tried optimize.leastsq?
>
> cheers,
> steve
>
> --
> Random number generation is the art of producing pure gibberish as
> quickly as possible.
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.org
> http://projects.scipy.org/mailman/listinfo/scipy-user
--
--
Scott M. Ransom Address: NRAO
Phone: (434) 296-0320 520 Edgemont Rd.
email: sransom at nrao.edu Charlottesville, VA 22903 USA
GPG Fingerprint: 06A9 9553 78BE 16DB 407B FFCA 9BFA B6FF FFD3 2989
More information about the SciPy-User
mailing list