Ejemplo n.º 1
0
def absorb_zink(a, b, c, d, Z, winkel, imp, x_p, x_m, y_p, y_m, name):
    ###Peak detect

    kante = winkel[c + 2] + 0.5 * (winkel[c + 6] - winkel[c + 2])
    energie_k = brag_ener(kante, 1) * 1e-3
    sigma = absorbkoe(energie_k * 1e3, Z)

    print('Betrachte: ', name)
    print('winkel_min', winkel[c + 2])
    print('winkel_max', winkel[c + 6])
    print('Winkel K Kante', kante)
    print('Energie K Kante', energie_k)
    print('Abschirmkoef', sigma)
    print('\n\n\n')

    plt.clf()
    plt.plot(winkel, imp, 'rx', label=r'$Intensität$')
    #plt.axvline(winkel_max,ls='--', color='b',label=r'$\theta_{\mathrm{max}}$')
    #plt.axvline(winkel_min,ls='--', color='g',label=r'$\theta_{\mathrm{min}}$')
    plt.xlabel(r'$\theta \, \mathrm{in} \, \mathrm{deg}$')
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$')
    plt.grid()
    plt.xlim(winkel[0] - x_m, winkel[-1] + x_p)
    plt.ylim(min(imp) - y_m, max(imp) + y_p)
    plt.legend(loc='best', )

    plt.axes([0.207, 0.375, 0.3, 0.3])
    plt.plot(winkel[c:d], imp[c:d], 'rx')
    plt.title(r'$\mathrm{Vergrößerung \, der \, K-Kante}$')
    plt.xlim(winkel[c] - x_m, winkel[d] + x_p)
    plt.axvline(winkel[c + 6],
                ls='--',
                color='b',
                label=r'$\theta_{\mathrm{max}}$')
    plt.axvline(winkel[c + 2],
                ls='--',
                color='g',
                label=r'$\theta_{\mathrm{min}}$')
    plt.ylim(imp[c] - 15, imp[d] - 20)
    plt.legend(loc='best', fontsize=12)
    plt.grid()

    #plt.xticks([0, -0.1 , -0.2, -0.3], ['0', '-0.1', '-0.2', '-0.3'])
    #plt.yticks([0, 0.02 , 0.04 , 0.06,0.08, 0.1, 0.12, 0.14 ], ['0', '0.02', '0.04','0.06', '0.08' , '0.1', '0.12', '0.14'])

    plt.savefig(name + '.pdf')

    l.Latexdocument(name + '.tex').tabular(
        [winkel, imp],
        '{$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$}',
        [2, 0],
        caption=
        'Messwerte bei der Untersuchung des Absorptionsspektrums von $\ce{Zn}$.',
        label=name)
    return energie_k
Ejemplo n.º 2
0
def absorb(a, b, Z, winkel, imp, x_p, x_m, y_p, y_m, name):
    ###Peak detect
    maxi = max(imp[a:b])
    winkel_max = winkel[a:b][np.where(imp[a:b] == maxi)]

    mini = min(imp[a:b])
    winkel_min = winkel[a:b][np.where(imp[a:b] == mini)]
    kante = winkel_min + 0.5 * (winkel_max - winkel_min)
    energie_k = brag_ener(kante, 1) * 1e-3
    sigma = absorbkoe(energie_k * 1e3, Z)

    print('Betrachte: ', name)
    print('winekl min', winkel_min)
    print('winkel_max', winkel_max)
    print('Winkel K Kante', kante)
    print('Energie K Kante', energie_k)
    print('Abschirmkoef', sigma)
    print('\n\n\n')

    plt.clf()
    plt.plot(winkel, imp, 'rx', label=r'$Intensität$')
    plt.axvline(winkel_max,
                ls='--',
                color='b',
                label=r'$\theta_{\mathrm{max}}$')
    plt.axvline(winkel_min,
                ls='--',
                color='g',
                label=r'$\theta_{\mathrm{min}}$')
    plt.grid()
    plt.xlabel(r'$\theta \, \mathrm{in} \, \mathrm{deg}$', size=25)
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$', size=25)
    plt.xlim(winkel[0] - x_m, winkel[-1] + x_p)
    plt.ylim(min(imp) - y_m, max(imp) + y_p)
    plt.legend(loc='best', fontsize=20)
    plt.savefig(name + '.pdf')

    l.Latexdocument(name + '.tex').tabular(
        [winkel, imp],
        '{$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$}',
        [2, 0],
        caption=
        'Messwerte bei der Untersuchung des Emmissionspektrums von $\ce{Cu}$.',
        label=name)
    return energie_k
