154 lines
5.6 KiB
Python
154 lines
5.6 KiB
Python
"""
|
|
File: jitter_scan.py
|
|
Author: KR84
|
|
Copyright PSI LLRF, 2016
|
|
|
|
Purpose Record RF system jitters and store / archive data
|
|
Preconditions - RF station is running
|
|
- AVG gates are set-up for correct length for particular station, P2P count is set to 100 for all channels + vsum
|
|
- AMPLT-REFERENCE is set to the klystron saturation point
|
|
- feedbacks are in closed loop (both)
|
|
- you know the settling time of the feedback + 100 P2P-count + 100 Hz, if required, change it below
|
|
-
|
|
|
|
"""
|
|
|
|
#################################################################
|
|
# Parameter SECTION, change it to your RF station before run
|
|
SECTION = "SINSB02"
|
|
#################################################################
|
|
|
|
|
|
|
|
|
|
|
|
# some other parameters
|
|
# for 100 Hz and P2P-count = 100 this can be 1.1 seconds
|
|
latency = 0.3
|
|
start = -170.0
|
|
stop = 180.0
|
|
step = 10.0
|
|
|
|
print "SECTION = ", SECTION
|
|
print "Start = ", start
|
|
print "Stop = ", stop
|
|
print "Step = ", step
|
|
|
|
|
|
# re-define filename, such that the SECTION is also in the filename
|
|
set_context(path = "{data}/{year}_{month}/{date}/{date}_{time}_" + str(SECTION) + "_{name}")
|
|
|
|
|
|
# define all PVs
|
|
import ch.psi.pshell.epics.ProcessVariable as PV
|
|
|
|
# controlled variabales
|
|
cv_rf_phase = PV("phase_ref", SECTION + "-RSYS:SET-VSUM-PHASE")
|
|
cv_rf_amplt = PV("amplt_ref", SECTION + "-RSYS:SET-ACC-VOLT")
|
|
|
|
# measured variables
|
|
mv_ref_jit_amplt = PV("REF_amplt_jit" ,SECTION + "-RLLE-REF10:SIG-AMPLT-JIT-P2P-REL")
|
|
mv_ref_jit_phase = PV("REF_phase_jit" ,SECTION + "-RLLE-REF10:SIG-PHASE-JIT-P2P")
|
|
|
|
mv_iqm_jit_amplt = PV("IQM_amplt_jit" ,SECTION + "-RIQM-DCP10:FOR-AMPLT-JIT-P2P-REL")
|
|
mv_iqm_jit_phase = PV("IQM_phase_jit" ,SECTION + "-RIQM-DCP10:FOR-PHASE-JIT-P2P")
|
|
|
|
mv_pre_jit_amplt = PV("PRE_amplt_jit" ,SECTION + "-RPRE-DCP10:FOR-AMPLT-JIT-P2P-REL")
|
|
mv_pre_jit_phase = PV("PRE_phase_jit" ,SECTION + "-RPRE-DCP10:FOR-PHASE-JIT-P2P")
|
|
|
|
mv_kly_jit_amplt = PV("KLY_amplt_jit" ,SECTION + "-RKLY-DCP10:FOR-AMPLT-JIT-P2P-REL")
|
|
mv_kly_jit_phase = PV("KLY_phase_jit" ,SECTION + "-RKLY-DCP10:FOR-PHASE-JIT-P2P")
|
|
|
|
|
|
# initialize all PVs
|
|
cv_rf_phase.initialize()
|
|
cv_rf_amplt.initialize()
|
|
mv_ref_jit_amplt.initialize()
|
|
mv_ref_jit_phase.initialize()
|
|
mv_iqm_jit_amplt.initialize()
|
|
mv_iqm_jit_phase.initialize()
|
|
mv_pre_jit_amplt.initialize()
|
|
mv_pre_jit_phase.initialize()
|
|
mv_kly_jit_amplt.initialize()
|
|
mv_kly_jit_phase.initialize()
|
|
|
|
# define current amplitude as saturation amplitude, then define three scans
|
|
amplt_sat = cv_rf_amplt.read()
|
|
amplt_m5 = 0.95 * amplt_stop
|
|
amplt_m10 = 0.9 * amplt_stop
|
|
|
|
#cv_rf_amplt.write(amplt_sat)
|
|
#time.sleep(1.0)
|
|
#scan_result_sat = lscan(cv_rf_phase, (mv_ref_jit_amplt,mv_ref_jit_phase,mv_iqm_jit_amplt,mv_iqm_jit_phase,mv_pre_jit_amplt,mv_pre_jit_phase,mv_kly_jit_amplt,mv_kly_jit_phase), -170, 180, 10, latency=latency, title="Jitter Scan")
|
|
#cv_rf_amplt.write(amplt_m5)
|
|
#time.sleep(1.0)
|
|
#scan_result_m5 = lscan(cv_rf_phase, (mv_ref_jit_amplt,mv_ref_jit_phase,mv_iqm_jit_amplt,mv_iqm_jit_phase,mv_pre_jit_amplt,mv_pre_jit_phase,mv_kly_jit_amplt,mv_kly_jit_phase), -170, 180, 10, latency=latency, title="Jitter Scan")
|
|
#cv_rf_amplt.write(amplt_m10)
|
|
#time.sleep(1.0)
|
|
#scan_result_m10 = lscan(cv_rf_phase, (mv_ref_jit_amplt,mv_ref_jit_phase,mv_iqm_jit_amplt,mv_iqm_jit_phase,mv_pre_jit_amplt,mv_pre_jit_phase,mv_kly_jit_amplt,mv_kly_jit_phase), -170, 180, 10, latency=latency, title="Jitter Scan")
|
|
|
|
|
|
scan_result = ascan((cv_rf_phase, cv_rf_amplt), (mv_ref_jit_amplt,mv_ref_jit_phase,mv_iqm_jit_amplt,mv_iqm_jit_phase,mv_pre_jit_amplt,mv_pre_jit_phase,mv_kly_jit_amplt,mv_kly_jit_phase), (-170.0, 0.2), (180.0, 0.3), (10.0, 0.05) , latency=latency, title="Jitter Scan", zigzag=False)
|
|
|
|
# close all PVs
|
|
cv_rf_phase.close()
|
|
cv_rf_amplt.close()
|
|
mv_ref_jit_amplt.close()
|
|
mv_ref_jit_phase.close()
|
|
mv_iqm_jit_amplt.close()
|
|
mv_iqm_jit_phase.close()
|
|
mv_pre_jit_amplt.close()
|
|
mv_pre_jit_phase.close()
|
|
mv_kly_jit_amplt.close()
|
|
mv_kly_jit_phase.close()
|
|
|
|
|
|
|
|
|
|
# analyze
|
|
ref_jit_amplt_mean = mean(scan_result.getReadable(0))
|
|
ref_jit_phase_mean = mean(scan_result.getReadable(1))
|
|
|
|
iqm_jit_amplt_mean = mean(scan_result.getReadable(2))
|
|
iqm_jit_phase_mean = mean(scan_result.getReadable(3))
|
|
|
|
pre_jit_amplt_mean = mean(scan_result.getReadable(4))
|
|
pre_jit_phase_mean = mean(scan_result.getReadable(5))
|
|
|
|
kly_jit_amplt_mean = mean(scan_result.getReadable(6))
|
|
kly_jit_phase_mean = mean(scan_result.getReadable(7))
|
|
|
|
|
|
#Setting attributes to the scan group
|
|
path = get_context().group
|
|
set_attribute(path, "SECTION", SECTION)
|
|
set_attribute(path, "ref_jit_amplt_mean", ref_jit_amplt_mean)
|
|
set_attribute(path, "ref_jit_phase_mean", ref_jit_phase_mean)
|
|
|
|
set_attribute(path, "iqm_jit_amplt_mean", iqm_jit_amplt_mean)
|
|
set_attribute(path, "iqm_jit_phase_mean", iqm_jit_phase_mean)
|
|
|
|
set_attribute(path, "pre_jit_amplt_mean", pre_jit_amplt_mean)
|
|
set_attribute(path, "pre_jit_phase_mean", pre_jit_phase_mean)
|
|
|
|
set_attribute(path, "kly_jit_amplt_mean", kly_jit_amplt_mean)
|
|
set_attribute(path, "kly_jit_phase_mean", kly_jit_phase_mean)
|
|
|
|
|
|
|
|
# ELOG
|
|
#msg = scan_result.print("\t")
|
|
msg = ""
|
|
msg = msg + "\nMean:\nREF amplt\t" + str(ref_jit_amplt_mean)[:5] + "\nREF phase\t" + str(ref_jit_phase_mean)[:5] + "\n\nIQM amplt\t" + str(iqm_jit_amplt_mean)[:5] + "\nIQM phase\t" + str(iqm_jit_phase_mean)[:5] + "\n\nPRE amplt\t" + str(pre_jit_amplt_mean)[:5] + "\npre phase\t" + str(pre_jit_phase_mean)[:5] + "\n\nKLY amplt\t" + str(kly_jit_amplt_mean)[:5] + "\nkly phase\t" + str(kly_jit_phase_mean)[:5]
|
|
msg = msg + "\n\nFile: " + get_context().path
|
|
|
|
print msg
|
|
|
|
# save the entry in the logbook
|
|
#plot_files = get_plot_snapshots("Jitter Scan")
|
|
#time.sleep(1.0)
|
|
#elogllrf("Jitter Scan", msg,"Measurement", "RF Stability", SECTION, plot_files)
|
|
|
|
|
|
|