From 3bb27e83bf511c1077c84830119199e181afea3e Mon Sep 17 00:00:00 2001 From: sfop Date: Tue, 5 Jul 2016 10:17:29 +0200 Subject: [PATCH] Script execution --- script/RFscan/phase_scan_caqtdm_dv.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/script/RFscan/phase_scan_caqtdm_dv.py b/script/RFscan/phase_scan_caqtdm_dv.py index edcb5ea..2f75c97 100644 --- a/script/RFscan/phase_scan_caqtdm_dv.py +++ b/script/RFscan/phase_scan_caqtdm_dv.py @@ -1,14 +1,15 @@ import ch.psi.pshell.epics.ControlledVariable as ControlledVariable -prefix = args[0] +prefix = args[0] + "-RSYS" + start = caget(prefix + ":SET-SCAN-START") stop = caget(prefix + ":SET-SCAN-STOP") step = caget(prefix + ":SET-SCAN-STEP") lat = caget(prefix + ":SET-SCAN-WAIT-TIME") nb = caget(prefix + ":SET-NUM-AVERAGE") -bpm_ch = caget(prefix + ":BPM") +bpm_ch = caget(prefix + ":DBPM") disp = caget(bpm_ch + ":DISPERSION") -energy = caget(bpm_ch + ":ENERGY") +energy0 = caget(bpm_ch + ":ENERGY") rf_phase_var = ControlledVariable("Phase", prefix + ":SET-VSUM-PHASE-SIM", prefix + ":GET-VSUM-PHASE-SIM") rf_phase_var.config.minValue =-180.0 @@ -28,14 +29,19 @@ try: r = lscan(rf_phase_var, [rf_ampl_rbk, bpm_x], start, stop, step , latency=lat, passes = nb, after_read = after) rf_phase = r.getPositions(0) - energy = r.getReadable(1) / 1000 / disp * energy + energy = [x/1000.0/disp*energy0 for x in r.getReadable(1)] + caput(prefix + ":GET-PHASE-ARRAY", rf_phase) + caput(prefix + ":GET-ENERGY-ARRAY", energy) phase_fit_max = None try: - (energy_max, angular_frequency, phase0, phase_fit_max) = hfit(energy , xdata = rf_phase) + (energy_max, angular_frequency, phase0, phase_fit_max, fit_x, fit_y) = hfit(energy , xdata = rf_phase) except: raise Exception("Fit failure") + caput(prefix + ":GET-FIT-PHASE-ARRAY", fit_x) + caput(prefix + ":GET-FIT-ENERGY-ARRAY", fit_y) + phase_min, phase_max = min(phase), max(phase) if not (phase_min <= phase_fit_max <= phase_max): raise Exception("Fit maximum outside scan range")