Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- %matplotlib inline
- import matplotlib.pyplot as plt
- import numpy as np
- from pylab import *
- from scipy.stats import linregress
- from math import pi as PI
- from scipy.optimize import curve_fit
- import scipy.optimize as optimization
- from uncertainties import ufloat
- #Lasermessung
- Spalt_1_d = np.array([0.0, 0.5e-3, 1.0e-3, 1.5e-3, 2.0e-3, 2.5e-3, 3.0e-3, 3.5e-3, 4.0e-3, 4.23e-3, 4.5e-3, 5.0e-3,
- 5.5e-3, 6.0e-3, 6.5e-3, 7.0e-3, 7.5e-3, 8.0e-3, 8.5e-3])
- Spalt_1_I = np.array([10.0e-3, 17.3e-3, 39.8e-3, 84.9e-3, 151.5e-3, 197.4e-3, 278.6e-3, 300.0e-3, 333.5e-3, 341.1e-3,
- 329.2e-3, 282.3e-3, 243.0e-3, 177.2e-3, 114.2e-3, 67.9e-3, 28.5e-3, 10.5e-3, 10.9e-3])
- Spalt_2_d = np.array([0.0, 0.5e-3, 1.0e-3, 1.5e-3, 2.0e-3, 2.5e-3, 3.0e-3, 3.5e-3, 4.0e-3, 4.5e-3, 5.0e-3,
- 5.5e-3, 5.9e-3, 6.0e-3, 6.1e-3, 6.2e-3, 6.5e-3, 7.0e-3, 7.5e-3, 8.0e-3, 8.5e-3])
- Spalt_2_I = np.array([10.0e-3, 11.5e-3, 16.1e-3, 23.6e-3, 34.7e-33, 51.0e-3, 72.1e-3, 99.3e-3, 133.1e-3, 170.2e-3, 206.2e-3,
- 236.8e-3, 249.3e-3, 250.7e-3, 250.5e-3, 248.9e-3, 239.9e-3, 203.7e-3, 145.5e-3, 76.6e-3, 10.9e-3])
- Doppelspalt_d = np.array([0.0, 0.5e-3, 1.0e-3, 1.5e-3, 2.0e-3, 2.5e-3, 3.0e-3, 3.25e-3, 3.5e-3, 3.71e-3, 4.0e-3, 4.13e-3,
- 4.2e-3, 4.3e-3, 4.4e-3, 4.5e-3, 4.6e-3, 4.7e-3, 4.8e-3, 4.9e-3, 5.0e-3, 5.1e-3, 5.2e-3,
- 5.3e-3, 5.4e-3, 5.5e-3, 5.6e-3, 5.7e-3, 5.8e-3, 5.9e-3, 6.0e-3, 6.1e-3, 6.2e-3, 6.3e-3, 6.4e-3,
- 6.5e-3, 6.6e-3, 6.7e-3, 6.8e-3])
- Doppelspalt_I = np.array([10.0e-3, 20.1e-3, 55.7e-3, 55.2e-3, 260.3e-3, 247.6e-3, 403.0e-3, 23.7e-3, 643.0e-3, 1102.0e-3,
- 254.3e-3, 17.9e-3, 36.4e-3, 269.5e-3, 749.0e-3, 1067.0e-3, 1262.0e-3, 1180.0e-3, 787.0e-3, 398.0e-3,
- 81.6e-3, 18.4e-3, 179.9e-3, 572.0e-3, 890.0e-3, 1076.0e-3, 1037.0e-3, 800.0e-3, 405.0e-3, 135.3e-3,
- 23.7e-3, 90.3e-3, 293.2e-3, 513.0e-3, 660.0e-3, 655.0e-3, 534.0e-3, 313.0e-3, 141.0e-3])
- len(Spalt_1_I)
- lam = 670e-9
- def func1(x, A, B, C):
- return C*(sin(PI*B*x)**2/(PI*B**2))*cos(PI*A*x)**2
- def func2(x, A, B, C):
- return 1262e-3*(((sin((PI/lam)*B*sin(x/C)))/((PI/lam)*B*sin(x/C)))**2)*cos((PI/lam)*A*sin(x/C))**2
- def func3(x, A, B, C):
- return 1262e-3*((sin(B))**2/B**2)*cos(A*x/C)**2
- xdata = Doppelspalt_d
- ydata = Doppelspalt_I
- xdata_plot = np.linspace(0.0, 0.008, 500)
- print "Fit"
- popt, pcov = optimization.curve_fit(func3, xdata, ydata)
- print popt
- fig, graph1 = plt.subplots()
- #2xdata_plot = np.linspace(400, 750, 50)
- graph1.plot(Spalt_1_d, Spalt_1_I, '-x', label = 'Spalt 1')
- graph1.plot(Spalt_2_d, Spalt_2_I, '-+', label = 'Spalt 2')
- graph1.plot(Doppelspalt_d, Doppelspalt_I, '-o', label = 'Doppelspalt')
- graph1.plot(xdata_plot, func3(xdata_plot, popt[0], popt[1], popt[2]), '--o', label = 'Fit')
- graph1.legend()
- graph1.set_ylabel(r'Detektorspannung in V', fontsize = 20)
- graph1.set_xlabel(r'Position des Detektorspalts in m', fontsize = 20)
- fig.set_size_inches(12,7)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement