# Aufgabe 3a w_3a = npfarray([0, 30, 60, 90]) w_3a_dsys = npfarray([2.5, 2.5, 2.5, 2.5]) Vss_3a = npfarray([1.48, 1.29, 0.73, 0.03]) Vss_3a_dsys = npfarray([0.03, 0.02, 0.01, 0.02]) Uind_3a = Vss_3a / 2 Uind_3a_dsys = Vss_3a_dsys / 2 def fitfunc_3a(w, B): return B * A_i * N_i * 2 * pi * 100 * cos(w * deg_to_rad) w_array = nplinspace(-10, 100) popt_3a, pcov_3a = curve_fit(fitfunc_3a, w_3a, Uind_3a, sigma=Uind_3a_dsys) B_3a = popt_3a[0] B_3a_dsys = sqrt(pcov_3a[0][0]) pltext.initplot( num=3, title='Abbildung : Induktionsspannung als Funktion des Winkels', xlabel='Winkel in deg', ylabel='Induktionsspannung in V') plt.plot(w_array, fitfunc_3a(w_array, *popt_3a), label=' Fit') pltext.plotdata(w_3a, Uind_3a, Uind_3a_dsys, w_3a_dsys, label=' Measurements') pltext.set_layout(legend=True, xlim=(-10, 100), ylim=(0, 0.8)) print('\nAufgabe 3a:\n') print(val(B_3a, B_3a_dsys, 'B'))
U_top.append(abs(kl_U[n])) lastmax = abs(kl_U[n]) t_top.append(kl_t[n]) lastn = n + 1 for n in range(lastn, len(kl_U)): if abs(kl_U[n]) >= np.max([abs(kl_U[j]) for j in range(n, len(kl_U))]): U_top.append(abs(kl_U[n])) t_top.append(kl_t[n]) def gauss(x, A, mu, sigma): return A * exp(-(x - mu)**2 / (2. * sigma**2)) popt, pcov = curve_fit(gauss, t_top, U_top) sigma = popt[2] sigma_dtot = sqrt(pcov[2][2]) t_int = npfarray([0.1e-2 * n for n in range(-30, 91)]) pltext.initplot(num=2, title='Signalverlauf LED', xlabel='Zeit in s', ylabel='Spannung in V') plt.plot(kl_t, kl_U, label='Messwerte') plt.plot(t_int, gauss(t_int, popt[0], popt[1], popt[2]), label='Gaußfit') L = 2. * kl_v * sigma * 2. * sqrt(2. * ln(2.)) L_dtot = 2. * kl_v * sigma_dtot * 2. * sqrt(2. * ln(2.)) print()
title=r'$\sqrt{E_\alpha}$ als Funktion von $Z$', xlabel=r'$Z$', ylabel=r'$\sqrt{E_\alpha}$ in $\sqrt{keV}$') pltext.plotdata(x=Z, y=sqrt_K_alpha, dy=Delta_sqrt_K_alpha) n1 = 1 n2 = 2 def fit_func_alpha(x, sqrt_Er, sig12): return sqrt_Er * (x - sig12) * sqrt(1 / n1**2 - 1 / n2**2) popt, pcov = curve_fit(fit_func_alpha, Z, sqrt_K_alpha, sigma=Delta_sqrt_K_alpha, p0=p0) sqrt_Er_alpha = popt[0] Delta_sqrt_Er_alpha = sqrt(pcov[0, 0]) sig12_alpha = popt[1] Delta_sig12_alpha = sqrt(pcov[1, 1]) plt.plot(Z, fit_func_alpha(Z, *popt)) print() print('K_alpha:') print(val('sqrt(Er)', sqrt_Er_alpha, Delta_sqrt_Er_alpha)) print( sig('Abweichung',
plt.xlim(-3, 3) plt.ylim(0, 0.6) plt.hist(d_all, density=True) plt.plot(points, gauss) plt.text(-2.41, 0.504, 'σ = ' + val('', sigma) + '\nμ = ' + val('', mu)) plt.savefig('fig2.pdf', format='pdf') # Kumulative Verteilung der Verschiebungsquadrate r_kum = np.cumsum(r_sqr) def lin(x, a, b): return a * x + b popt, pcov = curve_fit(lin, t[:-1], r_kum) slope = popt[0] yitc = popt[1] slope_dtot = sqrt(pcov[0][0]) yitc_dtot = sqrt(pcov[1][1]) vert_D = slope / 4. vert_D_dtot = slope_dtot / 4. vert_kB = 6. * pi * nu * r_k * vert_D / T_mv vert_kB_dtot = 6. * pi / T_mv * sqrt((nu_dsys * r_k * vert_D)**2 + (nu * r_k_dsys * vert_D)**2 + (nu * r_k * vert_D_dtot)**2 + (nu * r_k * vert_D * T_dtot / T_mv)**2) pltext.initplot(num=3, title='Kumulative Verteilung der Verschiebungsquadrate',
pltext.set_layout(xlim=(1e2, 1e6), ylim=(3e0, 2e3)) def fitfunc(f, V, W1, W2, n1, n2): return V / (np.sqrt(1 + 1 / (f / W1)**(2 * n1)) * np.sqrt(1 + (f / W2)**(2 * n2))) V = 1000 W1 = 1000 W2 = 50000 n1 = 5 n2 = 5 p0 = (V, W1, W2, n1, n2) popt, pcov = curve_fit(fitfunc, f[15:-43], g[15:-43], p0) print() print(val(popt[0], sqrt(pcov[0][0]), 'V')) print(val(popt[1], sqrt(pcov[1][1]), 'W1')) print(val(popt[2], sqrt(pcov[2][2]), 'W2')) print(val(popt[3], sqrt(pcov[3][3]), 'n1')) print(val(popt[4], sqrt(pcov[4][4]), 'n2')) pltext.initplot(num=2, title='Abbildung : Frequenzgang (Fit)', xlabel='Frequenz in Hz', ylabel='g(f)', scale='loglog') pltext.plotdata(f[17:-45], g[17:-45], label='Messwerte') f_array = nplinspace(4e2, 1.2e5)