예제 #1
0
def viskos():
    alpha = 1.024*10**(-9) #m**2/s**2
    rho = 1000 #Dichte von Wasser in kg/m³
    t = 920
    delta = [1.2, 0.9, 0.7, 0.5, 0.4]
    t2 = [600, 700, 800, 900, 1000]

    params, cov = curve_fit(linear, delta, t2 )
    errors = np.sqrt(np.diag(cov))

    delta_real = (t - params[1]) / params[0]
    #delta_real = 0.48
    x_range = np.linspace(0.4, 1.2)
    plt.plot(delta, t2, label='Daten')
    plt.plot(x_range, linear(x_range, *params), label='Fit')
    plt.xlabel(r'Parameter \delta / \si{second}')
    plt.ylabel(r'Zeit $t$ / $10^3$\si{\second}')
    plt.legend(loc='best')
    plt.savefig('build/test.pdf')
    plt.clf()

    make_table(header= ['$t$ / \\second', '\\delta / \\second'],
            places= [4.0, 1.1],
            data = [t2[0:3], delta[0:3]],
            caption = 'Werte zur Bestimmung der Referenzzeit $\delta$.',
            label = 'tab:viskos',
            filename = 'build/viskos.tex')
    print(delta_real)
    return rho*alpha*(t-delta_real)
예제 #2
0
def messung_T1():
    tau, M = np.genfromtxt('rohdaten/t1.txt', unpack=True) # tau in s und M in V

    params, cov = curve_fit(formel_T1, tau, M, p0 = [-640, 2])
    errors = np.sqrt(np.diag(cov))
    #print('Anfangsbedingung der Magnetisierung M0 = ', params[0] , ' +/- ', errors[0])
    print('Relaxationszeit T1 = ', np.round(params[1], 3), ' +/- ', np.round(errors[1], 3))
    print('Parameter M0 = ', np.round(params[0], 3), '+/-', np.round(errors[0], 3))
    #print('Parameter M1 = ', np.round(params[2], 3), '+/_', np.round(errors[2], 3))

    x_range = np.linspace(min(tau), max(tau), 100000)
    plt.plot(tau*1000, -M, 'bx', label='Messwerte')
    plt.plot(x_range*1000, -formel_T1(x_range, *params), 'r-', label='Fit')
    plt.ylabel(r'$U\:/\:\si{\volt}$')
    plt.xlabel(r'$\tau\:/\:\si{\milli\second}$')
    plt.xscale('log')
    plt.tight_layout()
    plt.legend(loc='best')
    plt.savefig('build/t1')
    plt.clf()

    make_table(header= ['$t$ / \\milli\\second', '$U$ / \\milli\\volt', '$t$ / \\milli\\second', '$U$ / \\milli\\volt', '$t$ / \\milli\\second', '$U$ / \\milli\\volt'],
            places= [2.1, 3.2, 3.2, 3.2, 4.1, 4.2],
            data = [tau[0:9]*1000, M[0:9]*1000, tau[10:20]*1000, M[10:20]*1000, tau[21:31]*1000, M[21:31]*1000],
            caption = 'Werte zur Bestimmung der longitudinalen Relaxationszeit $T_1$.',
            label = 'tab:T1',
            filename = 'build/T1.tex')
예제 #3
0
def diffusion(T2, g):
    tau, M = np.genfromtxt('rohdaten/diffusion.txt', unpack=True) # tau in s und M in V

    params, cov = curve_fit(diff_konst, tau, M, p0=[0.6, 1*10**(-9)])
    errors = np.sqrt(np.diag(cov))
    D = [params[1], errors[1]] #In m^2/s
    print('Diffusionskonstante: D = ', params[1], ' +/- ', errors[1])
    print('Parameter M0 = ', params[0], '+/-', errors[0])

    x_range = np.linspace(min(tau), max(tau))
    plt.plot(tau*1000, M, 'bx', label='Messwerte')
    plt.plot(x_range*1000, diff_konst(x_range, *params), 'r-', label='Fit')
    plt.ylabel(r'$U\:/\:\si{\volt}$')
    plt.xlabel(r'$\tau\:/\:\si{\milli\second}$')
    #  plt.xscale('log')
    plt.tight_layout()
    plt.savefig('build/diffussion')
    plt.clf()

    make_table(header= ['$t$ / \\milli\\second', '$U$ / \\milli\\volt', '$t$ / \\milli\\second', '$U$ / \\milli\\volt', '$t$ / \\milli\\second', '$U$ / \\milli\\volt'],
            places= [2.0, 3.2, 2.0, 3.2, 2.0, 3.2],
            data = [tau[0:6]* 1000, M[0:6]* 1000, tau[7:13]* 1000, M[7:13]* 1000, tau[14:20]* 1000, M[14:20]* 1000],
            caption = 'Werte zur Bestimmung der Diffusionskonstante.',
            label = 'tab:dif',
            filename = 'build/diff.tex')

    return D
