* Bug fixes and documentation update.

master
Wirawan Purwanto 9 years ago
parent 56b5d9ed05
commit 78c638a371
  1. 2
      math/fitting/__init__.py
  2. 9
      math/fitting/funcs_pec.py
  3. 1
      math/fitting/funcs_physics.py
  4. 5
      math/fitting/funcs_simple.py

@ -490,7 +490,7 @@ class fit_func_base(object):
leastsq=dict(xtol=1e-8, epsfcn=1e-6),
)
fit_default_opts["lmfit:leastsq"] = dict(xtol=1e-8, epsfcn=1e-6)
debug = 1
debug = 0
dbg_params = 1
fit_method = 'fmin'
fit_opts = fit_default_opts

@ -11,10 +11,13 @@
wpylib.math.fitting.funcs_pec module
A library of simple f(x) functions for PEC fitting
For use with OO-style x-y curve fitting interface.
For use with the OO-style x-y curve fitting interface
(fit_func_base).
"""
import numpy
from wpylib.math.fitting import fit_func_base
from wpylib.math.fitting.funcs_simple import fit_harm
class harm_fit_func(fit_func_base):
@ -99,7 +102,7 @@ class morse2_fit_func(fit_func_base):
imin = numpy.argmin(y)
harm_params = fit_harm(x[0], y)
if self.debug >= 10:
print "Initial guess by fit_harm gives: ", harm_params
print("Initial guess by fit_harm gives: %s" % (harm_params,))
self.guess_params = (y[imin], harm_params[0][1], x[0][imin], 0.01 * harm_params[0][1])
return self.guess_params
def Guess_xy_old(self, x, y):
@ -134,7 +137,7 @@ class ext3Bmorse2_fit_func(fit_func_base):
imin = numpy.argmin(y)
harm_params = fit_harm(x[0], y)
if self.debug >= 10:
print "Initial guess by fit_harm gives: ", harm_params
print("Initial guess by fit_harm gives: %s " % (harm_params,))
self.guess_params = (y[imin], harm_params[0][1], x[0][imin], 0.01 * harm_params[0][1], 0)
return self.guess_params

@ -15,6 +15,7 @@ For use with OO-style x-y curve fitting interface.
"""
import numpy
from wpylib.math.fitting import fit_func_base
class FermiDirac_fit_func(fit_func_base):

@ -15,6 +15,7 @@ For use with OO-style x-y curve fitting interface.
"""
import numpy
from wpylib.math.fitting import fit_func_base
# Some simple function fitting--to aid fitting the complex ones later
@ -114,7 +115,7 @@ class linear_leastsq_fit_func(linear_fit_func):
# Changed from:
# rslt = fit_linear_weighted(x,y,dy)
# to:
rslt = (x, y, sigma=None)
rslt = linregr2d_SZ(x, y, sigma=dy)
self.last_fit = rslt[1]
# Retrofit for API compatibility: not necessarily meaningful
@ -137,6 +138,7 @@ class exp_fit_func(fit_func_base):
"""
dim = 1 # a function with 1-D domain
param_names = ['A', 'B', 'x0']
# FIXME: AD HOC PARAMETERS!
A_guess = -2.62681
B_guess = -9.05046
x0_guess = 1.57327
@ -182,6 +184,7 @@ class powx_fit_func(fit_func_base):
"""
dim = 1 # a function with 1-D domain
param_names = ['A', 'B', 'x0']
# FIXME: AD HOC PARAMETERS!
A_guess = -2.62681
B_guess = -9.05046
x0_guess = 1.57327

Loading…
Cancel
Save