Exemple #1
0
Fichier : n.py Projet : knly/PAP2
def vergleiche_aktivitaet(A, filename, e_soll=None, k=None, index=None):
    headlines = ['d [cm]', 'A'+('_k'+str(index) if index is not None else '')+' [1/s]', 'Abweichung [1/s]', 'rel. Abweichung', 'Sigma-Bereich']
    if k is not None:
        headlines.insert(2, 'Korrekturfaktor')
    if e_soll is not None:
        headlines.append('Epsilon-Soll')
    table = pt.PrettyTable(headlines)
    for i in range(len(A)):
        row = [d[i]/const.centi, A[i]]
        if k is not None:
            row.append(k[i])
        row.extend(papstats.rdiff(A[i], A_erw))
        if e_soll is not None:
            row.append(e_soll[i])
        table.add_row(row)
    with open('Resources/'+filename+'.txt', 'w') as file:
        file.write(table.get_string())
Exemple #2
0
def vergleiche_aktivitaet(A, filename, e_soll=None, k=None, index=None):
    headlines = [
        'd [cm]',
        'A' + ('_k' + str(index) if index is not None else '') + ' [1/s]',
        'Abweichung [1/s]', 'rel. Abweichung', 'Sigma-Bereich'
    ]
    if k is not None:
        headlines.insert(2, 'Korrekturfaktor')
    if e_soll is not None:
        headlines.append('Epsilon-Soll')
    table = pt.PrettyTable(headlines)
    for i in range(len(A)):
        row = [d[i] / const.centi, A[i]]
        if k is not None:
            row.append(k[i])
        row.extend(papstats.rdiff(A[i], A_erw))
        if e_soll is not None:
            row.append(e_soll[i])
        table.add_row(row)
    with open('Resources/' + filename + '.txt', 'w') as file:
        file.write(table.get_string())
Exemple #3
0
#####
# Legierungen
#####

converters = dict.fromkeys(range(1), unc.ufloat_fromstr)
data = np.array([
    np.loadtxt(
        'legierungen/' + l + '.txt', converters=converters, dtype=object)
    for l in legierungen
]) * const.kilo * const.eV
table_strings = []
for i in range(data.shape[0]):
    E_L = data[i]
    table = pt.PrettyTable()
    table.add_column(u'Moegliche Legierung ' + legierungen[i] + ':',
                     ['Abweichung [keV]', 'Sigma'])
    containing_elements = []
    for j in range(E.shape[0]):
        diffs = np.abs([E[j] - E_l for E_l in E_L]) / const.kilo / const.eV
        argmin = np.argmin(diffs)
        diff_min = diffs.flatten()[argmin]
        sigma = diff_min.n / diff_min.s
        if sigma <= 1:
            containing_elements.append((j, sigma))
            table.add_column(elements[j][0],
                             np.array(papstats.rdiff(diff_min))[[0, 2]])
    table_strings.append(table.get_string())
with open('Resources/3.2.txt', 'w') as file:
    file.write('\n'.join(table_strings))
Exemple #4
0
    R, dtype=float) * const.kilo, np.array(f, dtype=float), T_H * const.micro
C, R = unp.uarray(C, C * 0.1), unp.uarray(R, R * 0.05)

tau_exp = T_H / np.log(2)
tau_theo = R * C

print papstats.table(
    labels=[
        'C', 'R', 'f', u'τ_exp', u'τ_theo', 'Abweichung', 'rel. Abw.',
        u'σ-Bereich'
    ],
    units=['nF', u'kΩ', 'Hz', u'µs', u'µs', u'µs', None, None],
    columns=[
        C / const.nano, R / const.kilo, f, tau_exp / const.micro,
        tau_theo / const.micro
    ] + list(papstats.rdiff(tau_exp / const.micro, tau_theo / const.micro)))

print "Messung aus Stromverlauf:", papstats.pformat(unc.ufloat(37.2, 2) /
                                                    np.log(2),
                                                    unit='us')

#####
print "# 3: Frequenz- und Phasengang eines RC-Glied"
#####

# Theoretische Grenzfrequenz

R = 1 * const.kilo * unc.ufloat(1, 0.05)
C = 47 * const.nano * unc.ufloat(1, 0.1)
f_G_theo = 1. / 2. / const.pi / R / C
Exemple #5
0
Fichier : n.py Projet : knly/PAP2
import papstats


#####
print "# 1: Bestimmung der Zeitkonstante eines RC-Glieds"
#####

C, R, f, T_H = np.loadtxt('1.txt', skiprows=1, converters=dict.fromkeys([3], unc.ufloat_fromstr), dtype=object, unpack=True)
C, R, f, T_H = np.array(C, dtype=float)*const.nano, np.array(R, dtype=float)*const.kilo, np.array(f, dtype=float), T_H*const.micro
C, R = unp.uarray(C, C*0.1), unp.uarray(R, R*0.05)

tau_exp = T_H/np.log(2)
tau_theo = R*C


print papstats.table(labels=['C', 'R', 'f', u'τ_exp', u'τ_theo', 'Abweichung', 'rel. Abw.', u'σ-Bereich'], units=['nF', u'kΩ', 'Hz', u'µs', u'µs', u'µs', None, None], columns=[C/const.nano, R/const.kilo, f, tau_exp/const.micro, tau_theo/const.micro] + list(papstats.rdiff(tau_exp/const.micro, tau_theo/const.micro)))

print "Messung aus Stromverlauf:", papstats.pformat(unc.ufloat(37.2,2)/np.log(2), unit='us')


#####
print "# 3: Frequenz- und Phasengang eines RC-Glied"
#####

# Theoretische Grenzfrequenz

R = 1*const.kilo * unc.ufloat(1, 0.05)
C = 47*const.nano * unc.ufloat(1, 0.1)
f_G_theo = 1./2./const.pi/R/C

print "Theoretische Grenzfrequenz:", papstats.pformat(f_G_theo/const.kilo, unit='kHz', format='c')
Exemple #6
0
Fichier : n.py Projet : knly/PAP2
    ax2.fill_between(np.sort(Z), k+1, unp.nominal_values(s[:,k])[np.argsort(Z)], alpha=0.15, color=p[0].get_color())
ax1.set_ylim(None, 45)
#ax2.set_ylim(0.3, 2.3)
ax1.legend(loc='lower right')
papstats.savefig_a4('3.2.png')


#####
# Legierungen
#####

converters = dict.fromkeys(range(1), unc.ufloat_fromstr)
data = np.array([np.loadtxt('legierungen/'+l+'.txt', converters=converters, dtype=object) for l in legierungen])*const.kilo*const.eV
table_strings = []
for i in range(data.shape[0]):
    E_L = data[i]
    table = pt.PrettyTable()
    table.add_column(u'Moegliche Legierung '+legierungen[i]+':', ['Abweichung [keV]', 'Sigma'])
    containing_elements = []
    for j in range(E.shape[0]):
        diffs = np.abs([E[j] - E_l for E_l in E_L])/const.kilo/const.eV
        argmin = np.argmin(diffs)
        diff_min = diffs.flatten()[argmin]
        sigma = diff_min.n/diff_min.s
        if sigma <=1:
            containing_elements.append((j, sigma))
            table.add_column(elements[j][0],  np.array(papstats.rdiff(diff_min))[[0,2]])
    table_strings.append(table.get_string())
with open('Resources/3.2.txt', 'w') as file:
    file.write('\n'.join(table_strings))