def fitExp(self, src, dest, b=None):
     tmp = []
     for d in self.data:
         if d[src] > 0:
             tmp.append((d[1],math.log(d[src])))  # ts, value    
     if b is None:
         ef = function_fit.function_fit(tmp, lin_function.func())
     else:
         ef = function_fit.function_fit(tmp, parlin_function.func(_m=b))
     sys.stderr.write("%s\n"%str(ef.fit()))
     [b, a] = ef.f.getParList()
     A = math.exp(a)
     for d in self.data:
         d[dest] = d[src] - A*math.exp(b * d[1])
Ejemplo n.º 2
0
        lead_cols[tmp] = r[:icol]
        padding = [NA for x in lead_cols[tmp]]
    except ValueError, e:
        print "Skipping text values (%s)"%','.join(r)

# fit type
if options.func_name == "lognorm":
    func = lognormal_function.func()
elif options.func_name == "gauss":
    func = gauss_function.func()
elif options.func_name == "exp":
    func = exp_function.func()
elif options.func_name == "gamma":
    func = gamma_function.func()
elif options.func_name == "lin":
    func = lin_function.func()
else:
    func = doubleexp_function.func()
fr = function_fit(d, func, p0)

# fit results
print fr.fit()

# blank line
print
wrt = csv.writer(sys.stdout)
# output is outer join of function and fit
d_dict = dict(d)
f_dict = dict(fr.eval(start=tstart, end=tend, points=points))

for time in sorted(list(set(d_dict.keys() + f_dict.keys()))):