Ejemplo n.º 1
0
def arcsin(number):
    if isinstance(number, fr.Fraction):
        number = Mixed(number)
    elif isinstance(number, uc.UFloat):
        number = Mixed(number)
    elif isinstance(number, int):
        number = Mixed(number)
    elif isinstance(number, float):
        number = Mixed(number)
    assert isinstance(number, Mixed), \
        "Cannot calculate arcsin of object of type %s." % (type(number))
    if isinstance(number.value, uc.UFloat):
        return Mixed(unumpy.arcsin(number.value).item())
    elif isinstance(number.value, fr.Fraction):
        return Mixed(np.arcsin(float(number.value)))
    elif isinstance(number.value, int):
        return Mixed(np.arcsin(number.value))
    elif isinstance(number.value, float):
        return Mixed(np.arcsin(number.value))
Ejemplo n.º 2
0
def arcsin(number):
    if isinstance(number, fr.Fraction):
        number = Mixed(number)
    elif isinstance(number, uc.UFloat):
        number = Mixed(number)
    elif isinstance(number, int):
        number = Mixed(number)
    elif isinstance(number, float):
        number = Mixed(number)
    assert isinstance(number, Mixed), \
        "Cannot calculate arcsin of object of type %s." % (type(number))
    if isinstance(number.value, uc.UFloat):
        return Mixed(unumpy.arcsin(number.value).item())
    elif isinstance(number.value, fr.Fraction):
        return Mixed(np.arcsin(float(number.value)))
    elif isinstance(number.value, int):
        return Mixed(np.arcsin(number.value))
    elif isinstance(number.value, float):
        return Mixed(np.arcsin(number.value))
Ejemplo n.º 3
0
def darcsin(number):
    if isinstance(number, fr.Fraction):
        number = Mixed(number)
    elif isinstance(number, uc.UFloat):
        number = Mixed(number)
    elif isinstance(number, int):
        number = Mixed(number)
    elif isinstance(number, float):
        number = Mixed(number)
    assert isinstance(number, Mixed), \
        "Cannot calculate darcsin of object of type %s." % (type(number))
    if isinstance(number.value, uc.UFloat):
        return rad2deg(Mixed(unumpy.arcsin((number.value)).item()))
    elif isinstance(number.value, fr.Fraction):
        if number == -1:
            return Mixed(-90)
        elif number == -fr.Fraction(1, 2):
            return Mixed(-30)
        elif number == 0:
            return Mixed(0)
        elif number == fr.Fraction(1, 2):
            return Mixed(30)
        elif number == 1:
            return Mixed(90)
        else:
            return rad2deg(Mixed(np.arcsin(float(number.value))))
    elif isinstance(number.value, int):
        if number  == -1:
            return Mixed(-90)
        elif number == 0:
            return Mixed(0)
        elif number == 1:
            return Mixed(90)
        else:
            return rad2deg(Mixed(np.arcsin(number.value)))
    elif isinstance(number.value, float):
        return rad2deg(Mixed(np.arcsin(number.value)))
Ejemplo n.º 4
0
def darcsin(number):
    if isinstance(number, fr.Fraction):
        number = Mixed(number)
    elif isinstance(number, uc.UFloat):
        number = Mixed(number)
    elif isinstance(number, int):
        number = Mixed(number)
    elif isinstance(number, float):
        number = Mixed(number)
    assert isinstance(number, Mixed), \
        "Cannot calculate darcsin of object of type %s." % (type(number))
    if isinstance(number.value, uc.UFloat):
        return rad2deg(Mixed(unumpy.arcsin((number.value)).item()))
    elif isinstance(number.value, fr.Fraction):
        if number == -1:
            return Mixed(-90)
        elif number == -fr.Fraction(1, 2):
            return Mixed(-30)
        elif number == 0:
            return Mixed(0)
        elif number == fr.Fraction(1, 2):
            return Mixed(30)
        elif number == 1:
            return Mixed(90)
        else:
            return rad2deg(Mixed(np.arcsin(float(number.value))))
    elif isinstance(number.value, int):
        if number == -1:
            return Mixed(-90)
        elif number == 0:
            return Mixed(0)
        elif number == 1:
            return Mixed(90)
        else:
            return rad2deg(Mixed(np.arcsin(number.value)))
    elif isinstance(number.value, float):
        return rad2deg(Mixed(np.arcsin(number.value)))
Ejemplo n.º 5
0
from scipy.optimize import curve_fit
from scipy.stats import sem
import scipy.constants as const
import uncertainties.unumpy as unp

A, B = np.genfromtxt("../data/A4grün.dat", unpack=True)

a = np.deg2rad(A)  #ist alpha_1
b = np.deg2rad(B)  #ist alhpa_2
c = const.physical_constants["speed of light in vacuum"]
n = ufloat(1.45108, 0.01991)

