Lab 5 Python 3 Code and Figures
Lab 5 Python 3 Code and Figures
December 3, 2023
A = np.loadtxt("Pt 1 (A).txt")
B = np.loadtxt("Pt 1 (B).txt")
C = np.loadtxt("Pt 1 (C).txt")
D = np.loadtxt("Pt 1 (D).txt")
E = np.loadtxt("Pt 1 (E).txt")
F = np.loadtxt("Pt 1 (F).txt")
WA = A[:,0]
AA = A[:,1]
WB = B[:,0]
AB = B[:,1]
WC = C[:,0]
AC = C[:,1]
WD = D[:,0]
AD = D[:,1]
WE = E[:,0]
AE = E[:,1]
WF = F[:,0]
AF = F[:,1]
ax = plt.axes()
ax.plot(WA, AA, color = "black", label = "Solution A")
ax.plot(WB, AB, color = "orange", label = "Solution B")
ax.plot(WC, AC, color = "purple", label = "Solution C")
ax.plot(WD, AD, color = "pink", label = "Solution D")
ax.plot(WE, AE, color = "green", label = "Solution E")
ax.plot(WF, AF, color = "blue", label = "Solution F")
fs = 10
plt.xlabel("Wavelength [nm]", {"fontsize": fs})
1
plt.ylabel("Intensity [arb.]", {"fontsize": fs})
plt.title("Figure 1. Absorbance spectra of Cy7 Solutions", {"fontsize": fs});
ax.legend();
B = np.loadtxt("Pt 1 (B).txt")
WB = B[:,0]
AB = B[:,1]
MB = np.max(np.array([B[:,1]]))
print("The peak absorbance of Solution B was " + str(MB) + ".")
ax = plt.axes()
ax.plot(WB, AB, color = "orange", label = "Solution B")
ax.plot(B[450, 0], MB, "o", color = "red", label = "Peak Absorbance")
fs = 10
plt.xlabel("Wavelength [nm]", {"fontsize": fs})
plt.ylabel("Intensity [arb.]", {"fontsize": fs})
2
plt.title("Absorbance spectrum of Solution B", {"fontsize": fs});
ax.legend();
B = np.loadtxt("Pt 1 (B).txt")
C = np.loadtxt("Pt 1 (C).txt")
3
D = np.loadtxt("Pt 1 (D).txt")
E = np.loadtxt("Pt 1 (E).txt")
F = np.loadtxt("Pt 1 (F).txt")
MB = np.max(np.array([B[:,1]]))
MC = np.max(np.array([C[:,1]]))
MD = np.max(np.array([D[:,1]]))
ME = np.max(np.array([E[:,1]]))
MF = np.max(np.array([F[:,1]]))
ax = plt.axes()
ax.plot(TB, CyB, "o", color = "orange", label = "Solution B")
ax.plot(TC, CyC, "o", color = "purple", label = "Solution C")
ax.plot(TD, CyD, "o", color = "pink", label = "Solution D")
ax.plot(TE, CyE, "o", color = "green", label = "Solution E")
ax.plot(TF, CyF, "o", color = "blue", label = "Solution F")
ax.plot(T, decay(T, *pars), color = "red", label = "Curve Fit")
fs = 10
plt.xlabel("TCEP Concentration [$\mu$M]", {"fontsize": fs})
plt.ylabel("Cy7 Concentration [$\mu$M]", {"fontsize": fs})
plt.title("Figure 2. Titration of Cy7 and TCEP", {"fontsize": fs});
4
ax.legend();
C = np.loadtxt("Pt 2 (C2).txt")
tC = C[:,0]
AC = C[:,1]
tC_fit = tC[5:29]
AC_fit = AC[5:29]
pars, cov = curve_fit(f = decay, xdata = tC_fit, ydata = AC_fit, p0 = [1, 0,␣
↪0], bounds = (-np.inf, np.inf))
k1 = pars[2]
5
print("The reaction constant of the reaction is {} Hz.".format(k1))
fs = 10
ax = plt.axes()
ax.plot(tC, AC, color = "purple", label = "Solution C")
ax.plot(C[5, 0], C[5,1], "o", color = "red")
ax.plot(C[28, 0], C[28,1], "o", color = "red")
ax.plot(tC_fit, decay(tC_fit, *pars), color = "red", label = "Curve Fit")
plt.xlabel("Time [s]", {"fontsize": fs})
plt.ylabel("Intensity [arb.]", {"fontsize": fs})
plt.title("Figure 3. Absorbance decay of Solution C excited with UV light",␣
↪{"fontsize": fs});
ax.legend();
6
D = np.loadtxt("Pt 2 (D2).txt")
tD = D[:,0]
AD = D[:,1]
tD_fit = tD[31:59]
AD_fit = AD[31:59]
pars, cov = curve_fit(f = decay, xdata = tD_fit, ydata = AD_fit, p0 = [1, 0,␣
↪0], bounds = (-np.inf, np.inf))
k2 = pars[2]
fs = 10
ax = plt.axes()
ax.plot(tD, AD, color = "pink", label = "Solution D")
ax.plot(D[31, 0], D[31,1], "o", color = "red")
ax.plot(D[58, 0], D[58,1], "o", color = "red")
ax.plot(tD_fit, decay(tD_fit, *pars), color = "red", label = "Curve Fit")
plt.xlabel("Time [s]", {"fontsize": fs})
plt.ylabel("Intensity [arb.]", {"fontsize": fs})
plt.title("Figure 4. Absorbance decay of Solution D excited with UV light",␣
↪{"fontsize": fs});
ax.legend();
7
[35]: import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
E = np.loadtxt("Pt 2 (E2).txt")
tE = E[:,0]
AE = E[:,1]
tE_fit = tE[7:71]
AE_fit = AE[7:71]
pars, cov = curve_fit(f = decay, xdata = tE_fit, ydata = AE_fit, p0 = [1, 0,␣
↪0], bounds = (-np.inf, np.inf))
k3 = pars[2]
8
fs = 10
ax = plt.axes()
ax.plot(tE, AE, color = "green", label = "Solution E")
ax.plot(E[7, 0], E[7,1], "o", color = "red")
ax.plot(E[71, 0], E[71,1], "o", color = "red")
ax.plot(tE_fit, decay(tE_fit, *pars), color = "red", label = "Curve Fit")
plt.xlabel("Wavelength [nm]", {"fontsize": fs})
plt.ylabel("Intensity [arb.]", {"fontsize": fs})
plt.title("Figure 5. Absorbance decay of Solution E excited with UV light",␣
↪{"fontsize": fs});
ax.legend();
F = np.loadtxt("Pt 2 (F2).txt")
9
tF = F[:,0]
AF = F[:,1]
tF_fit = tF[10:60]
AF_fit = AF[10:60]
pars, cov = curve_fit(f = decay, xdata = tF_fit, ydata = AF_fit, p0 = [1, 0,␣
↪0], bounds = (-np.inf, np.inf))
k4 = pars[2]
fs = 10
ax = plt.axes()
ax.plot(tF, AF, color = "blue", label = "Solution F")
ax.plot(F[10, 0], F[10,1], "o", color = "red")
ax.plot(F[60, 0], F[60,1], "o", color = "red")
ax.plot(tF_fit, decay(tF_fit, *pars), color = "red", label = "Curve Fit")
plt.xlabel("Wavelength [nm]", {"fontsize": fs})
plt.ylabel("Intensity [arb.]", {"fontsize": fs})
plt.title("Figure 6. Absorbance decay of Solution F excited with UV light",␣
↪{"fontsize": fs});
ax.legend();
10
[37]: import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import curve_fit
ax = plt.axes()
ax.plot(1 / TC, 1 / k1, "o", color = "purple", label = "Solution C")
ax.plot(1 / TD, 1 / k2, "o", color = "pink", label = "Solution D")
ax.plot(1 / TE, 1 / k3, "o", color = "green", label = "Solution E")
ax.plot(1 / TF, 1 / k4, "o", color = "blue", label = "Solution F")
ax.plot(T, line(T, *pars), color = "red", label = "Curve Fit")
fs = 10
11
plt.xlabel("Inverse of TCEP Concentration [1/$\mu$M]", {"fontsize": fs})
plt.ylabel("Inverse of Reaction Constant [s]", {"fontsize": fs})
plt.title("Figure 7. Lineweaver-Burk plot for solutions C, D, E, and F",␣
↪{"fontsize": fs});
ax.legend();
[ ]:
12