예제 #4
0
def T2_Meiboom_Gill():
    tau, M = np.genfromtxt('rohdaten/mg_2.csv', unpack=True) # tau in s und M in V
    #find Minima for regression by using the negative values of M
    _, peaks = find_peaks(-M, height=0.13)
    peak_tau = []
    for i in _:
        peak_tau.append(tau[i])

    #do regression with formula 11 in the description
    params, cov = curve_fit(formel_T2, peak_tau, -peaks["peak_heights"])
    errors = np.sqrt(np.diag(cov))
    T2 = [params[1], errors[1]]
    print('Zeitkonstante T2 ist gegeben durch: T2 = ', np.round(params[1], 3), '+/-', np.round(errors[1],3))
    print('Parameter M0 = ', np.round(params[0], 3), '+/-', np.round(errors[0], 3))

    #print(len(peaks["peak_heights"]), len(peak_tau))
    plt.plot(peak_tau, -peaks["peak_heights"], 'bx', label='Peaks')
    plt.plot(tau, formel_T2(tau, *params), 'r-', label='Messwerte')
    plt.ylabel(r'$U\:/\:\si{\volt}$')
    plt.xlabel(r'$\tau\:/\:\si{\second}$')
    plt.legend(loc='best')
    plt.savefig('build/MG.pdf')
    plt.clf()

    print('Länge des Arrays: ', len(peaks), len(peak_tau))


    make_table(header= ['$t$ /  \\milli\\second', '$U$ /  \\milli \\volt', '$t$ /  \\milli\\second', '$U$ /  \\milli \\volt','$t$ /  \\milli\\second', '$U$ /  \\milli \\volt'],
            places= [1.1, 4.2, 2.1, 3.2, 2.1, 4.2],
            data = [tau[0:6]*1000, M[0:6]*1000, tau[7:13]*1000, M[7:13]*1000, tau[14:20]*1000, M[14:20]*1000],
            caption = 'Werte zur Bestimmung der transveralen Relaxationszeit $T_2$.',
            label = 'tab:MG',
            filename = 'build/MG.tex')

    return T2 # in s
예제 #5
0
def ui_characteristic():
    '''Strom-Spannungs-Kennlinie'''
    U, I = np.genfromtxt('rohdaten/ui-characteristic.txt', unpack=True)

    print('\tPlot UI-Characteristic')
    plt.axvspan(xmin=65, xmax=85, facecolor=tugreen, label=r'Mögliches $U_{\mathrm{Dep}}$')  # alpha=0.9
    plt.axvline(x=100, color='k', linestyle='--', linewidth=0.8, label=r'Anglegte $U_{\mathrm{Exp}}$')
    plt.plot(U, I, 'kx', label='Messwerte')
    plt.xlabel(r'$U\:/\:\si{\volt}$')
    plt.ylabel(r'$I\:/\:\si{\micro\ampere}$')
    plt.legend(loc='lower right')  # lower right oder best
    plt.tight_layout()
    plt.savefig('build/ui-characteristic.pdf')
    plt.clf()

    mid = len(U) // 2  # use modulo operator
    make_table(header= ['$U$ / \\volt', '$I$ / \\micro\\ampere', '$U$ / \\volt', '$I$ / \\micro\\ampere'],
            places= [3.0, 1.2, 3.0, 1.2],
            data = [U[:mid], I[:mid], U[mid:], I[mid:]],
            caption = 'Aufgenommene Strom-Spannungs-Kennlinie.',
            label = 'tab:ui-characteristic',
            filename = 'build/ui-characteristic.tex')
