Files
sf-op/script/Photonics/PhaseShifterScanGas.py
root 8d9794c431
2017-11-27 08:31:31 +01:00

35 lines
1.1 KiB
Python

GAP = "SARUN07-UPHS060"
SAMPLES = 20
TOLERANCE = 0.01
TIMEOUT = 10.0
intensity = Channel("SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US", alias = "gas det")
gap = Channel(GAP + ":GAP_SP", alias = "gap")
readout = Channel(GAP + ":GAP")
av = create_averager(intensity, SAMPLES, interval = -1, name = None)
def before(position, scan):
caput(GAP + ":GO", 1)
start = time.time()
while abs(readout.read() - gap.read()) > TOLERANCE:
time.sleep(0.1)
if time.time() - start > TIMEOUT:
raise Exception ("Timeout waiting gap change")
ret = lscan (gap, av, 17.5, 19.5, 20, latency=20.0, before_read=before)
#run("CPython/wrapper")
#xdata = ret.getPositions(0)
#ydata = ret.getReadable(0)
#(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(ydata , xdata)
#print fit_amplitude, fit_phase_deg, fit_offset
#plt = get_plots()[0]
#if plt is not None:
# plt.addSeries(LinePlotErrorSeries("fit"))
# plt.getSeries(1).setData(fit_x, fit_y)
# plt.getSeries(1).setPointsVisible(False)
# plt.setLegendVisible(True)