Averager devices

This commit is contained in:
gac-bernina
2021-05-03 09:59:40 +02:00
parent 89562f457f
commit 2bcbb2b157
17 changed files with 154 additions and 61 deletions

View File

@@ -24,10 +24,11 @@ def fit_energy(e_from, e_to, steps, num_shots, data):
def fit_crystal_height(xstal_from, xstal_to, steps, data):
xstal_range = np.linspace(xstal_from, xstal_to, steps)
projection = data.mean(axis=1).mean(axis=1)
offset = np.mean(projection[0:100])
signal_centre = xstal_range[np.argmax(projection)]
xstal_range_fit = np.linspace(xstal_range[0], xstal_range[-1], len(xstal_range)*10)
try:
popt,pcov = curve_fit(gaus,xstal_range,projection,p0=[100,signal_centre,-0.2,100])
popt,pcov = curve_fit(gaus,xstal_range,projection,p0=[100,signal_centre,-0.2,offset])
except:
raise Exception('Fit failed: spectrum might not be near scan range center \n' + str(sys.exc_info()[1]))
#print('Fit failed: spectrum might not be near scan range center')