예제 #6
0
def eichung():
    '''Eichung der Magnetischen Flussdichte'''
    # Eichung des Elektromagneten
    I, B = np.genfromtxt('rohdaten/eichung.txt', unpack=True)
    params, covariance = curve_fit(eichfunktion, I, B)
    errors = np.sqrt(np.diag(covariance))
    print('Eichung')
    print(f'\ta_0 = {params[0]} ± {errors[0]}')
    print(f'\ta_1 = {params[1]} ± {errors[1]}')
    print(f'\ta_2 = {params[2]} ± {errors[2]}')
    print(f'\ta_3 = {params[3]} ± {errors[3]}')
    print(f'\ta_4 = {params[4]} ± {errors[4]}')

    # Plot
    x_plot = np.linspace(0, 20, 10000)
    plt.plot(I, B, 'kx', label='Messwerte')
    plt.plot(x_plot, eichfunktion(x_plot, *params), 'b-', label='Regression')
    plt.xlabel(r'$I\:/\:$A')
    plt.ylabel(r'$B\:/\:$mT')
    plt.tight_layout()
    plt.savefig('build/eichung.pdf')
    plt.clf()

    I_halb = len(I) // 2
    B_halb = len(B) // 2
    # Speichern der Messwerte
    make_table(
        header=[
            '$I$ / \\ampere', '$B$ / \milli\\tesla', '$I$ / \\ampere',
            '$B$ / \milli\\tesla'
        ],
        places=[2.1, 4.0, 2.1, 4.0],
        data=[I[:I_halb], B[:B_halb], I[I_halb:], B[B_halb:]],
        caption=
        'Magnetische Flussdichte in Abhängigkeit des angelegten Stroms.',
        label='tab:eichung',
        filename='build/eichung.tex')
    return params, errors
예제 #7
0
def test():
    # Import data from text files with numpy
    # x, y = np.genfromtxt('rohdaten/filename.txt', unpack=True)

    # test data
    U = np.array(range(20))
    I = np.linspace(1, 10, 20) * 2 + np.pi

    params, covariance = curve_fit(linear, U, I)
    errors = np.sqrt(np.diag(covariance))
    print('Strom-Spannungs-Kennlinie')
    print('\ta = {} ± {}'.format(params[0], errors[0]))
    print('\tb = {} ± {}'.format(params[1], errors[1]))

    # plot test data
    U_plot = np.linspace(0, 19, 10000)
    plt.plot(U_plot,
             linear(U_plot, *params),
             color=tugreen,
             linestyle='-',
             label='Regression',
             linewidth=0.8)
    plt.plot(U, I, 'kx', label='Messwerte')
    plt.xlabel(r'$U\:/\:\si{\volt}$')
    plt.ylabel(r'$I\:/\:\si{\milli\ampere}$')
    plt.legend(loc='best')
    plt.tight_layout()
    plt.savefig('build/ui-ui_characteristic.pdf')
    plt.clf()

    # save test data in latex table
    make_table(header=['$U$ / \\volt', '$I$ / \\micro\\ampere'],
               places=[2.0, 2.2],
               data=[U, I],
               caption='Aufgenommene Strom-Spannungs-Kennlinie.',
               label='tab:ui-characteristic',
               filename='build/ui-characteristic.tex')
예제 #8
0
파일: test.py 프로젝트: hvaztrk/FP_B_SS19
    )  # für Index 2 wird Potenz negativ wieso? dadurch Aktivität etc negativ
    Q_e.append(Z_e[i] / (omega_4pi * A_e[i] * W_e[i] / 100 * 4510))
print(Q_e)
print(potenz(noms(E_e_det), *params2))
# print(E_e_det)
# print(potenz(noms(E_e_det[11]),*params2))
#print(f'\nDaten zur Berechnung der Akivität: {E_e}, {params2}, \n den Peakinhalt Z {Z_e},\n die Effizienz Q {Q_e} \n und der Aktivität {A_e}')
# print('Aktivitäten des Nuklids', A_e)
# print('gemittelte Aktivität für das Salz: ', np.mean(A_e[0:9]))

