Hi,
Thanks for your answers.
I don't have more time to play with gnuplot so I decided to use only
python's tools
Finally I use scipy to fittnig my data.
This is my code
def main():
z,f = numbers_col()
fitfunc = lambda v, z: v[0]*exp(z*v[1])
errfunc = lambda v, z,f: fitfunc(v,z) - f
v0 = [10., 0.005]
v1,success = optimize.leastsq(errfunc, v0[:], args =
(z,f),full_output=True)
best regars,
Cris
2011/11/14 Michael Haggerty <mh...@al...>
> On 11/12/2011 05:43 PM, Krzysztof Berniak wrote:
> > I'm writing script in python, which fitting exponencial curve to data (
> > f(x) = a*exp(x*b).
> > To this problem, I use gnuplot in my script. Gnuplot display parameters
> > ( a +/- delta a; b +/- delta b)
> > How Can I use/save this parameters in python variables in next steps of
> > my script,
> >
> > def main():
> > ...
> >
> >
> > plot = Gnuplot.Gnuplot()
> >
> > plot('f1(x) = a1*exp(b1*x)')
> > plot('a1 = 300; b1 = 0.005;')
> > plot('fit f1(x) "data.txt" using 1:2 via a1, b1')
> >
> > print "first parameter", a1
> > print "second parameter", b1 # is it feasible ? Or there is
> > another way to see the results ( parameter a1 and b1) of gnuplot by
> python
> >
> > #plot('set terminal postscript')
> > #plot('set output "output.ps <http://output.ps>"')
>
> The communication from Gnuplot.py to gnuplot is currently
> one-directional only. Therefore, there is no way for Gnuplot.py to see
> the output that gnuplot writes to the terminal.
>
> So without rewriting Gnuplot.py to change that fact (which would be a
> big job), the easiest thing would be to have gnuplot write the results
> of the fit to a file (see "help update"), then have Python read that
> file. If you want more information about the fit, you can read the
> logfile that gnuplot's "fit" command generates (see "help fit", "help
> set fit").
>
> Michael
>
> --
> Michael Haggerty
> mh...@al...
> http://softwareswirl.blogspot.com/
>
|