Startup
This commit is contained in:
@@ -6,16 +6,14 @@ if get_exec_pars().source == CommandSource.ui:
|
||||
else:
|
||||
station = args[0]
|
||||
bpm_ch = args[1]
|
||||
|
||||
|
||||
start = caget(station + "-RSYS:SET-SCAN-START")
|
||||
stop = caget(station + "-RSYS:SET-SCAN-STOP")
|
||||
step = caget(station + "-RSYS:SET-SCAN-STEP")
|
||||
lat = caget(station + "-RSYS:SET-SCAN-WAIT-TIME")
|
||||
nb = caget(station + "-RSYS:SET-NUM-AVERAGE")
|
||||
#disp = caget(bpm_ch + ":DISPERSION")
|
||||
#energy0 = caget(bpm_ch + ":ENERGY")
|
||||
disp = 1
|
||||
energy0 = 1000
|
||||
disp = caget(bpm_ch + ":DISPERSION")
|
||||
energy0 = caget(bpm_ch + ":ENERGY")
|
||||
|
||||
phase = ControlledVariable("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:SET-VSUM-PHASE")
|
||||
phase.config.minValue =-180.0
|
||||
@@ -27,8 +25,6 @@ V = Channel(station + "-RSYS:GET-VSUM-AMPLT", type = 'd', alias='Amplitude Read
|
||||
P = Channel(station + "-RSYS:GET-KLY-POWER", type = 'd', alias='Power Readback')
|
||||
x = Channel(bpm_ch + ":X1-SIMU", type = 'd', alias='BPM-X')
|
||||
|
||||
phase0 = phase.read()
|
||||
|
||||
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", to_array([0.0],'d'))
|
||||
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", to_array([0.0],'d'))
|
||||
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", float('nan'))
|
||||
@@ -36,6 +32,8 @@ caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", float('nan'))
|
||||
caput(station + "-RSYS:GET-ONCREST-E-GAIN", float('nan'))
|
||||
caput(station + "-RSYS:GET-ONCREST-KLY-POWER", float('nan'))
|
||||
|
||||
phase0 = phase.read()
|
||||
|
||||
#update the plot dynamically
|
||||
arr_phase,arr_energy = [],[]
|
||||
def after(rec):
|
||||
@@ -52,14 +50,11 @@ try:
|
||||
energy = [val.mean/1000.0/disp*energy0 for val in r.getReadable(0)]
|
||||
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(energy, 'd'))
|
||||
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
|
||||
run("CPython/wrapper")
|
||||
(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase)
|
||||
#try:
|
||||
#(energy_max, angular_frequency, phase0, in_range, ph_crest, fit_x, fit_y) = hfit(energy , xdata = rf_phase)
|
||||
#run("CPython/wrapper")
|
||||
#(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase)
|
||||
#except:
|
||||
# raise Exception("Fit failure")
|
||||
try:
|
||||
run("CPython/wrapper")
|
||||
(fit_amplitude, fit_phase_deg, fit_offset, ph_crest, fit_x, fit_y) = hfitoff(energy , rf_phase)
|
||||
except:
|
||||
raise Exception("Fit failure")
|
||||
plot([energy, fit_y], ["data", "fit"], [rf_phase, fit_x])
|
||||
energy_max = fit_amplitude - fit_offset
|
||||
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", ph_crest)
|
||||
@@ -68,7 +63,7 @@ try:
|
||||
caput(station + "-RSYS:GET-FIT-ENERGY-ARRAY", fit_y)
|
||||
phase_min, phase_max = min(rf_phase), max(rf_phase)
|
||||
if not (phase_min <= ph_crest <= phase_max):
|
||||
raise Exception("Fit maximum outside scan range")
|
||||
raise Exception("On-crest phase outside scan range")
|
||||
phase.write(ph_crest)
|
||||
time.sleep(lat)
|
||||
Ampl = V.read()
|
||||
|
||||
Reference in New Issue
Block a user