126 lines
3.5 KiB
Python
Executable File
126 lines
3.5 KiB
Python
Executable File
"""
|
|
File: jitter_vs_avggatelength_scan.py
|
|
Author: KR84
|
|
Copyright PSI LLRF, 2016
|
|
|
|
Purpose Record RF system jitters vs. average gate length and store / archive data
|
|
Preconditions - LLRF receives triggers. All changed gate settings are RESTORED after the scan.
|
|
|
|
"""
|
|
|
|
#################################################################
|
|
# Parameter SECTION, change it to your RF station before run
|
|
SECTION = "SINDI01"
|
|
REFxx = "REF10"
|
|
#################################################################
|
|
|
|
|
|
|
|
|
|
# re-define filename, such that the SECTION is also in the filename
|
|
set_exec_pars(path = "{data}/{year}_{month}/{date}/{date}_{time}_" + str(SECTION) + "_{name}")
|
|
|
|
|
|
#################################################################################
|
|
# define all PVs
|
|
#import ch.psi.pshell.epics.ProcessVariable as PV
|
|
import ch.psi.pshell.epics.ChannelDouble as PV
|
|
|
|
# controlled variabales
|
|
cv_gate_stop = PV("gate_stop - 0.15 = duration [us]", SECTION + "-RLLE-" + REFxx + ":SIG-AVG-STOP")
|
|
|
|
# measured variables
|
|
mv_ref_jit_amplt = PV("REF_amplt_jit" ,SECTION + "-RLLE-" + REFxx + ":SIG-AMPLT-JIT-P2P-REL")
|
|
mv_ref_jit_phase = PV("REF_phase_jit" ,SECTION + "-RLLE-" + REFxx + ":SIG-PHASE-JIT-P2P")
|
|
|
|
|
|
# auxiliary measured variables, but not scanned
|
|
auxv_gate_start = PV("gate_start", SECTION + "-RLLE-" + REFxx + ":SIG-AVG-START")
|
|
auxv_p2p_cnt = PV("p2p_count", SECTION + "-RLLE-" + REFxx + ":SIG-P2PCOUNT")
|
|
auxv_rfrate = PV("RF_RATE" ,SECTION + "-RLLE-EVR:CHCK-EVNT")
|
|
|
|
|
|
# initialize all PVs
|
|
cv_gate_stop.initialize()
|
|
mv_ref_jit_amplt.initialize()
|
|
mv_ref_jit_phase.initialize()
|
|
|
|
auxv_gate_start.initialize()
|
|
auxv_p2p_cnt.initialize()
|
|
auxv_rfrate.initialize()
|
|
|
|
|
|
|
|
#################################################################################
|
|
# scan
|
|
|
|
orig_avg_start = auxv_gate_start.read()
|
|
orig_avg_stop = cv_gate_stop.read()
|
|
p2pcount = auxv_p2p_cnt.read()
|
|
rfrate = auxv_rfrate.read()
|
|
|
|
latency = 1.5 * p2pcount / rfrate
|
|
|
|
# set start/stop gate for initial point:
|
|
auxv_gate_start.write(0.15)
|
|
cv_gate_stop.write(0.155)
|
|
|
|
time.sleep(latency)
|
|
|
|
scan_result = lscan(cv_gate_stop, (mv_ref_jit_amplt,mv_ref_jit_phase,), 0.155, 8.005, 0.05 , latency=latency, title="Jitter Scan vs. avg gate length")
|
|
|
|
|
|
#################################################################################
|
|
# restore original gate
|
|
cv_gate_stop.write(orig_avg_stop)
|
|
auxv_gate_start.write(orig_avg_start)
|
|
|
|
# close all PVs
|
|
cv_gate_stop.close()
|
|
mv_ref_jit_amplt.close()
|
|
mv_ref_jit_phase.close()
|
|
|
|
auxv_gate_start.close()
|
|
auxv_p2p_cnt.close()
|
|
auxv_rfrate.close()
|
|
|
|
|
|
#################################################################################
|
|
# analyze
|
|
|
|
|
|
|
|
#Setting attributes to the scan group
|
|
path = get_exec_pars().group
|
|
set_attribute(path, "SECTION", SECTION)
|
|
"""
|
|
set_attribute(path, "ref_jit_amplt", ref_jit_amplt)
|
|
set_attribute(path, "ref_jit_phase", ref_jit_phase)
|
|
"""
|
|
|
|
set_attribute(path, "RF Rate", rfrate)
|
|
set_attribute(path, "P2PCOUNT", p2pcount)
|
|
|
|
|
|
|
|
|
|
#################################################################################
|
|
# ELOG
|
|
|
|
msg = "RF rep rate = " + str(rfrate)[:6] + "Hz"
|
|
msg = msg + "\nP2PCOUNT = " + str(p2pcount)[:6]
|
|
msg = msg + "\n---------------------------------------------------------"
|
|
msg = msg + "\n\nData file: " + get_exec_pars().path
|
|
|
|
print msg
|
|
|
|
# save the entry in the logbook
|
|
# need some sleep before and after to allow plots to be updated and to be stored to disk
|
|
time.sleep(1.0)
|
|
plot_files = get_plot_snapshots("Jitter Scan vs. avg gate length","png")
|
|
time.sleep(1.0)
|
|
elogllrf("Jitter Scan vs. avg gate length", msg,"Measurement", "RF Stability", SECTION, plot_files)
|
|
|
|
|
|
|