Ejemplo n.º 3
0
def auswertung_brag(winkel, inten, x_p, x_m, y_p, y_m, name):
    l.Latexdocument(name + '.tex').tabular(
        [
            winkel[0:len(winkel) // 2], inten[0:len(winkel) // 2],
            winkel[len(winkel) // 2 + 1:], inten[len(winkel) // 2 + 1:]
        ],
        '{$\\alpha_{\mathrm{Gl}} \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$} & {$\\alpha_{\mathrm{Gl}} \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$}',
        [1, 0, 1, 0],
        caption='Messwerte bei der Untersuchung der Bragg Bedingung.',
        label='bragg_test')
    plt.clf()
    plt.plot(winkel, inten, 'rx', label=r'$Intensität$')
    plt.axvline(winkel[np.argmax(inten)],
                ls='--',
                color='b',
                label=r'$Maximum$')
    plt.grid()
    plt.xlabel(r'$2 \theta \, \mathrm{in} \, \mathrm{deg}$')
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$')
    plt.xlim(winkel[0] - x_m, winkel[-1] + x_p)
    plt.ylim(min(inten) - y_m, max(inten) + y_p)
    plt.legend(loc='best')
    plt.savefig(name + '.pdf')
    return winkel[np.argmax(inten)]
Ejemplo n.º 4
0
print('Gerade B(I) Paramter: ', params_B)
I_lim = np.linspace(-0.2, 5.2, 100)
plt.plot(I_eich_steigend, B_eich_steigend, 'bx', label='Messwerte steigender Strom')
plt.plot(I_eich_fallend, B_eich_fallend, 'rx', label='Messwerte fallender Strom')
plt.plot(I_lim, F_1(I_lim, *params_1), '-b', label='Lineare Regression')
plt.xlim(I_eich_steigend[0], I_eich_steigend[-1])
plt.xlabel('$I$ in $A$')
plt.ylabel('$B$ in $mT$')
plt.ylim(-1500, 500)
plt.xlim(I_lim[0], I_lim[-1])
plt.grid()
plt.legend(loc='best')
plt.savefig('hysterese.pdf')

latex.Latexdocument('hysterese_tab.tex').tabular([I_eich_steigend, B_eich_steigend, B_eich_fallend[::-1] ],
'{$I_q$ in $\si{\\ampere}$} & {$B_{wachsend}$ in $\si{\milli \\tesla}$}  &  {$B_{fallend}$ in $\si{\milli \\tesla}$}', [1, 1, 1] ,
caption = 'Messung des magnetischen Feldes bei fallendem und steigendem Strom', label = 'tab: hysterese')


def B(I):
	return Q_(params_1[0] * I + params_1[1], 'millitesla')

#Bestimmung Widerstand
I_zink_raw, U_zink_raw = np.genfromtxt('uri_zink.txt', unpack=True)
I_zink = Q_(I_zink_raw, 'ampere')
U_zink = Q_(U_zink_raw, 'millivolt')
params_zink_R, cov_zink_R = curve_fit(F_1, I_zink.magnitude, U_zink.magnitude, sigma=0.1)
plt.clf()
I_lim = np.linspace(-0.2, 8.2, 100)
plt.plot(I_zink.magnitude, U_zink.magnitude, 'rx', label='Messwerte')
plt.plot(I_lim, F_1(I_lim, *params_zink_R), '-b', label='Lineare Regression')
Ejemplo n.º 5
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
from pint import UnitRegistry
import scipy.constants as const
import latex as l
r = l.Latexdocument('plots.tex')
u = UnitRegistry()
Q_ = u.Quantity
import pandas as pd
from pandas import Series, DataFrame
from scipy.signal import find_peaks

# Import measurment datas
channel_content_ca = np.genfromtxt('./2018-10-29_becker_grisard/caesium.txt',
                                   unpack=True)

# --- Import params to transform binnumber to energy ---#
params, errors = np.genfromtxt('./umrechnungen_bins_to_energy.txt',
                               unpack=True)
m = ufloat(params[0], errors[0])
b = ufloat(params[1], errors[1])


def g(x, m, b):
    return m * x + b
Ejemplo n.º 6
0
print('RC in Teil a',1/params_a_u)
print('\n')

def ger (x,m,b):
	return m*x+b

params_a2,covariance_a2=curve_fit(ger,t,np.log(u_a))
error_params_a2=np.sqrt(np.diag(covariance_a2))
print(params_a2)
print(error_params_a2)
params_a_u=ufloat(params_a2[0],error_params_a2[1])
print('RC in Teil a, linearer Fit',1/params_a_u)
print('\n')

latex.Latexdocument('abgelesene_werte_teila.tex').tabular([t, u_a],
r'{$t$ in $\si{\milli\second}$} & {$U\ua{ein}$ in $\si{\volt}$}', [1, 1],
caption = r'Aus der Grafik \ref{fig:entladekurve} bestimmte Messwerte', label = 'tab:teil_a_spannungen')
##teilb

f, u_c, u_g = np.genfromtxt('u_c_und_u_g.txt',unpack=True)
f= f*u.hertz
u_c= 0.5*u_c* u.volt
u_g =0.5*u_g* u.volt

u_c_normierung=u_c/u_g
print('Verhältnis Uc/Ug', u_c_normierung)
print('\n')

def fit(x,a):
	return 1/(np.sqrt(1+(2*np.pi*x)**2*a**2))
Ejemplo n.º 7
0
        r'$\sqrt{I_{\mathrm{p}}} \, \, \mathrm{in} \, \, \sqrt{\mathrm{nA}}$',
        size=25)
    #plt.show()
    plt.savefig(name + '.pdf')
    return messwerte


###Gelb

result_gelb = auswertung((-1) * u_gelb_brems, i_gelb_brems, 'gelbem', 0.08,
                         0.01, 0.1)

l.Latexdocument('gelb.tex').tabular(
    [(-1) * u_gelb_brems.magnitude, i_gelb_brems.magnitude,
     np.sqrt(i_gelb_brems.magnitude)],
    '{Bremsspannung $U$ in $\si{\\volt}$} & {Photostrom $I_{\map{p}}$ in $\si{\\nano\\ampere}$} & {Photostrom $\sqrt{I_{\map{p}}}$ in $\sqrt{\si{\\nano\\ampere}}$}',
    [3, 3, 3],
    caption='Gemessener Photostrom bei gelbem Licht',
    label='gelb')

l.Latexdocument('gelb_all.tex').tabular(
    [u_gelb.magnitude, i_gelb.magnitude],
    '{Spanung $U$ in $\si{\\volt}$} & {Photostrom $I_{\map{p}}$ in $\si{\\nano\\ampere}$}',
    [3, 3],
    caption='Gemessener Photostrom bei gelbem Licht',
    label='gelb_all')

### grün
u_gruen, i_gruen = np.genfromtxt('grün.txt', unpack=True)
u_gruen = Q_(u_gruen, 'volt')
i_gruen = Q_(i_gruen, ' nanoampere')
Ejemplo n.º 8
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
import math
from scipy.optimize import curve_fit
from pint import UnitRegistry
import latex as l
r = l.Latexdocument('results.tex')
u = UnitRegistry()
Q_ = u.Quantity
import os
from tab2tex import make_table


def abs_path(filename):
    return os.path.join(os.path.dirname(__file__), filename)


import matplotlib as mlp
mlp.use('pgf')
import matplotlib.pyplot as plt
from matplotlib import rcParams

rcParams['font.family'] = 'serif'
rcParams['font.serif'] = '[lmroman10-regular]:+tlig;'
rcParams['text.usetex'] = True
rcParams['pgf.texsystem'] = 'lualatex'
rcParams['font.size'] = 10
Ejemplo n.º 9
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
import math
from scipy.optimize import curve_fit
from pint import UnitRegistry
import latex as l
r = l.Latexdocument('results.tex')
u = UnitRegistry()
Q_ = u.Quantity
import os
from scipy.integrate import quad
from pandas import DataFrame
from scipy.interpolate import interp1d
from tab2tex import make_table


def abs_path(filename):
    return os.path.join(os.path.dirname(__file__), filename)


def noise(y):
    error_y = np.random.normal(0, 0.01, size=len(y))
    return y + error_y


import matplotlib as mlp
mlp.use('pgf')
Ejemplo n.º 10
0

def weg_lambda(weg, anzahl):
    return (2 * weg) / (anzahl)


wellenlänge = weg_lambda(weg, anzahl_weg)
wellenlänge_u = unp.uarray(np.mean(wellenlänge),
                           np.std(wellenlänge) / np.sqrt(len(wellenlänge)))
print('Wellenlänge', wellenlänge_u)
print(wellenlänge)
print(anzahl_weg)

l.Latexdocument('abstands_messung.tex').tabular(
    [weg * 1e3, anzahl_weg, wellenlänge * 1000],
    '{Weg in $\si{\meter}$} &{Anzahl} & {Wellenlänge in $\si{\\nano\meter}$}',
    [2, 0, 9],
    caption='Messergebnisse bei der Abstandsmessung',
    label='tab: messwerte_abstand')

##Brechungsindex_luft

druck_luft, anzahl_luft = np.genfromtxt('anzahl_luft.txt', unpack=True)
druck_kohlenstoff, anzahl_kohlenstoff = np.genfromtxt('anzahl_kohlenstoff.txt',
                                                      unpack=True)


def delta_brechungsindex(anzahl, wellenlaenge):
    return (anzahl * wellenlaenge) / (2 * 0.05)


def brechungsindex(deltadruck, deltabrechung):
Ejemplo n.º 11
0
def absorb_gold(a, b, Z, winkel, imp, x_p, x_m, y_p, y_m, name):
    ###Peak detect
    winkel_l2 = winkel[17]
    winkel_l3 = winkel[39]

    maxi_l2 = winkel[17]
    mini_l2 = winkel[12]

    maxi_l3 = winkel[39]
    mini_l3 = winkel[33]

    kante_l2 = mini_l2 + 0.5 * (maxi_l2 - mini_l2)
    energie_l2_neu = brag_ener(kante_l2, 1) * 1e-3

    kante_l3 = mini_l3 + 0.5 * (maxi_l3 - mini_l3)
    energie_l3_neu = brag_ener(kante_l3, 1) * 1e-3

    energie_l2 = brag_ener(winkel_l2, 1) * 1e-3
    energie_l3 = brag_ener(winkel_l3, 1) * 1e-3
    delta_e = (energie_l2 - energie_l3)
    abschirm_kosnt = abschirm(Z, delta_e * 1e3)
    abschirm_kosnt_neu = abschirm(Z, (energie_l2_neu - energie_l3_neu) * 1e3)

    print('Betrachte: ', name)
    print('Winkel L2 Kante,max / min', kante_l2, mini_l2)
    print('Winkel L3 Kante, max / min', kante_l3, mini_l3)
    print('Energie L2 Kante', energie_l2, energie_l2_neu)
    print('Energie L3 kante', energie_l3, energie_l3_neu)
    print('Abschirm Konstante', abschirm_kosnt, abschirm_kosnt_neu)
    print('\n\n\n')

    plt.clf()
    plt.plot(winkel[:-1], imp[:-1], 'rx', label=r'$Intensität$')

    plt.axvline(winkel_l3,
                ls='--',
                color='b',
                label=r'$L_3 \, \theta_{\mathrm{max}}$')
    plt.axvline(mini_l3,
                ls='--',
                color='b',
                label=r'$L_3 \, \theta_{\mathrm{min}}$')

    plt.axvline(winkel_l2,
                ls='--',
                color='g',
                label=r'$L_2 \, \theta_{\mathrm{max}}$')
    plt.axvline(mini_l2,
                ls='--',
                color='y',
                label=r'$L_2 \, \theta_{\mathrm{min}}$')

    plt.xlabel(r'$\theta \, \mathrm{in} \, \mathrm{deg}$')
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$')
    plt.grid()
    plt.xlim(winkel[0] - x_m, winkel[-2] + x_p)
    plt.ylim(min(imp[:-1]) - y_m, max(imp[:-1]) + y_p)
    plt.legend(loc='best', )
    plt.savefig(name + '.pdf')
    l.Latexdocument(name + '.tex').tabular(
        [
            winkel[:len(winkel) // 2], imp[:len(winkel) // 2],
            winkel[len(winkel) // 2:], imp[len(winkel) // 2:]
        ],
        '{$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$} & {$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$}',
        [2, 0, 2, 0],
        caption=
        'Messwerte bei der Untersuchung des Absorptionsspektrums von $\ce{Au}$..',
        label=name)
Ejemplo n.º 12
0
def peak(int_1, int_2, winkel, imp, x_p, x_m, y_p, y_m, name):
    dic = {}
    ###Peak detect
    max_1 = max(imp[int_1[0]:int_1[1]])
    winkel_1 = winkel[np.where(imp == max_1)]

    max_2 = max(imp[int_2[0]:int_2[1]])
    winkel_2 = winkel[np.where(imp == max_2)]

    plt.clf()
    plt.plot(winkel, imp, 'rx', label=r'$Intensität$')
    plt.axvline(winkel_2, ls='--', color='b', label=r'$K_{\alpha}$')
    plt.axvline(winkel_1, ls='--', color='g', label=r'$K_{\beta}$')
    plt.grid()
    plt.xlabel(r'$\theta \, \mathrm{in} \, \mathrm{deg}$')
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$')
    plt.xlim(winkel[0] - x_m, winkel[-2] + x_p)
    plt.ylim(min(imp) - y_m, max(imp) + y_p)
    plt.legend(loc='best')
    plt.savefig(name + '.pdf')
    print(len(winkel) // 3)

    l.Latexdocument(name + '.tex').tabular(
        [
            winkel[0:len(winkel) // 3], imp[0:len(winkel) // 3],
            winkel[len(winkel) // 3:len(winkel) // 3 * 2],
            imp[len(winkel) // 3:len(winkel) // 3 * 2],
            winkel[len(winkel) // 3 * 2:], imp[len(winkel) // 3 * 2:]
        ],
        '{$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$} & {$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$} &{$\\theta \, / \, \si{\\degree}$} & {$I \, / \, \mathrm{Imp}/\mathrm{s}$}',
        [2, 0, 2, 0, 2, 0],
        caption=
        'Messwerte bei der Untersuchung des Emmissionspektrums von $\ce{Cu}$.',
        label='emi_cu')

    ###grenzwinkel
    lam_1 = brag_well(winkel_1, 1)
    lam_2 = brag_well(winkel_2, 1)
    dic['Wellenlänge'] = lam_1
    e_1 = brag_ener(winkel_1, 1)
    e_2 = brag_ener(winkel_2, 1)
    dic['Energie_k_beta'] = e_1
    dic['Energie_k_alpha'] = e_2
    sigma_1 = absorbkoe(e_1, 29)
    sigma_2 = absorbkoe(4 * (-e_2 + e_1), 29)

    print('Betrachte: ', name)
    print('Energie k_beta', e_1)
    print('Energie k_alpha', e_2)
    print('Sigma 1', sigma_1)
    print('Sigma 2', sigma_2)
    print('Maximale Energie', brag_ener(winkel[0], 1))
    print('\n\n\n')

    ## Bestimmung der Halbwertsbreite

    #K_alpha peak, Winkel 1

    def g(m, x, b):
        return m * x + b

    imp_winkel1_partner = imp[np.where(imp == max_1)[0][0] - 1]
    winkel_1_fit_partner = winkel[np.where(imp == max_1)[0][0] - 1]

    parms_winkel1, cov_winkel1 = curve_fit(
        g, [winkel_1_fit_partner, winkel_1[0]],
        [imp_winkel1_partner, imp[np.where(imp == max_1)][0]])
    error_winkel1 = np.sqrt(np.diag(cov_winkel1))
    m_uwinkel1 = ufloat(parms_winkel1[0], error_winkel1[0])
    b_uwinkel1 = ufloat(parms_winkel1[1], error_winkel1[1])

    breite_winkel1 = 2 * (winkel_1 - (max_1 * 0.5 - b_uwinkel1) / m_uwinkel1)
    delta_energie_1 = brag_ener(noms(
        (max_1 * 0.5 - b_uwinkel1) / m_uwinkel1), 1) - brag_ener(
            noms((max_1 * 0.5 - b_uwinkel1) / m_uwinkel1 + breite_winkel1), 1)

    print('K_beta fit Steigung', m_uwinkel1)
    print('k_beta fit y_achsenabschnitt', b_uwinkel1)
    print('ort des Maximums', winkel_1)
    print('Höhe des Maximums', max_1)
    print('Partner Ort', winkel_1_fit_partner)
    print('partner Höhe', imp_winkel1_partner)
    print('Ort der Halben beta', (max_1 * 0.5 - b_uwinkel1) / m_uwinkel1)
    print('k_beta Breite 1', breite_winkel1)
    print('k_beta Breite 1 in ev', delta_energie_1)

    print('\n\n\n')

    ###k_alpha peak
    imp_winkel2_partner = imp[np.where(imp == max_2)[0][0] - 1]
    winkel_2_fit_partner = winkel[np.where(imp == max_2)[0][0] - 1]
    parms_winkel2, cov_winkel2 = curve_fit(
        g, [winkel_2_fit_partner, winkel_2[0]],
        [imp_winkel2_partner, imp[np.where(imp == max_2)][0]])
    error_winkel2 = np.sqrt(np.diag(cov_winkel2))
    m_uwinkel2 = ufloat(parms_winkel2[0], error_winkel2[0])
    b_uwinkel2 = ufloat(parms_winkel2[1], error_winkel2[1])

    breite_winkel2 = 2 * (winkel_2 - (max_2 * 0.5 - b_uwinkel2) / m_uwinkel2)
    delta_energie_2 = brag_ener(
        noms((max_2 * 0.5 - b_uwinkel2) / m_uwinkel2 + breite_winkel2),
        1) - brag_ener(noms((max_2 * 0.5 - b_uwinkel2) / m_uwinkel2), 1)
    print(brag_ener(noms(breite_winkel2), 1))
    print('K_alpha fit Steigung', m_uwinkel2)
    print('k_alpha fit y_achsenabschnitt', b_uwinkel2)
    print('ort des Maximums', winkel_2)
    print('Höhe des Maximums', max_2)
    print('Partner Ort', winkel_2_fit_partner)
    print('partner Höhe', imp_winkel2_partner)
    print('Ort der Halben alpha', (max_2 * 0.5 - b_uwinkel2) / m_uwinkel2)
    print('k_alpha Breite 2', breite_winkel2)
    print('k_alpha Breite 2 in ev', delta_energie_2)
    print('\n\n\n')

    ## Plots für die Halbwertsbrete
    lauf1 = np.linspace(19, 22, 1000)
    lauf2 = np.linspace(21, 23, 1000)

    plt.clf()
    plt.plot(winkel, imp, 'rx', label=r'$Intensität$')
    plt.plot(lauf1,
             g(parms_winkel1[0], lauf1, parms_winkel1[1]),
             'c-',
             label=r'$Ausgleichgerade K_{\beta}$')
    plt.plot(lauf2,
             g(parms_winkel2[0], lauf2, parms_winkel2[1]),
             'y-',
             label=r'$Ausgleichgerade K_{\alpha}$')
    plt.axvline(winkel_2, ls='--', color='b', label=r'$K_{\alpha}$')
    plt.axvline(winkel_1, ls='--', color='g', label=r'$K_{\beta}$')
    plt.grid()
    plt.xlabel(r'$\theta \, \mathrm{in} \, \mathrm{deg}$')
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$')
    plt.xlim(17.5, 23.5)
    plt.ylim(0, 4400)
    plt.legend(loc='best')
    plt.savefig(name + '_zoom.pdf')

    ##Auswertung der maximalen Energie

    plt.clf()
    plt.plot(winkel[0:10], imp[0:10], 'rx', label=r'$Intensität$')
    plt.grid()
    plt.xlabel(r'$\theta \, \mathrm{in} \, \mathrm{deg}$')
    plt.ylabel(r'$I \, \mathrm{in} \, \mathrm{Imp}/\mathrm{s}$')
    plt.axvline(winkel[3],
                ls='--',
                color='b',
                label=r'$\theta_{\mathrm{min,u}} \, untere \, Schranke}$')
    plt.axvline(winkel[7],
                ls='--',
                color='g',
                label=r'$\theta_{\mathrm{min,o}} \,obere\, Schranke}$')
    plt.legend(loc='best')
    plt.xlim(3.8, 6)
    plt.ylim(20, 80)
    #plt.show()
    plt.savefig(name + '_maximale_energies.pdf')

    winkel_min = winkel[3] + 0.5 * (winkel[7] - winkel[3])
    print('Minimaler Winkel', winkel_min)
    print('Maximale Energie', brag_ener(winkel_min, 1) * 1e-3)
    print('Wellenlänge', brag_well(winkel_min, 1))
    print('\n\n\n')
Ejemplo n.º 13
0
energie_k.append(
    1e3 *
    absorb(15, 21, 35, 0.5 * winkel_brom, int_brom, 0.5, 0.5, 1, 1, 'brom'))
energie_k.append(1e3 * absorb(14, 20, 38, 0.5 * winkel_stom, int_strom, 0.25,
                              0.25, 10, 1, 'strom'))
energie_k.append(1e3 * absorb_zink(14, 20, 8, 25, 30, 0.5 * winkel_zink,
                                   int_zink, 0.25, 0.25, 20, 10, 'zink'))
absorb_gold(14, 20, 79, 0.5 * winkel_gold, int_gold, 0.25, 0.25, 10, 1, 'gold')

### Bestimmung der Rydbergenergie
#Z=[40-2.88,32-3.09,35-2.98,38-2.98,30-3.37]
Z = [40, 32, 35, 38, 30]
Element = ['$\ce{Zr}$', '$\ce{Ge}$', '$\ce{Br}$', '$\ce{Sr}$', '$\ce{Zn}$']
l.Latexdocument('ryd.tex').tabular(
    [Z, np.sqrt(energie_k)],
    '{Element} & {Z} & {$E_{\mathrm{K}}$}', [0, 1],
    caption='Experimentell bestimmten Energie $E_{\mathrm{K}}$',
    label='ener_ryd')


def g(m, x, b):
    return m * x + b


parms, cov = curve_fit(g, Z, np.sqrt(energie_k))
error = np.sqrt(np.diag(cov))
m_u = ufloat(parms[0], error[0])
b_u = ufloat(parms[1], error[1])
print('Regressionsrechnugng E_k und Z')
print('Steigung/Rydberggenerie', m_u)
print('Steigung/Rydberggenerie', m_u**2)
Ejemplo n.º 14
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties.unumpy import nominal_values as noms, std_devs as stds
from uncertainties import ufloat
import math
from scipy.optimize import curve_fit
import scipy.constants
import matplotlib.pyplot as plt
from pint import UnitRegistry
import random
import latex as l

u = UnitRegistry()
Q_ = u.Quantity
r = l.Latexdocument('results.tex')
e = Q_(scipy.constants.e, 'coulomb')
###########################################
#DATEN EINLESEN
N_raw = np.genfromtxt('counts_plateau.txt', unpack=True)
delta_t = 60
errors_raw = np.sqrt(N_raw)
N = unp.uarray(N_raw, errors_raw) / delta_t
U = Q_(np.linspace(310, 700, 40), 'volt')
I = np.genfromtxt('strom.txt', unpack=True)
#Ladungsmenge
delta_Q = Q_(I / N, 'microampere * second').to('gigacoulomb') / e

l.Latexdocument('tabs/zählrate_strom_ladung.tex').tabular(
    [
        U.magnitude, N_raw,
        np.sqrt(N_raw),
Ejemplo n.º 15
0
print('Schwingungsfrequenz Theorie v_-', v_mint)
print('\n')
print('Schwingungsfrequenz Theorie v_+', v_plut)
print('\n')

verhaeltnis = (1 / n)
#n_theo=(v_plut+v_mint)/(2*(v_mint-v_plut))
n_theo = (2 * (v_mint - v_plut)) / (v_plut + v_mint)

print('Theoretisch Verhältnis', n_theo)
n_verhl = ((verhaeltnis / (n_theo)) - 1) * 100

latex.Latexdocument('teila_ck_n_mit_theo.tex').tabular(
    [c_k.magnitude, n, verhaeltnis, n_theo, n_verhl],
    r'{$C\ua{k}$ in $\si{\nano\farad}$} & {Anzahl Schwingungsmaxima} & {Verhäl. $n$ in \%} & { Verhäl. $n\ua{theo}$ in \%} & {rel. Abw. $\frac{n}{n\ua{theo}}$ in \%}',
    [1, 1, 2, 2, 1],
    caption=
    r'Anzahl der Schwingungsmaxima bei verschiedenenen Kapazitäten $C_k$',
    label='teila_n_ck')
verhaeltnis = ((1 / n) - 1) * 100

#for n in range(len(v_mint)):
#	a[n]=v_plut.magnitude.noms
#	b[n]=v_plu.magnitude.stds
#v_plut_list=unp.uarray(a,b)
#print(v_plut_list)

##Aufgabenteil b
c_k_1, v_plug, v_ming = np.genfromtxt('teilaufgabe_b_frequenzen.txt',
                                      unpack=True)
v_ming = Q_(unp.uarray(v_ming, 1), 'kilohertz')
Ejemplo n.º 16
0
C = ufloat(2.098e-9, 0.006e-9)

#Messwerte einlesen
frequenz1, U_G_1, U_C_1, a1, b1 = np.genfromtxt(
    'frequenzabhängigkeit_amplitude_phase.txt', unpack=True)
frequenz2, U_G_2, U_C_2, a2, b2 = np.genfromtxt('frequenz_2.txt', unpack=True)
frequenz = np.concatenate((frequenz1, frequenz2), axis=0)
U_G = np.concatenate((U_G_1, U_G_2), axis=0)
U_C = np.concatenate((U_C_1, U_C_2), axis=0)
a = np.concatenate((a1, a2), axis=0)
b = np.concatenate((b1, b2), axis=0)
phase = a / b * 2 * np.pi
latex.Latexdocument('frequenzabhängigkeit.tex').tabular(
    [frequenz, U_G, U_C, a, b, phase],
    '{$\\nu$ / \si{\hertz}} & {$U$ / $\si{\\volt}$} & {$U_C$ / $\si{\\volt}$} & {$a$ / $\si{\micro\second}$} & {$b$ / $\si{\micro\second}$} & {$\phi$ / rad}',
    [0, 2, 2, 2, 2, 2],
    caption=
    'Messwerte der Zeitparameter a und b, Kondensator- und Generatorspannung, sowie die errechnete Phasendifferenz in Abhängigkeit von der Frequenz $\\nu$.',
    label='tab: frequenzabhängigkeit')

amplitude = np.genfromtxt('amplitude_schwingfall.txt', unpack=True)
time = np.linspace(0, 12, 13) * 30e-6
latex.Latexdocument('amplitude.tex').tabular(
    [time * 100000, amplitude],
    '{$t$ / $10^{-5}\si{\second}$} & {$A$ / $\si{\\volt}$}', [1, 2],
    caption='Zeitlicher Verlauf der Amplitude des gedämpften Schwingkreises.',
    label='tab: amplitude')


def lin_function(t, m, b):
    return m * t + b
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
from pint import UnitRegistry
import scipy.constants as const
import latex as l
r = l.Latexdocument('plots.tex')
u = UnitRegistry()
Q_ = u.Quantity
import pandas as pd
from pandas import Series, DataFrame
from scipy.signal import find_peaks
import os


def abs_path(filename):
    return os.path.join(os.path.dirname(__file__), filename)


# Import measurment datas
channel_content_sb_ba = np.genfromtxt(
    './2018-10-29_becker_grisard/sb_or_ba.txt', unpack=True)

# --- Import params to transform binnumber to energy ---#
params, errors = np.genfromtxt('./umrechnungen_bins_to_energy.txt',
                               unpack=True)
Ejemplo n.º 18
0
    return np.sqrt( 1/(L.magnitude * C.magnitude) * (1 - 0.25 * L.magnitude * C.magnitude * (2*np.pi*nus))    )

def impedanz_plot(omega):
    return np.sqrt(L.magnitude / C.magnitude) * 1/np.sqrt( 1 - 0.25 * omega**2 * L.magnitude * C.magnitude )

def impedanz(omega):
    return np.sqrt(L / C) * 1/np.sqrt( 1 - 0.25 * omega**2 * L * C )
#variabel_1,variabel_2=np.genfromtxt('name.txt',unpack=True)


#Einlesen der Messwerte
eigenfrequenzen_a_LC = np.genfromtxt('eigenfrequenzen_a_LC.txt', unpack=True)
range_lin = np.linspace(1, len(eigenfrequenzen_a_LC), 12)
Phasenverschiebung_pro_glied_LC = np.pi * range_lin / 16
latex.Latexdocument('tabs/eigenfrequenzen_dispersion_LC.tex').tabular([Phasenverschiebung_pro_glied_LC, eigenfrequenzen_a_LC],
'{$\\theta$} & {$\\nu$ in $\si{\hertz}$}', [1, 0],
caption = 'LC-Kette, Gemessene Frequenzen mit zugeordnetem Phasenversatz pro Glied', label = 'tab: dispersion_LC')


eigenfrequenzen_a_LC1C2 = np.genfromtxt('eigenfrequenzen_a_LC1C2.txt', unpack=True)
range_lin = np.linspace(1, len(eigenfrequenzen_a_LC1C2), len(eigenfrequenzen_a_LC1C2))
Phasenverschiebung_pro_glied_LC1C2 = np.pi * range_lin / 16
for i in range(0, len(Phasenverschiebung_pro_glied_LC1C2)):
    if (Phasenverschiebung_pro_glied_LC1C2[i] > np.pi/2):
        Phasenverschiebung_pro_glied_LC1C2[i] -= 2*(Phasenverschiebung_pro_glied_LC1C2[i] - np.pi/2)
latex.Latexdocument('tabs/eigenfrequenzen_dispersion_LC1C2.tex').tabular([Phasenverschiebung_pro_glied_LC1C2, eigenfrequenzen_a_LC1C2],
'{$\\theta$} & {$\\nu$ in $\si{\hertz}$}', [1, 0],
caption = '$LC_1C_2$-Kette, Gemessene Frequenzen mit zugeordnetem Phasenversatz pro Glied', label = 'tab: dispersion_LC1C2')

frequenzen_sweep_LC = np.genfromtxt('frequenz_sweep_LC.txt', unpack = True)
x_range_LC = ((np.linspace(1, len(frequenzen_sweep_LC), len(frequenzen_sweep_LC))-1) * 4)[::-1]
Ejemplo n.º 19
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
import math
import datetime
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
from pint import UnitRegistry
import latex as l
r = l.Latexdocument('plots.tex')
u = UnitRegistry()
Q_ = u.Quantity
import pandas as pd
from pandas import Series, DataFrame
from scipy.signal import find_peaks
import os


def abs_path(filename):
    return os.path.join(os.path.dirname(__file__), filename)


# ########################################################################### #
# ###################### --- Bestimmung der Peaks --- ####################### #
# ########################################################################### #

channel_content_eu = np.genfromtxt('./2018-10-29_becker_grisard/europium.txt',
                                   unpack=True)
Ejemplo n.º 20
0
nullrate = 167
nullrate *= (240) / (900)

##Isotop mit einem eifachen Zerfall

zeit, anzahl = np.genfromtxt('zaehlrate_indium.txt', unpack=True)
zeit *= 240
anzahl -= nullrate
anzahl_fehler = np.sqrt(anzahl)
anzahlu = unp.uarray(anzahl, anzahl_fehler)

fehlelog_indium = fehler_log(anzahl)

l.Latexdocument('messwerte_indium.tex').tabular(
    [zeit, anzahl, anzahl_fehler, fehlelog_indium[1], fehlelog_indium[0]],
    'Jo', [0, 0, 0, 2, 2],
    caption='Gemessene Anzahl an Zerfällen bei Indium',
    label='tab: indium_messwerte')

#latex.Latexdocument('messwerte_indium.tex').tabular([zeit, anzahl, anzhal_fehler, fehler_log[1], fehler_log[0] ],
#'{$t$ in $\si{\secod}$} & {Anzahl $N$} & {$\sigma\ua{N}$} & {$\ln{N+\sigma\ua{N}}-\ln{N}$} & {$\ln{N-\sigma\ua{N}}-\ln{N}$}', [1, 1, 1,1 ,1 ] ,
#caption = 'Gemessene Anzahl an Zerfällen bei Indium', label = 'tab: indium_messwerte')


def g(x, m, b):
    return m * x + b


params_indium, cov_indium = curve_fit(g, zeit, np.log(anzahl))
indium_errors = np.sqrt(np.diag(cov_indium))
indium_u = unp.uarray(params_indium, indium_errors)
Ejemplo n.º 21
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
import math
from scipy.optimize import curve_fit
import matplotlib.pyplot as plt
from pint import UnitRegistry
import latex as l
r = l.Latexdocument('results.tex')

from scipy.constants import *


##r = l.Latexdocument('results.tex')
#u = UnitRegistry()
#Q_ = u.Quantity
#import pandas as pd
#from pandas import Series, DataFrame
##series = pd.Series(data, index=index)
## d = pd.DataFrame({'colomn': series})
#
#a = ufloat(1, 0.1)
#r.app('I', Q_(a, 'ampere'))
#r.makeresults()
##r.makeresults()
def g(m, x, b):
    return m * x + b
Ejemplo n.º 22
0
import numpy as np
import uncertainties.unumpy as unp
from uncertainties import ufloat
from uncertainties.unumpy import nominal_values as noms
from uncertainties.unumpy import std_devs as stds
from uncertainties import correlated_values
import math
from scipy.optimize import curve_fit
from pint import UnitRegistry
import latex as l
r = l.Latexdocument('results.tex')
u = UnitRegistry()
Q_ = u.Quantity
import os


def abs_path(filename):
    return os.path.join(os.path.dirname(__file__), filename)


import matplotlib as mlp
mlp.use('pgf')
import matplotlib.pyplot as plt
from matplotlib import rcParams

rcParams['font.family'] = 'serif'
rcParams['font.serif'] = '[lmroman10-regular]:+tlig;'
rcParams['text.usetex'] = True
rcParams['pgf.texsystem'] = 'lualatex'
rcParams['font.size'] = 10
rcParams['mathtext.fontset'] = 'custom'