make_table(
    header=[
        '$W_\\text{i}$\;/\;\si{\percent}', '$Q_\\text{i}$',
        '$Z_\\text{i}$ / \kilo\electronvolt',
        '$E_\\text{i}$ / \kilo\electronvolt', '$A_\\text{i}$ / \\becquerel'
    ],
    data=[W_e[3:], Q_e, Z_e, E_e[3:], A_e],
    places=[2.2, (1.3, 1.3), (4.2, 3.2), 4.1, (3.0, 2.0)],
    caption=
    'Berechnete Aktivität der betrachteten Emissionslinien mit dazu korrespondierenden Detektor-Effizienzen.',
    label='tab:aktivitaet_e',
    filename='build/tables/aktivitaet_e.tex')
make_table(header=[
    '$E_\\text{i}$ / \kilo\electronvolt', '$W_\\text{i}$\;/\;\si{\percent}',
    '$i$', '$E_\\text{i,fit}$ / \kilo\electronvolt'
],
           data=[E_e, W_e, peaks_ind_e,
                 lin(peaks_ind_e, *params_test)],
           places=[4.2, 2.2, 4.0, (4.2, 1, 2)],
           caption='Die ermittelten Peaks zur Nuklid Bestimmung.',
           label='tab:Salz',
           filename='build/tables/Salz_Peaks.tex')
예제 #9
0
def C_v(C_p, alpha, T):
    return C_p - 9 * alpha**2 * kappa * V_0 * T


#Fits für Ausdehnungskoeffizient und T-R-Charakteristik
T, alpha = np.genfromtxt(abs_path('data/alpha.txt'), unpack=True)
model_alpha = interp1d(T, alpha * 1e-6)

make_table(
    filename=abs_path('tabs/alpha.tex'),
    data=[
        np.split(T, 2)[0],
        np.split(alpha, 2)[0],
        np.split(T, 2)[1],
        np.split(alpha, 2)[1]
    ],
    header=[
        r'$T$ / \kelvin', r'$\alpha$ / 10^{-6}\per \kelvin', r'$T$ / \kelvin',
        r'$\alpha$ / 10^{-6}\per \kelvin'
    ],
    places=[3.0, 2.1, 3.0, 2.1],
    caption=
    r'Aus der Anleitung~\cite{anleitungV47} entnommene Wertepaare für $T$ und $\alpha$.',
    label='tab: alpha')

#def model_alpha(Temp):
#    T, alpha = np.genfromtxt(abs_path('data/alpha.txt'), unpack = True)
#    return np.interp(Temp, T, alpha)

