Exemple #1
0
def fitExpDecay(data, t, p0=1):
    """
    return rhamda, mean_lifetime, half_life, check
    """
    data = N.asarray(data, N.float64)
    t = N.asarray(t, N.float64)

    def f(p, n0):
        return yExpDecay(p, t, n0) - data

    x0 = p0
    from scipy import optimize
    rhamda, check = optimize.leastsq(f, x0, args=(data[0], ))
    if check in [1, 2, 3, 4]:
        mean_lifetime = 1. / rhamda + t[0]
        half_life = N.log(2.) * mean_lifetime
    else:
        mean_lifetime = half_life = 0
    return rhamda, mean_lifetime, half_life, check
Exemple #2
0
def fitExpDecay(data, t, p0=1):
    """
    return rhamda, mean_lifetime, half_life, check
    """
    data = N.asarray(data, N.float64)
    t = N.asarray(t, N.float64)

    def f(p, n0):
        return yExpDecay(p, t, n0) - data

    x0 = p0
    from scipy import optimize
    rhamda, check = optimize.leastsq(f, x0, args=(data[0],))
    if check in [1,2,3,4]:
        mean_lifetime = 1./rhamda + t[0]
        half_life = N.log(2.) * mean_lifetime
    else:
        mean_lifetime=half_life=0
    return rhamda, mean_lifetime, half_life, check
def arr_log(arr):
    logArr = N.log(arr)
    return N.where(logArr < 0, 0, logArr)
Exemple #4
0
def arr_log(arr):
    logArr = N.log(arr)
    return N.where(logArr < 0, 0, logArr)