55 lines
1.5 KiB
Python
55 lines
1.5 KiB
Python
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
|
|
import ch.psi.pshell.epics.Camtool as Camtool
|
|
|
|
if get_exec_pars().source == CommandSource.ui:
|
|
start = 0.0
|
|
stop = 180.0
|
|
step = 30.0
|
|
nb = 2
|
|
lat = 0.100
|
|
else:
|
|
start = args[0]
|
|
stop = args[1]
|
|
step = args[2]
|
|
nb = int(args[3])
|
|
lat = args[4]
|
|
|
|
disp = 0.32
|
|
energy0 = 6.5
|
|
|
|
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM")
|
|
phase.config.minValue =-45.0
|
|
phase.config.maxValue = 360.0
|
|
phase.config.resolution = 0.5
|
|
phase.initialize()
|
|
|
|
#camtool = Camtool("sflca:10000")
|
|
#camtool.startPipeline("simulated")
|
|
#camtool.startReceiver()
|
|
#x = camtool.getValue("x_com")
|
|
#dx = camtool.getValue("x_rms")
|
|
x = Channel("SINEG01-DSCR190:X-SIM", type = 'd', alias='SCR-X')
|
|
dx = Channel("SINEG01-DSCR190:DX-SIM", type = 'd', alias='SCR-DX')
|
|
|
|
|
|
try:
|
|
xb = create_averager(x, nb, 0.100)
|
|
dxb = create_averager(dx, nb, 0.100)
|
|
r = lscan(phase, [xb, dxb], start, stop, step , latency=lat)
|
|
rf_phase = r.getPositions(0)
|
|
E = [val.mean/1000.0/disp*energy0 for val in r.getReadable(0)]
|
|
dE = [val.mean/1000.0/disp*energy0 for val in r.getReadable(1)]
|
|
finally:
|
|
phase.close()
|
|
# camtool.close()
|
|
|
|
print rf_phase
|
|
xx = [0.0, 30.0, 60.0, 90.0, 120.0, 150.0, 180.0]
|
|
print xx
|
|
|
|
p = plot(None,name="Phase scan")[0]
|
|
p.addSeries(LinePlotSeries("data"))
|
|
p.getSeries(0).setData(xx, E)
|
|
p.getSeries(1).setData(rf_phase, dE)
|
|
#plot((E, dE), xdata = rf_phase, title="Phase scan")
|