Files
sf-op/script/RFscan/gun_scan1.py
2017-01-19 15:33:37 +01:00

37 lines
1.3 KiB
Python

import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
start = caget("SINEG01-RSYS:SET-SCAN-START")
stop = caget("SINEG01-RSYS:SET-SCAN-STOP")
step = caget("SINEG01-RSYS:SET-SCAN-STEP")
nb = caget("SINEG01-RSYS:SET-NUM-AVERAGE")
lat = caget("SINEG01-RSYS:SET-SCAN-WAIT-TIME")
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()
#st = Stream("ICTstream", dispatcher)
#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE-SIM", 1, 0)
#st.initialize()
q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias='ICT-Q')
try:
qb = create_averager(q, nb, 0.100)
r = lscan(phase, (qb), start, stop, step, latency=lat)
rf_phase = r.getPositions(0)
#charge = [val.mean for val in r.getReadable(0)]
charge = [val.mean for val in r.getReadable(0)]
caput("SINEG01-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
caput("SINEG01-RSYS:GET-CHARGE-ARRAY", to_array(charge, 'd'))
finally:
phase.close()
q.close()
#st.close()
# Here the user needs to pick a phase as reference phase (onset of charge emission)
phase_ref = 80.0
phase_offset = - phase_ref
caput("SINEG01-RSYS:CALC-VSUM-PHASE-OFFSET", phase_offset)