Files
sf-op/script/Photonics/PhaseShifterScan.py
2017-11-02 08:53:26 +01:00

39 lines
1.2 KiB
Python

CAMERA = "SARBD01-DSCR110"
GAP = "SARUN10-UPHS060"
SAMPLES = 20
TOLERANCE = 0.01
TIMEOUT = 10.0
#shared stream - make sure the camera is running on a screenpanel on the same console!
cam_server.start(CAMERA + "_sp1", True)
intensity = cam_server.stream.getChild("intensity")
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, 20, 40, latency=1.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)