Hi,
I want to use relax.py (rh command) for T1 calculation. However the
a*exp(b*t) model is not exactly right for T1, so I want to modify the
python code for this. I changed where the model is defined and where
(I believe) the initial guesses are defined as follows:
class a_exp_bx_function:
def parameter_count(self):
return 2
def value(self, params, x):
a, b ,c = params
# Multiply overflows in fit error calculation cause core dump on
DEC Alpha
cx = pyutil.bound_value(c*x, -50, 50)
e = math.exp(cx)
return a-(a-b)*e
def parameter_derivatives(self, params, x):
a, b, c = params
e = math.exp(c*x)
return (1-e,e,-a*x*e+b*x*e)
def fit_exponential(self, th_pairs):
fit_th_pairs = filter(lambda th: th[1] != None, th_pairs)
if len(fit_th_pairs) 2:
return None
exp_func = a_exp_bx_function()
h_values = map(lambda th: th[1], fit_th_pairs)
h_middle = .5 * (max(h_values) + min(h_values))
params = (h_middle, h_middle,0)
trials = self.error_estimate_trials
fit = curvefit.least_squares_fit(fit_th_pairs, exp_func, params, 1e-6)
fit.estimate_parameter_error(fit.point_sd, trials)
self.calculate_decay_time(fit)
return fit
However, when I run this code in sparky I get a straight line (I
guess) at h_middle. I dont know anything about Python so I can not
figure out where the problem is.
Is there anyone who had tried this before.
And maybe more important question is, can this code be modified to
give reasonable fit for y=a-(a-b)*exp(ct) kind of model, which cannot
be linearized by taking simple log.
Thanks
Asli Ertekin