Files
x07ma/script/HarmonicScan.py
gac-x07ma 9fe9b50fe8
2022-08-08 09:46:49 +02:00

54 lines
1.5 KiB
Python

import java.awt.Color as Color
if get_exec_pars().source == CommandSource.ui:
ID_ENERGY = 1250
HALFWIDTH = 10
STEP = 0.5
MODE = "Manual"
DRY_MODE = False
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)
wait_pol_done(1.0) # new script to wait for polarization. Wait_device does not work for this channel
current_offset = pol_offset.take()
else:
sensors = [sin, energy]
current_offset = 0.0
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 + current_offset
print "E0=",e0," ymin=",ymin," Offset=",new_offset
p=get_plots()[0]
p.addMarker(e0, p.AxisId.X, "%0.2f" % e0, Color.BLUE)
set_return(new_offset)
except:
print("Aborting...")
raise
finally:
if not DRY_MODE:
caput('X07MA-PHS-E:OPT', 'PGM+ID')