[Python] Calculate Exponential decay rate constant from graph

Discussão em 'Python' iniciado por Stack, Julho 13, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to calculate the lifetime of the particles from the extrapolated curve below, I know that lifetime is 1/decay constant but I get values for the decay constant that dont make sense.

    import numpy as np
    import matplotlib.pyplot as plt
    from scipy.interpolate import make_smoothing_spline
    from matplotlib.ticker import (MultipleLocator, FormatStrFormatter,AutoMinorLocator)
    import math
    Time=[0.1,0.5,1,5,10,50,100,250,500,1000,2500,5000]
    Intensity=[2722.164194,2877.627742,2663.520645,2708.928125,2545.461613,2421.236129,1885.837742,1710.483871,1275.428387,776.0895806,192.4806452,26.35279]
    error=[365.0612668,365.9075468,401.1165559,405.5068204,320.8171197,317.7694792,266.8600888,157.3938377,65.85350869,33.65902988,24.90421016,2.410679068]
    Time2=[50,100,250,500,1000,2500,5000]
    Intensity2=[2421.236129,1885.837742,1710.483871,1275.428387,776.0895806,192.4806452,26.35279]
    error2=[317.7694792,266.8600888,157.3938377,65.85350869,33.65902988,24.90421016,2.410679068]
    fig, ax = plt.subplots()
    ax.scatter(Time, Intensity, label="Measured", c='r',s=10)

    x2 = np.logspace(start=-1, stop=4, num=100)
    lam=3
    smooth_func = make_smoothing_spline(np.log(Time2), Intensity2, lam=lam)
    y2 = smooth_func(np.log(x2))
    ax.semilogx(x2, y2,label="Curve Fit Extrapolated")

    ax.set_ylim([0, 5500])
    ax.set_xlabel("Trapping time (ms)")
    ax.legend(loc="best")
    ax.set_ylabel("Average Intensity (counts/s)")
    ax.yaxis.set_minor_locator(MultipleLocator(100))
    ax.yaxis.tick_left()
    ax.yaxis.set_ticks_position('both')
    ax.xaxis.tick_bottom()
    ax.xaxis.set_ticks_position('both')
    ax.set_title("Average Intentsity Extrapolated vs Trapping Time after 30 Pulses",c='g')
    plt.errorbar(Time, Intensity, yerr=error ,fmt="o",c='r')
    ax.yaxis.set_minor_locator(MultipleLocator(100))
    print(delta)
    plt.grid()
    plt.show()

    Continue reading...

Compartilhe esta Página