This commit is contained in:
@@ -23,9 +23,9 @@ V.initialize()
|
||||
t0 = t.read()
|
||||
|
||||
start = 2.2
|
||||
stop = 12.0
|
||||
stop = 7.0
|
||||
step = 0.1
|
||||
nb = 4
|
||||
nb = 10
|
||||
lat = 0.150
|
||||
|
||||
plt = plot(None, title="Output")[0]
|
||||
|
||||
@@ -12,13 +12,13 @@ if is_panel:
|
||||
lat = args[4]
|
||||
plt = args[5]
|
||||
else:
|
||||
start = -50.0
|
||||
start = -10.0
|
||||
stop = 150.0
|
||||
step = 1.0
|
||||
nb = 2
|
||||
lat = 0.010
|
||||
nb = 4
|
||||
lat = 0.110
|
||||
plt = plot(None, title="Output")[0]
|
||||
|
||||
|
||||
#Plot setup
|
||||
plt.clear()
|
||||
plt.removeMarker(None)
|
||||
@@ -48,8 +48,8 @@ else:
|
||||
bph.config.minValue = -360.0
|
||||
bph.config.maxValue = 360.0
|
||||
bph.config.precision = 3
|
||||
bph.config.rotation = False
|
||||
bph.config.resolution = 0.01
|
||||
bph.config.rotation = True
|
||||
bph.config.resolution = 0.1
|
||||
bph.config.save()
|
||||
bph.initialize()
|
||||
rph.initialize()
|
||||
@@ -64,7 +64,7 @@ q_averager.monitored=True
|
||||
|
||||
#Record callback: uptate of output plot
|
||||
def after_sample(record, scan):
|
||||
plt.getSeries(0).appendData(record.positions[0], record.values[1].mean, record.values[1].stdev)
|
||||
plt.getSeries(0).appendData((record.positions[0] + 90) % 360 - 90, record.values[1].mean, record.values[1].stdev)
|
||||
|
||||
#The scan loop
|
||||
try:
|
||||
@@ -75,8 +75,9 @@ finally:
|
||||
rph.close()
|
||||
q.close()
|
||||
#st.close()
|
||||
beamphase = r.getPositions(0)
|
||||
rfphase = [val.mean for val in r.getReadable(0)]
|
||||
#beamphase = r.getPositions(0)
|
||||
beamphase = [(val + 90) % 360 - 90 for val in r.getPositions(0)]
|
||||
rfphase = [(val.mean + 90) % 360 - 90 for val in r.getReadable(0)]
|
||||
rfphaserms = [val.stdev for val in r.getReadable(0)]
|
||||
charge = [val.mean for val in r.getReadable(1)]
|
||||
chargerms = [val.stdev for val in r.getReadable(1)]
|
||||
@@ -84,13 +85,14 @@ chargerms = [val.stdev for val in r.getReadable(1)]
|
||||
#Fitting and plotting
|
||||
i, a, b = 0, 0, 0
|
||||
while charge[i] < (max(charge) * 0.20) : a = i; i = i + 1
|
||||
while charge[i] < (max(charge) * 0.80) : b = i; i = i + 1
|
||||
while charge[i] < (max(charge) * 0.60) : b = i; i = i + 1
|
||||
x = beamphase[a:b+1]
|
||||
y = charge[a:b+1]
|
||||
p = (a0, a1) = fit_polynomial(y, x, 1)
|
||||
f = PolynomialFunction(p)
|
||||
x1 = -a0 / a1 if a1 != 0 else 0.0
|
||||
x2 = beamphase[charge.index(max(charge))]
|
||||
#x2 = beamphase[charge.index(max(charge))]
|
||||
x2 = beamphase[b+1]
|
||||
x_fit = frange(x1, x2, (x2-x1), True)
|
||||
y_fit = [f.value(val) for val in x_fit]
|
||||
plt.addSeries(LinePlotErrorSeries("Fit", Color.green))
|
||||
|
||||
Reference in New Issue
Block a user