#def func_alpha(T, a, b, c, d):
#    return a * T**3 + b * T**2 + c * T + d
#
예제 #10
0
def auswertung_rot(params, d_lambda_D):
    print('Auswertung rote Linie')
    lower = 1700
    upper = 33000

    ## sigma0A
    im_0 = imageio.imread('content/pictures/rot_sigma_0A.png')
    im_0 = im_0[:,:,0]  # r g b  also ist blau an position 2
    mitte_0 = im_0[len(im_0) // 2]
    peaks_0 = find_peaks(mitte_0[1900:upper], height=20, distance=50, prominence=20)
    peak_indices_0 = peaks_0[0] + 1900
    delta_s = np.diff(peak_indices_0)
    #  print(peak_indices_0)
    print(f'\t#Delta_s:  {len(delta_s)}')

    # plot
    x_plot_0 = np.array(range(len(mitte_0)))
    plt.plot(x_plot_0, mitte_0, 'k.')
    plt.plot(peak_indices_0, mitte_0[peak_indices_0], 'rx',label="Verwertete Daten")
    plt.xlabel('Pixel (horizontale Richtung)')
    plt.ylabel('Rotwert')
    plt.grid()
    plt.legend()
    plt.tight_layout()
    plt.savefig('build/rot_sigma_0A.pdf')
    plt.clf()

    ## Sigma
    im_1 = imageio.imread('content/pictures/rot_sigma_10A.png')
    im_1 = im_1[:,:,0]  # r g b  also ist blau an position 2
    mitte_1 = im_1[len(im_1) // 2]
    peaks_1 = find_peaks(mitte_1[lower:upper], height=20, distance=50, prominence=10)
    peak_indices_1 = peaks_1[0] + lower
    peak_diffs_1 = np.diff(peak_indices_1)
    del_s = peak_diffs_1[1::2]
    #  print(peak_indices_1)
    #  print(peak_diffs_1)
    print(f'\t#Del_s:  {len(del_s)}')

    # plot
    x_plot_1 = np.array(range(len(mitte_1)))
    plt.plot(x_plot_1, mitte_1, 'k.')
    plt.plot(peak_indices_1, mitte_1[peak_indices_1], 'rx',label="Verwertete Daten")
    plt.legend()
    plt.xlabel('Pixel (horizontale Richtung)')
    plt.ylabel('Rotwert')
    plt.grid()
    plt.tight_layout()
    plt.savefig('build/rot_sigma_10A.pdf')
    plt.clf()

    #  current = Q_(10, 'ampere')  # angelegter Strom
    current = 10  # angelegter Strom in ampere
    B_1 = eichfunktion(current, *params)
    print(f'\tB:  {B_1}')
    d_lambda = wellenlaengenAenderung(del_s, delta_s, d_lambda_D)
    delta_mg = g_factor(d_lambda, B_1, lambda_1)
    #  print(f'\tWellenlängenänderung:  {d_lambda}')
    #  print(f'\tDelta_mg:  {delta_mg}')
    #  print(f'\tMittelwert:  {sum(delta_mg)/len(delta_mg)}')
    print(f'\tMittelwert Delta_mg:  {sum(delta_mg)/len(delta_mg)}')

    # save results
    make_table(header= ['$\delta s$ / pixel', '$\Delta s$ / pixel', '$\delta\lambda$ / \pico\meter', '$g$'],
            places= [3.0, 3.0, 2.2, (1.2, 1.2)],
            data = [delta_s, del_s, d_lambda*1e12, delta_mg],
            caption = 'Werte zur Bestimmung des Lande-Faktors für die rote Spektrallinie.',
            label = 'tab:rot_sigma',
            filename = 'build/rot_sigma.tex')
예제 #11
0
def auswertung_blau(params, d_lambda_D):
    print('Auswertung blaue Linie')
    lower_sigma = 1500
    upper_sigma = 3250

    ## Image 0 - Sigma 0A
    im_0 = imageio.imread('content/pictures/blau_sigma_0A.JPG')
    im_0 = im_0[:,:,2]  # r g b  also ist blau an position 2
    mitte_0 = im_0[len(im_0) // 2]
    peaks_0 = find_peaks(mitte_0[2000:3450], height=20, distance=50, prominence=20)
    peak_indices_0 = peaks_0[0] + 2000
    delta_s_sigma = np.diff(peak_indices_0)
    print(f'\t#peak-indices:  {len(peak_indices_0)}')
    print(f'\t#Delta_s_sigma: {len(delta_s_sigma)}')

    ## Image 1 - Sigma 20A
    im_1 = imageio.imread('content/pictures/blau_sigma_20A.JPG')
    im_1 = im_1[:,:,2]  # r g b  also ist blau an position 2
    mitte_1 = im_1[len(im_1) // 2]
    peaks_1 = find_peaks(mitte_1[lower_sigma:upper_sigma], height=20, distance=10, prominence=10)
    peak_indices_1 = peaks_1[0] + lower_sigma
    peak_diffs_1 = np.diff(peak_indices_1)
    del_s_sigma = peak_diffs_1[:18:2]
    print(f'\t#peak-indices:  {len(peak_indices_1)}')
    #  print(f'\tdiffs: {peak_diffs_1}')
    print(f'\t#Del_s:  {len(del_s_sigma)}')

    # Berechnung Delta mg
    current_sigma = 20  # angelegter Strom in ampere
    B_sigma = eichfunktion(current_sigma, *params)
    print(f'\tB:  {B_sigma}')
    d_lambda_sigma = wellenlaengenAenderung(del_s_sigma, delta_s_sigma, d_lambda_D)
    delta_mg_sigma = g_factor(d_lambda_sigma, B_sigma, lambda_2)
    #  print(f'\tWellenlängenänderung:  {d_lambda_sigma}')
    #  print(f'\tDelta_mg:  {delta_mg_sigma}')
    print(f'\tMittelwert Delta_mg:  {sum(delta_mg_sigma)/len(delta_mg_sigma)}')

    # save results
    make_table(header= ['$\delta s$ / pixel', '$\Delta s$ / pixel', '$\delta\lambda$ / \pico\meter', '$g$'],
            places= [3.0, 2.0, 1.2, (1.2, 1.2)],
            data = [delta_s_sigma, del_s_sigma, d_lambda_sigma*1e12, delta_mg_sigma],
            caption = 'Werte zur Bestimmung des Lande-Faktors für die $\pi$-Aufspaltung der blauen Spektrallinie.',
            label = 'tab:blau_sigma',
            filename = 'build/blau_sigma.tex')

    # plot - Sigma 20A
    x_plot_1 = np.array(range(len(mitte_1)))
    plt.plot(x_plot_1, mitte_1, 'k.')
    plt.plot(peak_indices_1, mitte_1[peak_indices_1], 'rx',label="Verwertete Daten")
    plt.xlabel('Pixel (horizontale Richtung)')
    plt.ylabel('Blauwert')
    plt.grid()
    plt.legend()
    plt.tight_layout()
    plt.savefig('build/blau_sigma_20A.pdf')
    plt.clf()

    # plot - Sigma 0A
    x_plot_0 = np.array(range(len(mitte_0)))
    plt.plot(x_plot_0, mitte_0, 'k.')
    plt.plot(peak_indices_0, mitte_0[peak_indices_0], 'rx',label="Verwertete Daten")
    plt.xlabel('Pixel (horizontale Richtung)')
    plt.ylabel('Blauwert')
    plt.grid()
    plt.legend()
    plt.tight_layout()
    plt.savefig('build/blau_sigma_0A.pdf')
    plt.clf()

    print('\n\tPi-Linie')
    lower_pi = 1500
    upper_pi = 3300

    ## Image 2 - Pi 0A
    im_2 = imageio.imread('content/pictures/blau_pi_0A.JPG')
    im_2 = im_2[:,:,2]  # r g b  also ist blau an position 2
    mitte_2 = im_2[len(im_2) // 2]
    peaks_2 = find_peaks(mitte_2[lower_pi:upper_pi], height=20, distance=50, prominence=20)
    peak_indices_2 = peaks_2[0] + lower_pi
    delta_s_pi = np.diff(peak_indices_2)
    delta_s_pi =  delta_s_pi[1:-1]
    print(f'\t#peak-indices:  {len(peak_indices_2)}')
    #  print(f'\tDelta_s_pi:  {delta_s_pi}, Numer {len(delta_s_pi)}')
    print(f'\t#Delta_s_pi:  {len(delta_s_pi)}')

    ## Image 3 - Pi 6A
    im_3 = imageio.imread('content/pictures/blau_pi_6A.JPG')
    im_3 = im_3[:,:,2]  # r g b  also ist blau an position 2
    mitte_3 = im_3[len(im_3) // 2]
    peaks_3 = find_peaks(mitte_3[1700:upper_pi], height=15, distance=20, prominence=10)
    peak_indices_3 = peaks_3[0] + 1700
    #peak_indices_3 = peak_indices_3[1:]
    peak_diffs_3 = np.diff(peak_indices_3)
    del_s_pi = peak_diffs_3[2::2]
    print(f'\t#peak-indices:  {len(peak_indices_3)}')
    #  print(f'\tdiffs: {peak_diffs_3}')
    #  print(f'\tDel_s:  {del_s_pi}, Number {len(del_s_pi)}')
    print(f'\t#Del_s:  {len(del_s_pi)}')

    # Berechnung Delta mg
    current_pi = 6  # angelegter Strom in ampere
    B_pi = eichfunktion(current_pi, *params)
    print(f'\tB:  {B_pi}')
    d_lambda_pi = wellenlaengenAenderung(del_s_pi, delta_s_pi, d_lambda_D)
    delta_mg_pi = g_factor(d_lambda_pi, B_pi, lambda_2)
    #  print(f'\tWellenlängenänderung:  {d_lambda_pi}')
    #  print(f'\tDelta_mg:  {delta_mg_pi}')
    print(f'\tMittelwert Delta_mg:  {sum(delta_mg_pi)/len(delta_mg_pi)}')

    # save results
    make_table(header= ['$\delta s$ / pixel', '$\Delta s$ / pixel', '$\delta\lambda$ / \pico\meter', '$g$'],
            places= [3.0, 3.0, 1.2, (1.2, 1.2)],
            data = [delta_s_pi, del_s_pi, d_lambda_pi*1e12, delta_mg_pi],
            caption = 'Werte zur Bestimmung des Lande-Faktors für die $\sigma$-Aufspaltung der blauen Spektrallinie.',
            label = 'tab:blau_pi',
            filename = 'build/blau_pi.tex')

    # plot - Pi 0A
    x_plot_2 = np.array(range(len(mitte_2)))
    plt.plot(x_plot_2, mitte_2, 'k.')
    plt.plot(peak_indices_2, mitte_2[peak_indices_2], 'rx',label="Verwertete Daten")
    plt.xlabel('Pixel (horizontale Richtung)')
    plt.ylabel('Blauwert')
    plt.grid()
    plt.legend()
    plt.tight_layout()
    plt.savefig('build/blau_pi_0A.pdf')
    plt.clf()

    # plot - Pi 6A
    x_plot_3 = np.array(range(len(mitte_3)))
    plt.plot(x_plot_3, mitte_3, 'k.',linewidth=0.6)
    plt.plot(peak_indices_3, mitte_3[peak_indices_3], 'rx',label="Verwertete Daten")
    plt.xlabel('Pixel (horizontale Richtung)')
    plt.ylabel('Blauwert')
    plt.grid()
    plt.legend()
    plt.tight_layout()
    plt.savefig('build/blau_pi_6A.pdf')
    plt.clf()
예제 #12
0
from scipy.signal import find_peaks
from astropy.io import ascii
from tab2tex import make_table

if not os.path.isdir('build'):
    os.mkdir('build')
if not os.path.isdir('build/tables'):
    os.mkdir('build/tables')

#------------------------Aufgabenteil a) {Untersuchung des Eu-Spektrums}
data = np.genfromtxt('data/Eu.txt', unpack=True)
E, peaks_ind, W = np.genfromtxt('data/2_0/Eu.txt', unpack=True)
make_table(
    header=[' $E$ / \kilo\electronvolt', ' $W$ / \%', 'Bin-Index $i$'],
    data=[E, W, peaks_ind],
    places=[4.0, 2.1, 4.0],
    caption=
    'Gegebene Werte zur Kalibrierung des Germanium-Detektors \cite{anleitung}. Aufgelistet sind die jeweilige Energie, die Emissionswahrscheinlichkeit $W$ und der Bin Index $i$.',
    label='tab:anleitung_eu',
    filename='build/tables/anleitung_eu.tex')

peaks = find_peaks(data, height=5, distance=10)
indexes = peaks[0]
peak_heights = peaks[1]


#Energieeichung: Wird bei jeder Betrachtung eines Spektrums benötigt
#Lineare Funktion für Ausgleichsgeraden
def lin(x, m, b):
    return m * x + b

예제 #13
0
if not os.path.isdir('build/tables'):
    os.mkdir('build/tables')

#------------------------Aufgabenteil a)
print('--------------Aufgabenteil a)-------------')
data, E, dE = np.genfromtxt('data/Eu152.txt',
                            unpack=True)  #liest die Messdaten ein
E = unp.uarray(
    E, dE
)  # Erzeugt aus den Daten Messwerte inkl Fehler für die vereinfachte Fehlerrechnung mit uncertainties

# Erzeugt eine Tabelle aus den gegebenen Daten, beachte E ist Fehlerbehaftet
make_table(
    header=[' $E_\\text{i}$ / \kilo\electronvolt', '$i$'],
    data=[E, data],
    places=[(4.4, 1.4), 4.0],
    caption=
    'Gegebene Werte zur Kalibrierung des Germanium-Detektors \cite{referenz1}.',
    label='tab:zuordnung_eu',
    filename='build/tables/zuordnung_Eu.tex')


#Lineare Funktion für Ausgleichsgeraden
def lin(x, m, b):
    return m * x + b


# Linerare Fit mit gefitteten Kanalnummern zu Energie
params, covariance = curve_fit(lin, noms(index_f), noms(E))
errors = np.sqrt(np.diag(covariance))
print('Kalibrationswerte mit gefitteten Kanälen:')
print('Steigung m =', params[0], '±', errors[0])
예제 #14
0
if not os.path.isdir('build'):
    os.mkdir('build')
if not os.path.isdir('build/tables'):
    os.mkdir('build/tables')

#------------------------Aufgabenteil a) {Untersuchung des Eu-Spektrums}
data = np.genfromtxt('data/Eu152.txt', unpack=True)
# Ener, Wahr = np.genfromtxt('data/2_0/Test.txt', unpack=True)
E, dE, W, dW, peaks_ind = np.genfromtxt('data/2_0/Eu_Zuordnung.txt', unpack=True)
E = unp.uarray(E, dE)
W = unp.uarray(W, dW)
make_table(
        header = [' $E_\\text{i}$ / \kilo\electronvolt', ' $W_\\text{i}$\;/\;\si{\percent}', '$i$'],
        data = [E, W, peaks_ind],
        places = [(4.4, 1.4), (2.3, 1.3), 4.0],
        caption = 'Gegebene Werte zur Kalibrierung des Germanium-Detektors \cite{referenz1}.',
        label = 'tab:zuordnung_eu',
        filename = 'build/tables/zuordnung_Eu.tex'
        )
# Findet Peaks, zuordnung dann manuelle
# peaks = find_peaks(data, height=80 , distance=2)
# indexes = peaks[0]
# peak_heights = peaks[1]
# print(indexes)

#verwendete und nicht verwendete peaks
peaks_v = [309, 614, 740, 861, 1027, 1108, 1939, 2159, 2399, 2702, 2765, 3500] #entsprechen auch peaks_ind
peaks_n = [106, 218, 919]

#plot von EU mit Kanälen
x=np.linspace(1,8192,8192)
예제 #15
0
#ax.plot(z_plot, gauss(z_plot, *params), 'r-')
#ax.plot(z_plot, poly(z_plot), 'r-')
ax.set_xlabel(r'$z / \si{\milli\meter}$')
ax.set_ylabel(r'$B / \si{\milli\tesla}$')
ax.legend()
fig.savefig(abs_path('results/magnetfeld.pdf'),
            bbox_inches='tight',
            pad_inches=0)

make_table(
    filename=abs_path('tabs/magnetfeld.tex'),
    data=[z[:20], B[:20], z[20:], B[20:]],
    header=[
        r'$z$ / \milli\meter', r'$B$ / \milli\tesla', r'$z$ / \milli\meter',
        r'$B$ / \milli\tesla'
    ],
    places=[3.0, 3.0, 3.0, 3.0],
    caption=
    r'Messwerte der Magnetfeldmessung zur Bestimmung des maximalen Wertes für $B$. Hierbei bezeichnet $z$ die Verschiebung entlang der Symmetrieachse des Elektromagneten.',
    label='tab: messwerte_magnetfeld')

#GaAs rein, L = 5.11mm
L_undot = Q_(5.11, 'millimeter')

lam = np.genfromtxt(abs_path('data/wellenlängen.txt'), unpack=True)
lam = Q_(lam, 'micrometer')

theta_pB1, theta_pB2, theta_nB1, theta_nB2 = np.genfromtxt(
    abs_path('data/ga_as_undotiert.txt'), unpack=True)