Indium = [ Indium[0], [ Indium[1] / 240 - Nullmessung1, np.sqrt(Indium[1] - Nullmessung1 * 240) / 240 ] ] Rhodium = [ Rhodium[0], [ Rhodium[1] / 15 - Nullmessung2, np.sqrt(Rhodium[1] - Nullmessung2 * 15) / 15 ] ] IndiumErgebnisse = linregress(Indium[0], np.log(Indium[1][0])) print('Ergebnisse Indium', IndiumErgebnisse) s = unp.uarray(IndiumErgebnisse[0][0], IndiumErgebnisse[1][0]) print('Halbwertszeit Indium', -np.log(2) / s) funktionswertbei240sIn = s * 240 + unp.uarray(IndiumErgebnisse[0][1], IndiumErgebnisse[1][1]) print(r'N_0(1-e^-yT)', unp.exp(funktionswertbei240sIn) * 240) makeNewTable([ Indium[0], Indium[1][0], Indium[1][1], np.log(Indium[1][0]), abs(np.log(Indium[1][0] + Indium[1][1]) - np.log(Indium[1][0])), abs(np.log(Indium[1][0] - Indium[1][1]) - np.log(Indium[1][0])) ], r'{$\frac{t}{\si{\second}}$}&{$\frac{N}{\si[per-mode=reciprocal]{\per\second}}$}&{$\sigma=\sqrt{\frac{N}{240\si[per-mode=reciprocal]{\per\second}}}$}&{$\ln\left(\frac{N}{\si[per-mode=reciprocal]{\per\second}}\right)$}&{$\ln\left(\frac{N+\sigma}{\si[per-mode=reciprocal]{\per\second}}\right)-\ln\left(\frac{N}{\si[per-mode=reciprocal]{\per\second}}\right)$}&{$\ln\left(\frac{N}{\si[per-mode=reciprocal]{\per\second}}\right)-\ln\left(\frac{N-\sigma}{\si[per-mode=reciprocal]{\per\second}}\right)$}', 'Indium', [ r'S[table-format=4.0]', r'S[table-format=1.1]',
sigma1=abschirm(Z,EL1,EL3) print(sigma1,'sigma1') print('THEO =',abschirm(Z,energy(lamb(11.06*2)),energy(lamb(13.2*2)))) print('%',pro(abschirm(Z,energy(lamb(11.06*2)),energy(lamb(13.2*2))),sigma1)) #plot Germanium=[germanium,32] Strontium=[strontium,38] Zirkonium=[zirkonium,40] Er=[germanium,strontium,zirkonium] #Er=[11110,16120,18010] zr=[32,38,40] x=np.linspace(0,140,100) a,aerr,b,berr=linregress(np.sqrt(Er),zr) print(a,aerr,b,berr,'a,aerr,b,berr') plt.plot(np.sqrt(Er),zr,'ko',label="Daten") plt.plot(x,a*x+b,'k-',label="Gerade y=0.27 x (eV)^(-1/2) + 3.48") plt.xlabel(r'reduzierte Absorbtionsenergie $ \sqrt{E_k}\ / \ \mathrm{\sqrt{eV}}$') plt.ylabel(r'Kernzahl $ Z$') plt.xlim(100,140) plt.ylim(30,45) plt.legend(loc='best') plt.tight_layout() plt.grid() plt.savefig('plot_mosley.pdf') plt.close() ryd=ufloat(a,aerr) print(raute)
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit from linregress import linregress from uncertainties import ufloat from uncertainties import unumpy # a)gleiche Kapazitäten A ,F =np.genfromtxt('a_gleiche_Kapazitäten.txt',unpack=True) a,aerr,b,berr=linregress(A,F) print(a,b,'m,b zu Durchlasskurven gleiche Kapazität') x1=13.4 x2=14 xg=(13.4+14)/2 print(xg,'arithmetisches mittel') print(a*xg+b,'charakteristische Stelle a) erste Messung') L=1.75*10**-3 C=22*10**-9 print(2/(2*np.pi*(np.sqrt(L*C))),'Thoriewert a)1') x=np.linspace(0,18,1000) plt.plot(A,F, 'kx', label='Messwerte') plt.plot(x,a*x+b) plt.xlabel(r'$ Abstand \ / \ \mathrm{cm}$') plt.ylabel(r'$ Frequenz \ / \ \mathrm{Hz}$') plt.legend(loc='best') plt.tight_layout() plt.savefig('durchlass_1.pdf') plt.close()
kupfer=kupfer*10**-3-Uoffset schwarz=schwarz*10**-3-Uoffset print(schwarz,'schwarz') spiegel=spiegel*10**-3-Uoffset T_0=273.15+21.2 T=273.15+T print(T**4,'\n',T_0**4) Tdiff=T**4-T_0**4 print(Tdiff,'Tdiff') # print(Tdiff) #WEIẞ wepsi,wepsierr,wb,wberr=linregress(Tdiff,weiß) q=np.linspace(0,1.2e10,100) plt.plot(Tdiff,weiß,'kx',label='Messwerte') plt.plot(q,wepsi*q+wb,'k-',label='Ausgleichsgerade') plt.xlabel(r'$T^4-\,T_0^4 \ / \ \mathrm{K^4}$') plt.ylabel(r'$U \ / \ \mathrm{V}$') plt.legend(loc='best') plt.tight_layout() plt.savefig('plotWEISS.pdf') plt.close() #KUPFER kepsi,kepsierr,kb,kberr=linregress(Tdiff,kupfer)
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit from linregress import linregress from uncertainties import ufloat from uncertainties import unumpy #Klemmspannung b) ref,uk,uk_err,I,I_err =np.genfromtxt('Klemmspannung.txt',unpack=True) I=I*10**-3 I_err=I_err*10**-3 a,aerr,b,berr=linregress(I,uk) Ri1=ufloat(-a,aerr) U_01=ufloat(b,berr) print(a,aerr,b,berr,'a,aerr,b,berr zu Klemmspannung') plt.errorbar(I, uk, xerr=I_err, yerr=uk_err, fmt='rx', label='Fehler') x = np.linspace(0,0.075, 100) plt.plot(I,uk, 'kx', label='Messwerte') plt.plot(x,b+x*a,'k-',label='Ausgleichsgerade') plt.xlim(0,0.075) plt.xlabel(r'$ I \ / \ \mathrm{A}$') plt.ylabel(r'$ U_k \ / \ \mathrm{V}$') plt.legend(loc='best') plt.tight_layout() plt.savefig('plot1.pdf') plt.close()
import numpy as np import matplotlib.pyplot as plt from scipy.optimize import curve_fit from linregress import linregress import math as math from uncertainties import ufloat # p =np.genfromtxt('pb.txt', unpack = True) # t, T1 =np.genfromtxt('t1.txt', unpack = True) p,T1 =np.genfromtxt('LaLb.txt', unpack = True) T1=1/(T1+274.15) p=p*100000 p=np.log(p) print(linregress(T1, p)) plt.plot(T1, p, 'kx', label= 'log(p)') m,merr,b,berr=linregress(T1, p) x=np.linspace(0.003,0.0037,100) plt.plot(x,m*x+b, 'b-', label = '$log(p) gegen 1/T$') plt.grid() plt.xlabel('$1/T$ in $1/K$') plt.ylabel(r'$log(p)$') # plt.ylim(-5, 55) # plt.xlim(0, 1800) plt.tight_layout() plt.legend(loc = 'best') plt.savefig('dampfdruck.pdf') plt.show() mu= ufloat(m,merr) R=8.3144 a=mu*R L=-(mu*R)
from scipy import stats from uncertainties.unumpy import (nominal_values as noms, std_devs as stds) import uncertainties.unumpy as unp from linregress import linregress print('################################################################################a') ####################orange######################## Udata,Idata=np.genfromtxt('orange.txt',unpack=True) U=unp.uarray(Udata,0.005) I=unp.uarray(Idata*10**-9,0.1*10**-9) sqI=unp.uarray(np.sqrt(noms(I*10**9)),np.sqrt(0.001)) print('farbe',sqI) i=range(2,9) a,aerr,b,berr=linregress(noms(U[i]),noms(sqI[i]*10**-9)) x=np.linspace(noms(U[0]),noms(U[len(U)-1]),100) plt.errorbar(noms(U),noms(sqI),xerr=stds(U),yerr=stds(sqI),fmt='k+',label="Daten") plt.plot(x,a*x*10**9+b*10**9,'k-',label="Fit") plt.xlabel(r'Gegenspannung $ U\ / \ \mathrm{V}$') plt.ylabel(r'reduzierter Photostrom $ \sqrt{I}\ / \ \mathrm{\sqrt{nA}}$') plt.xlim(noms(U[0]),noms(U[len(U)-1])) plt.legend(loc='best') plt.tight_layout() plt.grid() plt.savefig('plotorange.pdf') plt.close() b=ufloat(b,berr) a=ufloat(a,aerr) print(a,b,'m,b')
# plt.xlabel(r'$v/\si{\centi\meter\per\second}$') # plt.ylabel(r'$\Delta f / \si{\hertz}$') # plt.legend(loc='best') # plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) # plt.savefig('build/'+'VgegenDeltaV') # a = unp.uarray(params[0], np.sqrt(covar[0][0])) # params = unp.uarray(params, np.sqrt(np.diag(covar))) # makeNewTable([convert((r'$c_\text{1}$',r'$c_\text{2}$',r'$T_{\text{A}1}$',r'$T_{\text{A}2}$',r'$\alpha$',r'$D_1$',r'$D_2$',r'$A_1$',r'$A_2$',r'$A_3$',r'$A_4$'),strFormat),convert(np.array([paramsGes2[0],paramsGes1[0],deltat2*10**6,deltat1*10**6,-paramsDaempfung[0]*2,4.48*10**-6 *paramsGes1[0]/2*10**3, 7.26*10**-6 *paramsGes1[0]/2*10**3, (VierteMessung-2*deltat2*10**6)[0]*10**-6 *1410 /2*10**3, unp.uarray((VierteMessung[1]-VierteMessung[0])*10**-6 *1410 /2*10**3, 0), unp.uarray((VierteMessung[2]-VierteMessung[1])*10**-6 *2500 /2*10**3, 0),unp.uarray((VierteMessung[3]-VierteMessung[2])*10**-6 *1410 /2*10**3, 0)]),unpFormat,[[r'\meter\per\second',"",True],[r'\meter\per\second',"",True],[r'\micro\second',"",True],[r'\micro\second',"",True],[r'\per\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'2.2f',True]]),convert(np.array([2730,2730]),floatFormat,[r'\meter\per\second','1.0f',True])+convert((r'-',r'-'),strFormat)+convert(unp.uarray([57,6.05,9.9],[2.5,0,0]),unpFormat,[[r'\per\meter',"",True],[r'\milli\meter',r'1.2f',True],[r'\milli\meter',r'1.2f',True]])+convert((r'-',r'-',r'-',r'-'),strFormat),convert(np.array([(2730-paramsGes2[0])/2730*100,(2730-paramsGes1[0])/2730*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-'),strFormat)+convert(np.array([(-paramsDaempfung[0]*2-unp.uarray(57,2.5))/unp.uarray(57,2.5)*100,(4.48*10**-6 *paramsGes1[0]/2*10**3-6.05)/6.05*100, (-7.26*10**-6 *paramsGes1[0]/2*10**3+9.90)/9.90*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-',r'-',r'-'),strFormat)],r'{Wert}&{gemessen}&{Literaturwert\cite{cAcryl},\cite{alphaAcryl}}&{Abweichung}','Ergebnisse', ['c ','c',r'c','c']) #a) Schallgeschwindigkeit Impuls-Echo-Verfahren l, t, t1 = np.genfromtxt('scripts/data1.txt', unpack=True) l = l / 100 t = t / (2 * 10**6) paramsLinear, errorsLinear, sigma_y = linregress(t, l) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) #paramsLinear, covar = curve_fit(linear, t, l) #errorsLinear = np.sqrt(np.diag(covar)) #steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) print('a)') print('c=', steigung) print('Abweichung in %:', (paramsLinear[0] - 2730) / 2730 * 100) print('Achsenabschnitt:', achsenAbschnitt) plt.cla() plt.clf() x_plot = np.linspace(0, 50)
from scipy import stats from curve_fit import ucurve_fit from uncertainties.unumpy import (nominal_values as noms, std_devs as stds) #a)RC U0=656e-3 U0a=1300e-3 # Uc,t =np.genfromtxt('aufladungdata.txt',unpack=True) Uc,t =np.genfromtxt('entladungdata.txt',unpack=True) Uc=Uc*10**-3 t*=10**-6 # uDiff=np.log(Uc/U0) # np.savetxt('uDiff.txt', np.column_stack([uDiff]), header='Uc/U0') a,aerr,b,berr=linregress(t,np.log(Uc/U0a)) print(a,aerr,b,berr,'a,aerr,b,berr') Rc1=-1/a RC=ufloat(-1/a,1/aerr) print(RC,'RC') print(Rc1,'Rc1') # slope, intercept, r_value, p_value, std_err = stats.linregress(t,np.log(Uc)) terr=20e-6 Ucerr=20e-3 plt.errorbar(t, Uc/U0a, xerr=terr, yerr=Ucerr, fmt='rx', label='Fehler') x = np.linspace(0,0.0035, 100) plt.plot(t,Uc/U0a, 'kx', label='Messwerte') plt.plot(x,np.exp(b+x*a),'k-',label='Ausgleichsgerade') # plt.xlim(0,0.075)
# plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) # plt.savefig('build/'+'VgegenDeltaV') # a = unp.uarray(params[0], np.sqrt(covar[0][0])) # params = unp.uarray(params, np.sqrt(np.diag(covar))) # makeNewTable([convert((r'$c_\text{1}$',r'$c_\text{2}$',r'$T_{\text{A}1}$',r'$T_{\text{A}2}$',r'$\alpha$',r'$D_1$',r'$D_2$',r'$A_1$',r'$A_2$',r'$A_3$',r'$A_4$'),strFormat),convert(np.array([paramsGes2[0],paramsGes1[0],deltat2*10**6,deltat1*10**6,-paramsDaempfung[0]*2,4.48*10**-6 *paramsGes1[0]/2*10**3, 7.26*10**-6 *paramsGes1[0]/2*10**3, (VierteMessung-2*deltat2*10**6)[0]*10**-6 *1410 /2*10**3, unp.uarray((VierteMessung[1]-VierteMessung[0])*10**-6 *1410 /2*10**3, 0), unp.uarray((VierteMessung[2]-VierteMessung[1])*10**-6 *2500 /2*10**3, 0),unp.uarray((VierteMessung[3]-VierteMessung[2])*10**-6 *1410 /2*10**3, 0)]),unpFormat,[[r'\meter\per\second',"",True],[r'\meter\per\second',"",True],[r'\micro\second',"",True],[r'\micro\second',"",True],[r'\per\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'2.2f',True]]),convert(np.array([2730,2730]),floatFormat,[r'\meter\per\second','1.0f',True])+convert((r'-',r'-'),strFormat)+convert(unp.uarray([57,6.05,9.9],[2.5,0,0]),unpFormat,[[r'\per\meter',"",True],[r'\milli\meter',r'1.2f',True],[r'\milli\meter',r'1.2f',True]])+convert((r'-',r'-',r'-',r'-'),strFormat),convert(np.array([(2730-paramsGes2[0])/2730*100,(2730-paramsGes1[0])/2730*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-'),strFormat)+convert(np.array([(-paramsDaempfung[0]*2-unp.uarray(57,2.5))/unp.uarray(57,2.5)*100,(4.48*10**-6 *paramsGes1[0]/2*10**3-6.05)/6.05*100, (-7.26*10**-6 *paramsGes1[0]/2*10**3+9.90)/9.90*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-',r'-',r'-'),strFormat)],r'{Wert}&{gemessen}&{Literaturwert\cite{cAcryl},\cite{alphaAcryl}}&{Abweichung}','Ergebnisse', ['c ','c',r'c','c']) N, U, I = np.genfromtxt('scripts/data1.txt', unpack=True) N_err = np.sqrt(N) N = N / 60 N_err = N_err / 60 N = unp.uarray(N, N_err) I = I / 10**6 #a) paramsLinear, errorsLinear, R = linregress(U[3:37], noms(N[3:37])) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) N_min = steigung * U[3] + achsenAbschnitt print('N_min =', N_min) print('Steigung des Plateaus =', steigung) print('Steigung des Plateaus in %/100V =', steigung / N_min * 100 * 100) print('Achsenabschnitt des Plateaus =', achsenAbschnitt) print('Länge des Plateaus =', U[36] - U[3]) plt.cla() plt.clf() x_plot = np.linspace(200, 800) plt.errorbar(U,
# plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) # plt.savefig('build/'+'VgegenDeltaV') # a = unp.uarray(params[0], np.sqrt(covar[0][0])) # params = unp.uarray(params, np.sqrt(np.diag(covar))) # makeNewTable([convert((r'$c_\text{1}$',r'$c_\text{2}$',r'$T_{\text{A}1}$',r'$T_{\text{A}2}$',r'$\alpha$',r'$D_1$',r'$D_2$',r'$A_1$',r'$A_2$',r'$A_3$',r'$A_4$'),strFormat),convert(np.array([paramsGes2[0],paramsGes1[0],deltat2*10**6,deltat1*10**6,-paramsDaempfung[0]*2,4.48*10**-6 *paramsGes1[0]/2*10**3, 7.26*10**-6 *paramsGes1[0]/2*10**3, (VierteMessung-2*deltat2*10**6)[0]*10**-6 *1410 /2*10**3, unp.uarray((VierteMessung[1]-VierteMessung[0])*10**-6 *1410 /2*10**3, 0), unp.uarray((VierteMessung[2]-VierteMessung[1])*10**-6 *2500 /2*10**3, 0),unp.uarray((VierteMessung[3]-VierteMessung[2])*10**-6 *1410 /2*10**3, 0)]),unpFormat,[[r'\meter\per\second',"",True],[r'\meter\per\second',"",True],[r'\micro\second',"",True],[r'\micro\second',"",True],[r'\per\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'2.2f',True]]),convert(np.array([2730,2730]),floatFormat,[r'\meter\per\second','1.0f',True])+convert((r'-',r'-'),strFormat)+convert(unp.uarray([57,6.05,9.9],[2.5,0,0]),unpFormat,[[r'\per\meter',"",True],[r'\milli\meter',r'1.2f',True],[r'\milli\meter',r'1.2f',True]])+convert((r'-',r'-',r'-',r'-'),strFormat),convert(np.array([(2730-paramsGes2[0])/2730*100,(2730-paramsGes1[0])/2730*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-'),strFormat)+convert(np.array([(-paramsDaempfung[0]*2-unp.uarray(57,2.5))/unp.uarray(57,2.5)*100,(4.48*10**-6 *paramsGes1[0]/2*10**3-6.05)/6.05*100, (-7.26*10**-6 *paramsGes1[0]/2*10**3+9.90)/9.90*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-',r'-',r'-'),strFormat)],r'{Wert}&{gemessen}&{Literaturwert\cite{cAcryl},\cite{alphaAcryl}}&{Abweichung}','Ergebnisse', ['c ','c',r'c','c']) pi = const.pi #1 print('1:') t, U = np.genfromtxt('scripts/data1.txt', unpack=True) t = (t-4.36)/1000 U_0 = 49.6 paramsLinear, errorsLinear, sigma_y = linregress(t, np.log(U/U_0)) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) print('Steigung =', steigung) print('Achsenabschnitt =', achsenAbschnitt) print('RC =', 1/steigung) plt.cla() plt.clf() x_plot = np.linspace(-1,5) plt.plot(t*1000, np.log(U/U_0), 'rx', label ="Messwerte") plt.plot(x_plot, x_plot/1000*paramsLinear[0], 'b-', label='Ausgleichsgerade') plt.xlim(-0.3,3.8) #plt.ylim(0,46)
x=c*100/b return 100-x #reflektion def reflek(s,t): return 2*s/t Lref,dt,amp =np.genfromtxt('data.txt',unpack=True) Lref*=1e-3 dt*=1e-6 c=reflek(Lref,dt) print (c,'reflek c m/s') x=np.linspace(0,90,100) dt*=1e6 a,aerr,b,berr=linregress(dt,2*Lref) print(a,aerr,b,berr,'a,aerr,b,berr') plt.plot(dt,2*Lref,'ko',label="Daten") plt.plot(x,a*x+b,'k-',label="Gerade y=2735e-6*x m/s -0.00022m") plt.xlabel(r'Laufzeit $ t\ / \ \mathrm{μ s}$') plt.ylabel(r'Durchschallte Strecke $ 2L\ / \ \mathrm{m}$') # plt.xlim(100,140) # plt.ylim(30,45) plt.legend(loc='best') plt.tight_layout() plt.grid() plt.savefig('plot_reflek.pdf') plt.close() gleitgel=ufloat(b,berr)
def G(x, m, s): return 1 / np.sqrt(2 * np.pi * s**2) * np.exp(-(x - m)**2 / (2 * s**2)) def P(x, m): return m**(x) / factorial(x) * np.exp(-m) #1) p, N1, c1 = np.genfromtxt('scripts/data1.txt', unpack=True) p = p / 1000 N1 = N1 / 60 E1 = 4 * 10**6 / c1[0] * c1[:17] x1 = 2.7 / 100 paramsLinear2, errorsLinear2, sigma_y = linregress( xeff(p, x1)[13:18], N1[13:18]) steigung2 = unp.uarray(paramsLinear2[0], errorsLinear2[0]) achsenAbschnitt2 = unp.uarray(paramsLinear2[1], errorsLinear2[1]) Rm1 = (N1[0] / 2 - achsenAbschnitt2) / steigung2 Ea1 = (Rm1 * 1000 / 3.1)**(2. / 3) * 10**6 print('1)') print('xeff1=', xeff(p, x1)[13]) print('xeff2=', xeff(p, x1)[17]) print('N1/2=', N1[0] / 2) print('steigung2=', steigung2) print('achsenabschhnitt2=', achsenAbschnitt2) print('Rm1 in m=', Rm1) print('Ea1 in eV=', Ea1) """
plt.plot(UB_24, I_24*10**6, 'yx', label=r'$I_\text{H} = \SI{2,4}{\ampere}$') plt.plot(UB_25, I_25*10**6, 'kx', label=r'$I_\text{H} = \SI{2,5}{\ampere}$') plt.xlabel(r'$U/\si{\volt}$') plt.ylabel(r'$I/\si{\micro\ampere}$') plt.legend(loc='best') plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) plt.savefig('content/images/IH_21-5.pdf') print('2,1-5 finished') """ #b) print('b)') UB_log = np.log(UB_25) I_log = np.log(I_25) paramsLinear, errorsLinear, sigma_y = linregress(UB_log, I_log) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) print('steigung:', steigung) print('Achsenabschnitt:', achsenAbschnitt) """ plt.cla() plt.clf() x_plot = np.linspace(2,6) plt.plot(UB_log, I_log, 'rx', label='Messwerte') plt.plot(x_plot, x_plot*paramsLinear[0]+paramsLinear[1], 'b-', label='Ausgleichsgerade') plt.xlim(2,6) plt.xlabel(r'$\log(U/\si{\volt})$') plt.ylabel(r'$\log(I/\si{\ampere})$') plt.legend(loc='best')
p, m1, m2, m3 = np.genfromtxt('scripts/BIgasMA.txt', unpack=True) makeNewTable([p, m1, m2, m3], r'{$p/\si{\milli\bar}$} & {$M_1$} & {$M_2$} & {$M_3$}', 'Luft', [ 'S[table-format=3.0]', 'S[table-format=2.0]', 'S[table-format=2.0]', 'S[table-format=2.0]' ], ['{:1.0f}', '{:1.0f}', '{:1.0f}', '{:1.0f}']) m = m1.tolist() + m2.tolist() + m3.tolist() m = np.array(m) p = p.tolist() p *= 3 p = np.array(p) n2 = unp.nominal_values(m * lambdavac / L + 1) #print(n2) params, error, sigmay = linregress(p, n2**2) fitparams = unp.uarray(params, error) print(fitparams) print("sigmay:", sigmay) pres = np.linspace(0, 1100, 1000) plt.cla() plt.clf() plt.plot(pres, nhoch2(pres, *params), 'b-', label='Fit') plt.plot(p, n2**2, 'rx', label='Messwerte') #plt.ylim(1, 1.0003) plt.xlim(0, 1100) plt.xlabel(r'$p/\si{\milli\bar}$') plt.ylabel(r'$n^2$') plt.legend(loc='best') plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) plt.savefig('build/' + 'luft')
print('Sigma_K entweder: ', SK1_array) print('...oder: ', SK2_array) print('Sigma_L: ', SL) SL_Referenz = 3.581316724 print('Fehler: ', (SL / SL_Referenz - 1) * 100, '%') EK_array = np.array([E_Br, E_Sr, E_Zn, E_Zr]) z_array = np.array([35, 38, 30, 40]) def mosley(x, a, b): return a * x + b params, covar, y_err = linregress(z_array, np.sqrt(EK_array)) a_uar = unp.uarray(params[0], covar[0]) b_uar = unp.uarray(params[1], covar[1]) Rydberg1 = 4 / 3 * params[0]**2 Rydbergfehler_abs = 3 / 2 * params[0] * covar[0] print('Mosley-Steigung: ', a_uar) print('Achsenabschnitt: ', b_uar) print('Rydberg: ', Rydberg1, 'mit dem Fehler: ', (Rydberg1 / E_R - 1) * 100, '%') print('absoluter Fehler von Rydberg: ', Rydbergfehler_abs) x_plot = np.linspace(28, 42) plt.cla() plt.clf() plt.plot(x_plot, mosley(x_plot, *params), 'b-', label='Ausgleichsgerade') plt.plot(z_array, np.sqrt(EK_array), 'rx', label='Messwerte')
def f(x,L): return 3*L**2*x-4*x**3 # np.savetxt('diffrechtf(x).txt', np.column_stack([f(ortr,LeingespR)]), header='g(x)in m^3') # np.savetxt('diffzylf(x).txt', np.column_stack([f(ortz,LeingespZ)]), header='g(x)') np.savetxt('diffzwei2f(x).txt', np.column_stack([f(uhr2ortzweis,LzweieingespR)]), header='g(x)') # np.savetxt('diffzwei2f(x).txt', np.column_stack([f(uhr2ortzweis,LzweieingespR/2)]), header='g(x)') def h(x,L): return 4*x**3-12*L*x**2+9*L**2*x-L**3 np.savetxt('diffzwei1f(x).txt', np.column_stack([h(uhr1ortzweis,LzweieingespR)]), header='g(x)') # fW1,fW1err,fW2,fW2err=linregress(f(ortr,LeingespR),rdiff) # fQ1,fQ1err,fQ2,fQ2err=linregress(f(ortz,LeingespZ),zdiff) hE1,hE1err,hE2,hE2err=linregress(h(uhr1ortzweis,LzweieingespR),zweidiff1) fE1_,fE1err_,fE2_,fE2err_=linregress(f(uhr2ortzweis,LzweieingespR),zweidiff2) W1,W1err,W2,W2err=linregress(g(ortr,LeingespR),rdiff) Q1,Q1err,Q2,Q2err=linregress(g(ortz,LeingespZ),zdiff) # E1,E1err,E2,E2err=linregress(f(uhr1ortzweis,LzweieingespR),zweidiff1) # E1_,E1err_,E2_,E2err_=linregress(h(uhr2ortzweis,LzweieingespR),zweidiff2) print('R=',W1) print('Z=',Q1) print('weiterweg hE1=',hE1) print('näheran null fE1=',fE1_)
plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) plt.savefig('content/images/fig2.pdf') makeTable([U1, UI1, U2, UI2], r'{' + r'$U_.{A1}/\si{\volt}$' + r'} & {' + r'$I_1/U_.{A1}$' + r'} & {' + r'$U_.{A2}/\si{\volt}$' + r'} & {' + r'$I_2/U_.{A2}$' + r'}', 'tabEnergieverteilung', [ 'S[table-format=1.2]', 'S[table-format=2.2]', 'S[table-format=1.2]', 'S[table-format=1.2]' ], ["%1.2f", "%2.2f", "%1.2f", "%1.2f"]) #b) print('b)') n, a = np.genfromtxt(r'scripts/data4.txt', unpack=True) a = a / 1000 * fb paramsLinear, errorsLinear, sigma_y = linregress(n, a) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) #k2 = a[0]/fb/dbm-steigung lambdaa = const.value("Planck constant") * const.c / ( steigung * const.value("electron volt")) print('U1 = ', steigung) print('b = ', achsenAbschnitt) print('lambda = ', lambdaa) #print('k = ', k2) plt.cla() plt.clf() x_plot = np.linspace(0, 8)
N_err2 = np.sqrt(N1 - N_0 * 30) / 30 N = N / 30 - N_0 N1 = N1 / 30 - N_0 N_log = np.log(N1) N_log_err = [ np.log(N1 + N_err2) - np.log(N1), np.log(N1) - np.log(N1 - N_err2) ] N = unp.uarray(N, N_err) N1 = unp.uarray(N1, N_err2) t = t * 30 t1 = t[t != 22 * 30] #print('N=', N) paramsLinear, errorsLinear, sigma_y = linregress(t1, N_log) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) print('Lambda=', -steigung) print('N0=', unp.exp(achsenAbschnitt)) print('tau1=', -np.log(2) / steigung) plt.cla() plt.clf() x_plot = np.linspace(0, 30 * 30 + 20) plt.errorbar(t1, N_log, yerr=[N_log_err[0], N_log_err[1]], fmt='rx',
x = 0.138 / 2 R = 0.109 #KugelWerte m_K = 142 / 1000 r_K = 5.33 / 200 J_K = 2 / 5 * m_K * r_K**2 #Gravitation r, I = np.genfromtxt("scripts/data1.txt", unpack=True) r = (r + 1.4 + 5.33 / 2) * 0.01 m = 1.4 / 1000 B = (N * mu_0 * I * R**2) / ((R**2 + x**2)**(3 / 2)) paramsLinear, errorsLinear, sigma_y = linregress(B, r) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) m_Dipol = m * g * steigung print('Gravitation:') print('Steigung =', steigung) print('Achsenabschnitt =', achsenAbschnitt) print('m_Dipol =', m_Dipol) plt.cla() plt.clf() x_plot = np.linspace(0, 5) plt.plot(B * 1000, r * 100, 'rx', label="Messwerte")
L = 17.5 / 100 N = 20 my = const.mu_0 D, I_350, I_250 = np.genfromtxt('scripts/data7.txt', unpack=True) D = D * 6.25 / 1000 r = D / (L**2 + D**2) #print(r) B_350 = my * 8 / np.sqrt(125) * N * I_350 / R B_250 = my * 8 / np.sqrt(125) * N * I_250 / R def rad(B, a, c): return a * B + c params1, covar1, sigma_y = linregress(B_350, r) params2, covar2, sigma_y = linregress(B_250, r) """ B_plot=np.linspace(0,22/10**5,1000) plt.cla() plt.clf() plt.plot(B_plot*10**5,rad(B_plot,*params2),'b-',label=r'Ausgleichsgerade:$U_\text{B} = \SI{250}{\volt}$') plt.plot(B_plot*10**5,rad(B_plot,*params1),'y-',label=r'Ausgleichsgerade:$U_\text{B} = \SI{350}{\volt}$') plt.plot(B_250*10**5, r, 'rx', label=r'Messwerte:$U_\text{B} = \SI{250}{\volt}$') plt.plot(B_350*10**5, r, 'gx', label=r'Messwerte:$U_\text{B} = \SI{350}{\volt}$') plt.ylabel(r'$\frac{D}{D^2+L^2}/\si{\metre}$') plt.xlabel(r'$B/10^{-5}\si{\tesla}$') plt.xlim(0,22) plt.legend(loc='best') plt.savefig('content/images/GraphMag1.pdf') """
[CountsKallibrierung[i - 1], CountsKallibrierung[i]]) PeakPos.append(nom) PeakPosStd.append(std) #print('PeakPos1',i,':', PeakPos[-1]) #print('PeakPos2',i,':',unp.uarray(*weighted_avg_and_sem([i-1,i],[CountsKallibrierung[i-1],CountsKallibrierung[i]]))) else: nom, std = weighted_avg_and_sem([i], [CountsKallibrierung[i]]) PeakPos.append(nom) PeakPosStd.append(std) PeakPos = unp.uarray(PeakPos, PeakPosStd) makeNewTable([convert(PeakPos, unpFormat, [r'', '', True])], r'\multicolumn{1}{c}{Kanal}', 'tab1', [r'S']) #print(PeakPos) time = np.linspace(0.9, 0.9 + len(PeakPos) - 1, len(PeakPos)) #print(time) params, std, sigmay = linregress(unp.nominal_values(PeakPos), time) uparams = unp.uarray(params, std) print('a:', uparams[0]) print('b:', uparams[1]) timeOffset = params[1] PeakPos2 = np.linspace(0, unp.nominal_values(PeakPos)[-1] * 1.02 + 1) plt.cla() plt.clf() plt.errorbar(unp.nominal_values(PeakPos), time, fmt='x', xerr=unp.std_devs(PeakPos), label='Messwerte') plt.plot(PeakPos2, line(PeakPos2, *params), 'r-', label='Fit') # plt.ylim(0, line(t[-1], *params)+0.1)
gelb_alternativ[0] *= 10**(-3) gelb_alternativ[1] *= 10**(-12) gruen[0] *= 10**(-3) gruen[1] *= 10**(-12) blaugruen[0] *= 10**(-3) blaugruen[1] *= 10**(-12) violett[0] *= 10**(-3) violett[1] *= 10**(-12) ultraV1[0] *= 10**(-3) ultraV1[1] *= 10**(-12) ultraV2[0] *= 10**(-3) ultraV2[1] *= 10**(-12) #a) Nullstellen = [] params, covar = linregress(gelb[0][gelb[0] >= 0][0:-1], np.sqrt(gelb[1][gelb[0] >= 0][0:-1])) params = unp.uarray(params, covar[0:-1]) Nullstelle = -params[1] / params[0] Nullstellen += [Nullstelle] print('Ugrenzgelb: ', Nullstelle) plt.cla() plt.clf() plt.plot(gelb[0][gelb[0] >= 0], np.sqrt(gelb[1][gelb[0] >= 0]) * 10**6, r'yx', label='Messwerte') x = np.linspace(-0.1, nom(Nullstelle) * 1.02, 1000) plt.plot(x, (nom(params[0]) * x + nom(params[1])) * 10**6, 'r', label='linearer Fit') #plt.ylim(0, line(t[-1], *params)+0.1)
# plt.tight_layout(pad=0, h_pad=1.08, w_pad=1.08) # plt.savefig('build/'+'VgegenDeltaV') # a = unp.uarray(params[0], np.sqrt(covar[0][0])) # params = unp.uarray(params, np.sqrt(np.diag(covar))) # makeNewTable([convert((r'$c_\text{1}$',r'$c_\text{2}$',r'$T_{\text{A}1}$',r'$T_{\text{A}2}$',r'$\alpha$',r'$D_1$',r'$D_2$',r'$A_1$',r'$A_2$',r'$A_3$',r'$A_4$'),strFormat),convert(np.array([paramsGes2[0],paramsGes1[0],deltat2*10**6,deltat1*10**6,-paramsDaempfung[0]*2,4.48*10**-6 *paramsGes1[0]/2*10**3, 7.26*10**-6 *paramsGes1[0]/2*10**3, (VierteMessung-2*deltat2*10**6)[0]*10**-6 *1410 /2*10**3, unp.uarray((VierteMessung[1]-VierteMessung[0])*10**-6 *1410 /2*10**3, 0), unp.uarray((VierteMessung[2]-VierteMessung[1])*10**-6 *2500 /2*10**3, 0),unp.uarray((VierteMessung[3]-VierteMessung[2])*10**-6 *1410 /2*10**3, 0)]),unpFormat,[[r'\meter\per\second',"",True],[r'\meter\per\second',"",True],[r'\micro\second',"",True],[r'\micro\second',"",True],[r'\per\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',"",True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'1.3f',True],[r'\milli\meter',r'2.2f',True]]),convert(np.array([2730,2730]),floatFormat,[r'\meter\per\second','1.0f',True])+convert((r'-',r'-'),strFormat)+convert(unp.uarray([57,6.05,9.9],[2.5,0,0]),unpFormat,[[r'\per\meter',"",True],[r'\milli\meter',r'1.2f',True],[r'\milli\meter',r'1.2f',True]])+convert((r'-',r'-',r'-',r'-'),strFormat),convert(np.array([(2730-paramsGes2[0])/2730*100,(2730-paramsGes1[0])/2730*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-'),strFormat)+convert(np.array([(-paramsDaempfung[0]*2-unp.uarray(57,2.5))/unp.uarray(57,2.5)*100,(4.48*10**-6 *paramsGes1[0]/2*10**3-6.05)/6.05*100, (-7.26*10**-6 *paramsGes1[0]/2*10**3+9.90)/9.90*100]),unpFormat,[r'\percent','',True])+convert((r'-',r'-',r'-',r'-'),strFormat)],r'{Wert}&{gemessen}&{Literaturwert\cite{cAcryl},\cite{alphaAcryl}}&{Abweichung}','Ergebnisse', ['c ','c',r'c','c']) def linear(x, A, B): return A * x + B a, T = np.genfromtxt("scripts/data1.txt", unpack=True) a = a * 0.01 paramsLinear, errorsLinear, sigma_y = linregress(a**2, T**2) steigung = unp.uarray(paramsLinear[0], errorsLinear[0]) achsenAbschnitt = unp.uarray(paramsLinear[1], errorsLinear[1]) print('Steigung =', steigung) print('Achsenabschnitt =', achsenAbschnitt) plt.cla() plt.clf() x_plot = np.linspace(0, 0.055) plt.plot(a**2, T**2, 'rx', label="Messwerte") plt.plot(x_plot, linear(x_plot, *paramsLinear), 'b-', label='Ausgleichsgerade') plt.xlim(0, 0.055) plt.ylim(0, 46) plt.xlabel(r'$a^2/\si{\metre\squared}$')
print('-----------------------------------Abbe---------------------------------------') babbedata=10 posA,Bild,gabbedata=np.genfromtxt('Messpaareabbe.txt',unpack=True) # L=np.ones(shape=(len(Bild),1)) L=1.65 gstrich=gabbedata-posA bstrich=posA-babbedata np.savetxt('gstrich.txt', np.column_stack([gstrich]), header='gstrich in cm') np.savetxt('bstrich.txt', np.column_stack([bstrich]), header='bstrich in cm') V=Abbildges(Bild,L) # print(V,'V') np.savetxt('V.txt', np.column_stack([V]), header='V ') a,aerr,b,berr=linregress(1+1/V,gstrich) a1,aerr1,b1,berr1=linregress(1+V,bstrich) # print(a,aerr,b,berr,'a,aerr,b,berr') # print(a1,aerr1,b1,berr1,'a1,aerr1,b1,berr1') x = np.linspace(1,1.6, 100) plt.plot(x,a*x+b, 'k-', label='Lineare Regression') plt.plot(1+1/V,gstrich, 'kx', label='Messwerte g\'') plt.xlabel(r'$ 1+\frac{1}{V} $') plt.ylabel(r'$ g\' / \ 10e-2 \, \mathrm{m}$') plt.xlim(1+1/V[0],1+1/V[len(V)-1]) plt.legend(loc='best') plt.tight_layout() plt.savefig('plotabb1.pdf') plt.close()
ti=np.array(np.zeros(len(ci))) tii=240 for i in range (0,len(ci)): ti[i]=240*(i+1) fehleri=np.sqrt(ci+(noms(Nnullind)*tii)) zähli=unp.uarray(ci-noms(Nnullind)*tii,fehleri) LNi=np.log(noms(zähli)) slnplusi=(np.log(noms(zähli)+stds(zähli)))-np.log(noms(zähli)) slnminusi=np.log(noms(zähli))-(np.log(noms(zähli)-stds(zähli))) np.savetxt('indi.txt', np.column_stack([ti,ci,noms(zähli),fehleri,LNi,slnplusi,slnminusi]), header='t #Nmess #Nw #sigmaNw #LN(Nw) #LN(Nw+sigmaNw) #LN(Nw-sigmaNw)') x=np.linspace(0,4100,100) a,aerr,b,berr=linregress(ti,noms(LNi)) print(a,aerr,b,berr,'a,aerr,b,berr') plt.errorbar(ti,(noms(LNi)),yerr=[(slnminusi),(slnplusi)],fmt='k+',label="Daten") plt.plot(x,(a*x+b),'k-',label="Fit") plt.xlabel(r'Zeit $ t\ / \ \mathrm{ s}$') plt.ylabel(r'ln(Zählrate) ') plt.xlim(ti[0],ti[len(ti)-1]) # plt.ylim(1000,3000) plt.legend(loc='best') plt.tight_layout() plt.grid() plt.savefig('plotindi.pdf') plt.close()