import ch.psi.pshell.epics.ChannelDouble as ChannelDouble A1 = ChannelDouble("Actuator1", "SARUN07-UIND030:I-SET") S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:HAMP-INTENSITY-CAL") A1.initialize() S1.initialize() A1_init = A1.read() A1i = -1.0 A1f = 1.2 nstep = 22 lat = 0.11 nav = 50 plt = plot(None, title="Output")[0] plt.clear() plt.setStyle(plt.Style.ErrorY) plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red)) def after_sample(record, scan): plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev) try: S1_averager = create_averager(S1, nav, lat) time.sleep(1.0) r = lscan(A1, S1_averager, A1i, A1f, nstep, latency=2.0, after_read = after_sample) Act1 = r.getPositions(0) S1mean = [val.mean for val in r.getReadable(0)] S1rms = [val.stdev for val in r.getReadable(0)] finally: A1.write(A1_init) A1.close() S1.close()