Example #1
0
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'))

# Aufgabe 3b
f_3b = npfarray([
    20.3, 40.4, 60.2, 80.1, 100.2, 120.0, 142.3, 165.0, 180.3, 200.5, 404.5,
    595.5, 802.5, 1006, 1206, 1404, 1603, 1784, 2025
])
f_3b_dsys = npfarray([
    0.1, 0.1, 0.2, 0.1, 0.3, 0.2, 0.2, 0.3, 0.3, 0.2, 0.3, 0.4, 1.5, 2, 2, 2,
    3, 4, 3
])
Example #2
0
r_k = 755e-9 / 2.
r_k_dsys = 30e-9 / 2.
T = npfarray([22.6, 23.0])
T_dsys = npfarray([0.1, 0.1])
T_mv = mv(T) + T0
T_dtot = dtot(dsys_mv(T_dsys), dsto_mv(T))
nu = 9.40e-4
nu_dsys = 0.05e-4

# Teilchenbewegung
pltext.initplot(num=1,
                title='Bewegung des Teilchens',
                xlabel='x in m',
                ylabel='y in m')
plt.plot(x, y, marker='s')
plt.savefig('fig1.pdf', format='pdf')

# mittleres Verschiebungsquadrat
r_sqr = dx**2 + dy**2
r_sqr_mv = mv(r_sqr)
r_sqr_dsto = dsto_mv(r_sqr)
dt_mv = mv(dt)
dt_dsto = dsto_mv(dt)

hist_D = r_sqr_mv / (4. * dt_mv)
hist_D_dtot = 1. / (4. * dt_mv) * sqrt(r_sqr_dsto**2 +
                                       (r_sqr_mv * dt_dsto / dt_mv)**2)
