from mathutils import Gaussian,fit_gaussian, calculate_peaks ############################################################################################## #Setup ############################################################################################## #try: # collimator.move("In") #except: # pass shutter.write(1) 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(y, x, True) fitted_gaussian_function = Gaussian(normalization, mean, sigma) print "Mean = " + str(mean) resolution = step_size/100 fit_gaussian = [] 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)), None)