In [17]:
import sys
sys.path.append('/Users/ck/devel/peak-o-mat')
In [18]:
from peak_o_mat.project import Project
from peak_o_mat.model import Model
from peak_o_mat.fit import Fit
In [19]:
lpj = Project()
lpj.load('/Users/ck/devel/peak-o-mat/example.lpj')
In [20]:
mod = lpj[5][4].model.copy()
In [21]:
print mod
LB LO1 LO2 LO3 LO4
In [22]:
sets = lpj[5]
for s in sets[::-1]:
    mod = mod.copy()
    s.limits = (240,330)
    f = Fit(s, mod, maxiter=200)
    res = f.run()
    print res[-1]
    mod.update_from_fit(res)
    s.model = mod
['reason for halting: Sum of squares convergence', 'residual variance: 0.00193225']
['reason for halting: Sum of squares convergence', 'residual variance: 0.00145658']
['reason for halting: Sum of squares convergence', 'residual variance: 0.00427332']
['reason for halting: Sum of squares convergence', 'residual variance: 0.00621128']
['reason for halting: Sum of squares convergence', 'residual variance: 0.00913794']
In [23]:
lpj.save('/users/ck/devel/peak-o-mat/result.lpj')
In [24]:
sets[0].model.parameters_as_table()
Out[24]:
[[u'LB', 'lin', -0.00048104443817930612],
 [u'LB', 'const', 0.044997780878055012],
 [u'LO1', 'amp', 0.075247342513192941],
 [u'LO1', 'fwhm', 6.9737907622426505],
 [u'LO1', 'pos', 254.78375052829705],
 [u'LO1', 'area', 0.80243752102757937],
 [u'LO2', 'amp', 0.30144465936881021],
 [u'LO2', 'fwhm', 5.5126557625350641],
 [u'LO2', 'pos', 264.57071796749199],
 [u'LO2', 'area', 2.5410874762758917],
 [u'LO3', 'amp', 1.1303717562561664],
 [u'LO3', 'fwhm', 4.7124994064160308],
 [u'LO3', 'pos', 283.20792010436895],
 [u'LO3', 'area', 8.1454277004173559],
 [u'LO4', 'amp', 5.4877387702119478],
 [u'LO4', 'fwhm', 4.0369231753405321],
 [u'LO4', 'pos', 297.26235086797374],
 [u'LO4', 'area', 33.876229183351285]]
In []: