""" 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 import ch.psi.pshell.epics.ControlledVariable as PV_cv # controlled variabales #cv_rf_phase = PV("phase_ref", SECTION + "-RLLE-DSP:PHASE-REFERENCE") #cv_rf_amplt = PV("amplt_ref", SECTION + "-RLLE-DSP:AMPLT-REFERENCE") cv_rf_phase = PV_cv("phase_ref", SECTION + "-RSYS:SET-VSUM-PHASE", SECTION + "-RLLE-DSP:FB-PHASE-M") cv_rf_amplt = PV_cv("amplt_ref", SECTION + "-RSYS:SET-ACC-VOLT" , SECTION + "-RSYS:GET-AMPLT-REACHED") # 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() scan_result = 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), start, stop, step , latency=latency, title="Jitter Scan") # 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 plot_files = get_plot_snapshots("Jitter Scan") time.sleep(1.0) elogllrf("Jitter Scan", msg,"Measurement", "RF Stability", SECTION, plot_files) # save the entry in the logbook