31 lines
1020 B
Python
31 lines
1020 B
Python
from mathutils import fit_gaussian,calculate_peaks
|
|
|
|
prefix="2017/05/10/20170510_132908_WireScan.h5|/"
|
|
|
|
xdata, ydata = "w_pos", "blm1"
|
|
number_scans = 6
|
|
c1, c2 = Color.RED, Color.BLUE
|
|
|
|
p= plot(None, title = xdata)[0]
|
|
for i in range(1,number_scans+1):
|
|
c = c1 if ((i%2) == 1) else c2
|
|
s = LinePlotSeries("Measure" + str(i), color = c)
|
|
p.addSeries(s)
|
|
xval = load_data(prefix+ "x_000" + str(i)+"/" + xdata)
|
|
yval = load_data(prefix+ "x_000" + str(i)+"/" + ydata)
|
|
yval = yval[:len(xval)]
|
|
s.setData(xval, yval)
|
|
#This is to cope with the repeated values: fit needs increasing x
|
|
for i in range (len(xval)-1):
|
|
if xval[i+1] == xval[i]:
|
|
xval[i+1] = xval[i] + 0.00001
|
|
max_y= max(ydata)
|
|
index_max = ydata.index(max_y)
|
|
(norm, mean, sigma) = fit_gaussian(yval, xval)
|
|
|
|
print mean
|
|
if mean is not None:
|
|
p.addMarker(mean, p.AxisId.X, "", c)
|
|
|
|
|
|
#plot( load_data(prefix+ "x_0003/blm1"), "1", xdata = load_data(prefix+ "x_0003/w_pos")) |