I have written the codes below:
def model(axis, p):
a1, t1, a2, t2, a3, t3, a4, t4 = p
return a1*np.exp(-axis/t1) + a2*np.exp(-axis/t2) + a3*np.exp(-axis/t3) + a4*np.exp(- axis/t4)
This code is the definition of 4 exponentials. I have to convolve this functions, which
returns a series in different time points, with another series. To do this I have written
the code below:
def Recsig(N, irf, model):
conv_sig = [0.0]*irf.size
for n in range(0,N+1):
SUM = 0.0
for m in range(0, n+1):
SUM = irf[m]*model[n-m] + SUM
conv_sig[n] = SUM
result = np.squeeze(conv_sig)
return result
The result of Recsig function must be a series. I have another series obtained by
experiment. The goal is to use nonlinear least squares method, experimental series, and
Recsig to find the parameters in function model, a1,t1 .... a4,t4.
The problem is that model function does not accept parameter when I want to call it. As a result I cannot make a series of 4 exponentials and give it to Recsig function.
More explanation:
I measured the fluorescence emission of some kind of bacteria in time using TCSPC set up,
time correlated single photon counting. The recorded signal or fluorescence is the
convolution of IRF, instrument response function, and a model
, in this case a 4
exponential function. I want to convolve, do the convolution, irf and the model
. Then I
will have the result of this convolution as a series in time. Each element of the series is
the value of convolution in a point in time. Now, I can use the convolution series and
recorded fluorescence to estimate the free parameters in model
.
The problem is that I cannot turn the model
function into a series with a given time axis.
numpy.exp(axis/t1)
tries to evaluate the numerical value of this exponential, but just axis
is a numerical value and t1 is a parameter yet to bet determined in the fitting. As a
result mumpy cannot turn the model
function into a series.