Script execution
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user