From 78c638a371d7ec142f93792f90d940897f3967c6 Mon Sep 17 00:00:00 2001 From: Wirawan Purwanto Date: Thu, 28 May 2015 17:20:34 -0400 Subject: [PATCH] * Bug fixes and documentation update. --- math/fitting/__init__.py | 2 +- math/fitting/funcs_pec.py | 9 ++++++--- math/fitting/funcs_physics.py | 1 + math/fitting/funcs_simple.py | 5 ++++- 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/math/fitting/__init__.py b/math/fitting/__init__.py index 19b8b6e..39d29e2 100644 --- a/math/fitting/__init__.py +++ b/math/fitting/__init__.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 diff --git a/math/fitting/funcs_pec.py b/math/fitting/funcs_pec.py index 87546e3..28f7d2a 100644 --- a/math/fitting/funcs_pec.py +++ b/math/fitting/funcs_pec.py @@ -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 diff --git a/math/fitting/funcs_physics.py b/math/fitting/funcs_physics.py index 5d5ade0..f4773c9 100644 --- a/math/fitting/funcs_physics.py +++ b/math/fitting/funcs_physics.py @@ -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): diff --git a/math/fitting/funcs_simple.py b/math/fitting/funcs_simple.py index d43d2e0..97e6317 100644 --- a/math/fitting/funcs_simple.py +++ b/math/fitting/funcs_simple.py @@ -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