hist_kB = 6. * pi * nu * r_k * hist_D / T_mv
hist_kB_dtot = 6. * pi / T_mv * sqrt((nu_dsys * r_k * hist_D)**2 +
                                     (nu * r_k_dsys * hist_D)**2 +
Example #3
0
    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()
print('Kohärenzlänge LED:')
print(val('sigma', sigma, sigma_dtot))
print(val('L', L, L_dtot))

plt.show()
Example #4
0
fwhm_ka2o_err = 2 * sqrt(2 * ln(2)) * p_err_ka2o[2]

l_kb2o = d * sin(p_opt_kb2o[1] * deg_to_rad)
l_kb2o_err = d * cos(p_opt_kb2o[1] * deg_to_rad) * p_err_kb2o[1] * deg_to_rad
l_ka2o = d * sin(p_opt_ka2o[1] * deg_to_rad)
l_ka2o_err = d * cos(p_opt_ka2o[1] * deg_to_rad) * p_err_ka2o[1] * deg_to_rad

x_kb1o_array = nplinspace(8.5, 9.4)
x_ka1o_array = nplinspace(9.6, 10.7)
pltext.initplot(num=3,
                title='Abbildung   : Extrema erster Ordnung (LiF)',
                xlabel='Winkel in deg',
                ylabel='Zählrate in 1/s')
pltext.plotdata(alpha_1o, rate_1o, rate_1o_err, label='Messwerte')
plt.plot(x_kb1o_array,
         gauss(x_kb1o_array, *p_opt_kb1o),
         label=r'$K_\beta$ Fit')
plt.plot(x_ka1o_array,
         gauss(x_ka1o_array, *p_opt_ka1o),
         label=r'$K_\alpha$ Fit')
pltext.set_layout(xlim=(7.9, 11.1), ylim=(150, 1600))

x_kb2o_array = nplinspace(17.7, 18.8)
x_ka2o_array = nplinspace(20.1, 21.2)
pltext.initplot(num=4,
                title='Abbildung   : Extrema zweiter Ordnung (LiF)',
                xlabel='Winkel in deg',
                ylabel='Zählrate in 1/s')
pltext.plotdata(alpha_2o, rate_2o, rate_2o_err, label='Messwerte')
plt.plot(x_kb2o_array,
         gauss(x_kb2o_array, *p_opt_kb2o),
Example #5
0
fgr_fgang_dsys = npfarray([0.15, 0.15]) * 1e3
fgr_fgang_mv = mv(fgr_fgang)
fgr_fgang_mv_dtot = dtot_mv(fgr_fgang, fgr_fgang_dsys)
fgr_calc = 1 / (2 * pi * R_A3 * C_A3)
fgr_calc_dsys = 1 / (2 * pi * R_A3 * C_A3) * sqrt((R_A3_dsys / R_A3)**2 +
                                                  (C_A3_dsys / C_A3)**2)

f_array = linspace(1e3, 10e3, 1000)

pltext.initplot(num=1,
                title='Abbildung   : Phase in Abhängigkeit der Frequenz',
                xlabel='Frequenz in Hz',
                ylabel='Phase in rad',
                scale='loglin')
pltext.plotdata(f_A3, Phi, Phi_dsys, label='gemessene Phase')
plt.plot([1e3, 10e3], [pi / 4, pi / 4], label='45°')
plt.plot(f_array, phase_b(f_array), label='berechnet')
plt.plot(f_array, phase_b_dys(f_array), label='berechnet, Fehler')
plt.legend()

print()
print('Aufgabe 3:\n')
print(
    tbl([['Messgröße', 'bei 45° Phase', 'Frequenzgang', 'berechnet'],
         lst([fgr_phase, fgr_fgang_mv, fgr_calc],
             [fgr_phase_dsys, fgr_fgang_mv_dtot, fgr_calc_dsys],
             'f_gr in Hz')]))
print(
    sig('Phase/Fgang', fgr_phase, fgr_phase_dsys, fgr_fgang_mv,
        fgr_fgang_mv_dtot))
print(sig('Phase/calc ', fgr_phase, fgr_phase_dsys, fgr_calc, fgr_calc_dsys))
Example #6
0
chi2_pf = chi2stat.chi2(N_ag, N_ag_err, fitfunc_pf(t, *p_opt_pf))
chi2_red_pf = chi2stat.chi2_red(chi2_pf, len(N_ag), ddof=4)
prob_pf = chi2stat.fit_prob(chi2_pf, len(N_ag), ddof=4)

chi2_mf = chi2stat.chi2(N_ag, N_ag_err, fitfunc_mf(t, *p_opt_mf))
chi2_red_mf = chi2stat.chi2_red(chi2_mf, len(N_ag), ddof=4)
prob_mf = chi2stat.fit_prob(chi2_mf, len(N_ag), ddof=4)

t_array = nplinspace(0, 400)
pltext.initplot(num=1,
                title='Abbildung   : Zerfall von Silber',
                xlabel='Zeit in s',
                ylabel='# Zerfälle (mit Untergrund)',
                scale='linlog')
pltext.plotdata(t, N_ag, N_ag_err, label='Messwerte')
plt.plot(t_array, fitfunc(t_array, *p_opt), label='Fit')
plt.plot(t_array, fitfunc_pf(t_array, *p_opt_pf), label='Fit + Fehler Ug')
plt.plot(t_array, fitfunc_mf(t_array, *p_opt_mf), label='Fit - Fehler Ug')
pltext.set_layout(xlim=(0, 4e2), ylim=(2e1, 4e2))

print('\nSilber:\n')
print(val(unterg_ag_mv, unterg_ag_mv_dsto, name='Untergrund'))
print()
print(
    tbl([['', 'A1', 'l1', 'A2', 'l2'],
         [
             'Fitwerte',
             val(p_opt[0], p_err[0]),
             val(p_opt[1], p_err[1]),
             val(p_opt[2], p_err[2]),
             val(p_opt[3], p_err[3])
Example #7
0
# Einzelspaltbreite
lage_es_hmax = 499.79
lage_es_min = (npfarray([529.91, 561.26, 590.92, 623.13, 653.63]) -
               lage_es_hmax) * mpp
lage_es_max = (lage_es_hmax -
               npfarray([456.82, 424.68, 394.69, 363.78, 333.80])) * mpp
lage_es_d = npfarray([3, 3, 3, 3, 3]) * mpp
n_es = npfarray([1, 2, 3, 4, 5])

pltext.initplot(num=1,
                title='Position Extrema am Einzelspalt',
                xlabel='Ordnung',
                ylabel='Abstand')
[es_sl, es_dsl, es_itc, es_ditc] = linreg(n_es, lage_es_min, dy=lage_es_d)
plt.plot([0, 6], [es_itc, es_itc + 6 * es_sl])
pltext.plotdata(n_es, lage_es_min, dy=lage_es_d, label='Minima')
pltext.plotdata((lage_es_max - es_itc) / es_sl,
                lage_es_max,
                dx=lage_es_max / es_sl + n_es * (es_dsl / es_sl - 1) -
                (es_itc + es_ditc) / es_sl,
                label='Maxima')
plt.xlim((0.8, 6))
plt.ylim((0.0, 0.0014))
plt.legend(loc=2)

es_breite = schirmabstand * laser / es_sl
es_breite_err = schirmabstand * laser * es_dsl / es_sl**2
print()
print(val('ES Breite', es_breite, es_breite_err))
Example #8
0
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',
        sqrt_Er_alpha,
        Delta_sqrt_Er_alpha,
        sqrt_Er_lit,
        perc=True))
print(val('sig12', sig12_alpha, Delta_sig12_alpha))
print(sig('Abweichung', sig12_alpha, Delta_sig12_alpha, sig12_lit, perc=True))

# K_beta mit Ti
Example #9
0
t_1perc = 10**4 * k100 / k0**2 * (1 + k100 / k0)
k_delta = k100 - k0
k_delta_err = sqrt(k100_err**2 + k0_err**2)

t_array = nplinspace(50, 190)
pltext.initplot(num=2,
                title='Abbildung   : Ereignisse als Funktion der Zeit',
                xlabel='Zeit in s',
                ylabel='Ereignisse')
pltext.plotdata([60, 180], [N1min[0], N3min[0]],
                [N1min_dsto[0], N3min_dsto[0]],
                label=r'Messwerte $U_0+0V$')
pltext.plotdata([60, 180], [N1min[1], N3min[1]],
                [N1min_dsto[1], N3min_dsto[1]],
                label=r'Messwerte $U_0+100V$')
plt.plot(t_array, fitfunc_3(t_array, *p_opt_0), label=r'Fit $U_0 +0V$')
plt.plot(t_array, fitfunc_3(t_array, *p_opt_100), label=r'Fit $U_0 +100V$')
pltext.set_layout(xlim=(50, 190), ylim=(0.9e4, 3.1e4))

print('\nAufgabe 3\n')
print(
    val(anstieg_1min,
        anstieg_1min_dsto,
        name='abs Anstieg (1min)',
        percerr=True))
print(
    val(rel_anstieg_1min,
        rel_anstieg_1min_dsto,
        name='rel Anstieg (1min)',
        percerr=True))
print(
Example #10
0
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)
plt.plot(f_array, fitfunc(f_array, *popt), label='Fit')
pltext.set_layout(legend=True, xlim=(4e2, 1.2e5), ylim=(1e1, 2e3))


def fitfuncsquare(f, V, W1, W2, n1, n2):
    return fitfunc(f, V, W1, W2, n1, n2)**2


B = integrate.quad(fitfuncsquare, f[17], f[-45], args=tuple(popt))[0]
B_dsys = 0.02 * B

print(val(B, B_dsys, name='Integral'))

R = npfarray([5, 10, 15, 20, 25, 30]) * 1e3
R_dsys = 0.005 * R
U_aus = npfarray([2.4146, 3.1253, 3.7027, 4.2104, 4.6677, 5.0843]) * 1e-3