Script execution

This commit is contained in:
voulot_d
2017-08-24 08:59:58 +02:00
parent 6caab49d20
commit d60872d277
+63
View File
@@ -0,0 +1,63 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
run("CPython/wrapper")
#base_name = "SINEG01-DICT009" # "S10DI01-DICT113" "SARMA01-DICT482" "SARBD01-DICT599"
#dev_name = "SINEG01-DICT215" # "S10DI01-DICT025" "SARMA01-DICT090" "SARBD01-DICT030"
#t = ChannelDouble("fine delay (ns)", base_name + "-EVR0:UnivDlyModule0-Delay0-SP")
#q = ChannelDouble("charge (pC)", dev_name + ":B1_CHARGE")
#V = ChannelDouble("DC output (V)", dev_name + ":B1_VOLTAGE")
t = ChannelDouble("fine delay (ns)", "SINEG01-DICT215:Pul1-Delay-SP-SIM")
q = ChannelDouble("charge (pC)", "SINEG01-DICT215:AL1-ICT-CHARGE-SIM")
V = ChannelDouble("DC output (V)", "SINEG01-DICT215:AL1-ICT-VOLTAGE-SIM")
t.initialize()
q.initialize()
V.initialize()
t0 = t.read()
start = 2.2
stop = 12.7
step = 0.1
nb = 5
lat = 0.150
try:
q_averager = create_averager(q, nb, lat)
V_averager = create_averager(V, nb, lat)
V_averager.monitored=True
r = lscan(t, (q_averager, V_averager), start, stop, step, latency=lat)
delay = r.getPositions(0)
charge = [val.mean for val in r.getReadable(0)]
chargerms = [val.stdev for val in r.getReadable(0)]
volt = [val.mean for val in r.getReadable(1)]
voltrms = [val.stdev for val in r.getReadable(1)]
finally:
t.write(t0)
t.close()
q.close()
V.close()
try:
i_max = charge.index(max(charge))
min_i, max_i = max(i_max-10, 0), min(i_max+11, len(charge))
(delay_max, charge_max, delay_fit, charge_fit) = extremum(delay[min_i:max_i], charge[min_i:max_i])
print delay_max, charge_max
except:
raise Exception("Fit failure")
plt = plot(None, title="Output")[0]
plt.clear()
plt.removeMarker(None)
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Charge", Color.red))
plt.addSeries(LinePlotErrorSeries("DC output", Color.yellow, 2))
plt.getAxis(plt.AxisId.X).setLabel("Fine delay (ns)")
plt.getAxis(plt.AxisId.Y).setLabel("Charge (pC)")
plt.getAxis(plt.AxisId.Y2).setLabel("DC output (V)")
plt.setLegendVisible(True)
plt.addSeries(LinePlotErrorSeries("Charge Fit", plt.getSeries(0).color))
plt.getSeries(2).setData(delay_fit, charge_fit)
plt.getSeries(2).setPointsVisible(False)
plt.addMarker(delay_max, plt.AxisId.X, "%3.2f" % delay_max, plt.getSeries(0).color)