Script execution
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks
|
||||
from mathutils import Gaussian,fit_gaussian, calculate_peaks
|
||||
|
||||
##############################################################################################
|
||||
#Setup
|
||||
##############################################################################################
|
||||
#try:
|
||||
# collimator.move("In")
|
||||
#except:
|
||||
@@ -7,24 +10,32 @@ from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks
|
||||
|
||||
shutter.write(1)
|
||||
|
||||
result = lscan (collimatorX, diode, -0.5, 0.5 , 100, 0, relative = True)
|
||||
|
||||
step_size = 0.05
|
||||
|
||||
##############################################################################################
|
||||
#Scan
|
||||
##############################################################################################
|
||||
|
||||
result = lscan (collimatorX, diode, -0.3, 0.3 , 30, 0.2, relative = True)
|
||||
shutter.write(0)
|
||||
|
||||
|
||||
##############################################################################################
|
||||
#Peak detection
|
||||
##############################################################################################
|
||||
|
||||
y = result.getReadable(0)
|
||||
x = result.getPositions(0)
|
||||
(normalization, mean, sigma) = fit_gaussian(readable, positions, True)
|
||||
(normalization, mean, sigma) = fit_gaussian(y, x, True)
|
||||
fitted_gaussian_function = Gaussian(normalization, mean, sigma)
|
||||
print (normalization, mean, sigma)
|
||||
print "Mean = " + str(mean)
|
||||
|
||||
|
||||
resolution = step_size/100
|
||||
fit_gaussian = []
|
||||
for x in frange(start,end,resolution, True):
|
||||
fit_gaussian.append(fitted_gaussian_function.value(x))
|
||||
gx = frange(start, end+resolution, resolution)
|
||||
for p in frange(x[0],x[-1],resolution, True):
|
||||
fit_gaussian.append(fitted_gaussian_function.value(p))
|
||||
gx = frange(x[0], x[-1]+resolution, resolution)
|
||||
|
||||
plots = plot([y, fit_gaussian], ["data", "gaussian"], xdata = [x,gx] )
|
||||
plots[0].addMarker(mean, None, "Mean=" + str(round(mean,2)))
|
||||
plots[0].addMarker(mean, None, "Mean=" + str(round(mean,2)), None)
|
||||
|
||||
Reference in New Issue
Block a user