You are on page 1of 2

import matplotlib.

pyplot as plt
from scipy import optimize
import numpy as np
V = [3.5,3.9]
E = [1.173,1.332]

def f(x, a): #linear fitting


return a*x
popt, p_cov= optimize.curve_fit(f, V, E,p0=[1.5])
print("Slope of the curve " +str(popt))
x = np.linspace(0,5,1000)
plt.xlabel("LLD")
plt.ylabel("Energy in KeV")

plt.scatter(V, E,marker = "*",c = "r",label='Data of highest peaks')


plt.title("E vs LLD")
plt.plot(x,f(x,*popt),"--", label='Fitted function')

#For other three peaks


LLD = [0.25,0.75,2.65]
Energy = []
for i in LLD:
Energy.append(f(i,*popt))
plt.scatter(LLD,Energy,marker = "o", c = "k", label = "Energy of other three peaks
of Co-60")

#For Cs
L_Cs = [0.1,0.25,0.6]
E_Cs = []
for i in L_Cs:
E_Cs.append(f(i,*popt))
plt.scatter(L_Cs,E_Cs,marker = "o", c = "b", label = "Energy of other three peaks
of Cs-60")

#For max peak of Cs


L_max = [2]
E_max = f(L_max[0],*popt)
plt.scatter(L_max,E_max ,marker = "o", c = "m", label = "Energy of max peak of Cs-
60")

plt.legend(loc = "upper left")


plt.show()
print(str(LLD)+ " and corresponding energies (for Co-60) " + str(Energy))
print(str(L_Cs)+ " and corresponding energies (for Cs-137) " + str(E_Cs))
print("Maximum energy peak for Cs at LLD = 2, from the fitted curve is "+
str(E_max))

#For Na-22
L_Na = [0.25,1.55,3.80]
E_Na = []
for i in L_Na:
E_Na.append(f(i,*popt))

#For Co-57
L_57 = [0.25,0.40]
E_57 = []
for i in L_57:
E_57.append(f(i,*popt))
plt.xlabel("LLD")
plt.ylabel("Energy in KeV")
plt.title("E vs LLD")
plt.plot(x,f(x,*popt),"--", label='Fitted function')
plt.scatter(L_Na,E_Na,marker = "o", c = "b", label = "Energy of all four peaks of
Na-22")
plt.scatter(L_57,E_57,marker = "*", c = "r", label = "Energy of all four peaks of
Co-57")
plt.legend(loc = "upper left")
plt.show()
print(str(L_Na)+ " and corresponding energies (for Na-22) " + str(E_Na))
print(str(L_57)+ " and corresponding energies (for Co-57) " + str(E_57))

You might also like