aERR = np.array([])
bERR = np.array([])
for i in range(len(a)):
    aERR = np.append(aERR, ufloat(a[i], 0.00872665))
for i in range(len(b)):
    bERR = np.append(bERR, ufloat(b[i], 0.00872665))

#bestimme beta 1
beta = unp.arcsin(unp.sin(aERR) / n)
beta2 = np.deg2rad(60) - beta

print(beta * 180 / np.pi)
print(beta2 * 180 / np.pi)

delta = (aERR + bERR) - (beta + beta2)
deltamean = np.mean(delta)
print("###### delta grün:")
print(delta * 180 / np.pi)
print(f"Abweichung delta= {(deltamean*180/np.pi):.4f}")
Ejemplo n.º 6
0
Archivo: n.py Proyecto: knly/PAP2
# Extrapolation
def fit_lin(b, a, n_0):
    return a*b + n_0

sl_grenz=slice(13, 18)
popt_grenz, pstats_grenz = papstats.curve_fit(fit_lin, b[sl_grenz], n[sl_grenz])
b_G = (n_U-popt_grenz[1])/popt_grenz[0]
y_G = y_bragg(b_G)

# Berechnung
print "Grenzwellenlänge:", papstats.pformat(y_G/const.pico, label='y_G', unit='pm', format='.2u')
print "Plancksches Wirkungsquantum:"
papstats.print_rdiff(h_planck(y=y_G, U_B=30*const.kilo), h_erw)
# 2. Ordnung
print "2. Ordung ab:", papstats.pformat(unp.arcsin(y_G/d)/2/const.pi*360, label='b', unit='°', format='.2u')

# Plot
plt.clf()
plt.title(u'Diagramm 3.1: Bremsspektrum von LiF mit Untergrund und Extrapolation am kurzwelligen Ende')
axmain = plt.subplot(111)
plt.xlabel(ur'Bestrahlungswinkel $\beta \, [^\circ]$')
plt.ylabel(ur'Zählrate $n \, [\frac{Ereignisse}{s}]$')
xlim = [b[0], b[-1]]
xspace = np.linspace(*xlim, num=1000)
axmain.set_xlim(*xlim)
papstats.plot_data(b, n, label='Messpunkte')
plt.fill_between(unp.nominal_values(b), 0, unp.nominal_values(n), color='g', alpha=0.2)

from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes
from mpl_toolkits.axes_grid1.inset_locator import mark_inset
Ejemplo n.º 7
0
xerror = 1e-3 * np.ones(len(xsigma)) * 0.05

a = 1
b = 1

usigma_x = usigma_x**2 * a
usigma_y = usigma_y**2 * a

uheight = unp.uarray(heigh_m, xerror) * b

alpha = unp.arctan((usigma_x - omega_0) / (uheight - z_0))

x = 150e-6

d_1 = x * unp.tan(unp.arcsin(1 / 3.551))

print(d_1)

usigma_x -= 2 * unp.sqrt(d_1**2)

print(usigma_x)
#print(alpha,uheight)

################## Plot and Fit with ROOT ############################

root.gStyle.SetLabelSize(.055, "XY")
root.gStyle.SetLabelFont(42, "XY")
root.gStyle.SetTitleSize(.055, "YY")
root.gStyle.SetTitleSize(.053, "X")
Ejemplo n.º 8
0
sl_grenz = slice(13, 18)
popt_grenz, pstats_grenz = papstats.curve_fit(fit_lin, b[sl_grenz],
                                              n[sl_grenz])
b_G = (n_U - popt_grenz[1]) / popt_grenz[0]
y_G = y_bragg(b_G)

# Berechnung
print "Grenzwellenlänge:", papstats.pformat(y_G / const.pico,
                                            label='y_G',
                                            unit='pm',
                                            format='.2u')
print "Plancksches Wirkungsquantum:"
papstats.print_rdiff(h_planck(y=y_G, U_B=30 * const.kilo), h_erw)
# 2. Ordnung
print "2. Ordung ab:", papstats.pformat(unp.arcsin(y_G / d) / 2 / const.pi *
                                        360,
                                        label='b',
                                        unit='°',
                                        format='.2u')

# Plot
plt.clf()
plt.title(
    u'Diagramm 3.1: Bremsspektrum von LiF mit Untergrund und Extrapolation am kurzwelligen Ende'
)
axmain = plt.subplot(111)
plt.xlabel(ur'Bestrahlungswinkel $\beta \, [^\circ]$')
plt.ylabel(ur'Zählrate $n \, [\frac{Ereignisse}{s}]$')
xlim = [b[0], b[-1]]
xspace = np.linspace(*xlim, num=1000)
Ejemplo n.º 9
0
def theta(x):
    return unp.arcsin(n * c * h / (2 * x * d))