Files
dev/script/HarmonicScan.py
2020-06-18 09:16:37 +02:00

47 lines
1.2 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
if get_exec_pars().source == CommandSource.ui:
ID_ENERGY = 1250
HALFWIDTH = 10
STEP = 0.5
MODE = "Manual"
DRY_MODE = True
try:
if not DRY_MODE:
caput('X07MA-PHS-E:OPT', 'PGM')
energy_id.write(ID_ENERGY)
wait_device(energy_done, 1 )
sensors = [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', energy]
if MODE =="C+":
set_pol_cplus()
if MODE =="C-":
set_pol_cminus()
if MODE == "LH":
set_pol_lin(0.0)
elif MODE == "LV":
set_pol_lin(90.0)
else:
sensors = [sin, energy]
ret = lscan(energy, sensors, ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, latency = 0.3)
xdata = ret.getPositions(0)
ydata = ret.getReadable(0)
ymin = min(ydata)
e0 = xdata[ydata.index(min(ydata))]
new_offset =ID_ENERGY e0 + pol_offset.take()
print "E0=",xminmin," ymin=",ymin," Offset=",new_offset
set_return(new_offset)
except:
print("Aborting...")
raise
finally:
if not DRY_MODE:
caput('X07MA-PHS-E:OPT', 'PGM+ID')