Startup
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
|
||||
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
station = "SINSB04"
|
||||
station = "SINEG01"
|
||||
else:
|
||||
station = args[0]
|
||||
|
||||
@@ -10,9 +10,9 @@ 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")
|
||||
bpm_ch = caget(station + "-RSYS:DBPM")
|
||||
disp = caget(bpm_ch + ":DISPERSION")
|
||||
energy0 = caget(bpm_ch + ":ENERGY")
|
||||
scr_ch = caget(station + "-RSYS:DSCR")
|
||||
disp = caget(scr_ch + ":DISPERSION")
|
||||
energy0 = caget(scr_ch + ":ENERGY")
|
||||
|
||||
phase = ControlledVariable("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE")
|
||||
phase.config.minValue =-45.0
|
||||
@@ -20,37 +20,34 @@ phase.config.maxValue = 360.0
|
||||
phase.config.resolution = 0.5
|
||||
phase.initialize()
|
||||
|
||||
V = Channel(station + "-RSYS:GET-VSUM-AMPLT", type = 'd', alias='Amplitude Readback')
|
||||
P = Channel(station + "-RSYS:GET-KLY-POWER", type = 'd', alias='Power Readback')
|
||||
x = Channel(bpm_ch + ":X1", type = 'd', alias='BPM-X')
|
||||
V = Channel(station + "-RSYS:GET-VSUM-AMPLT", type = 'd', alias='Amplitude Readback')
|
||||
P = Channel(station + "-RSYS:GET-KLY-POWER", type = 'd', alias='Power Readback')
|
||||
q = Channel("SINEG01-DICT215:B1_CHARGE", type = 'd', alias='Charge')
|
||||
x = Stream(scr_ch + ":camtool.pipeline.x_stats_gr.com_egu", type = 'd', alias='SCR-X')
|
||||
dx = Stream(scr_ch + ":camtool.pipeline.x_stats_gr.rms_egu", type = 'd', alias='SCR-DX')
|
||||
|
||||
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'))
|
||||
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'))
|
||||
caput(station + "-RSYS:GET-FIT-CHARGE-ARRAY", to_array([0.0],'d'))
|
||||
caput(station + "-RSYS:GET-REF-VSUM-PHASE", float('nan'))
|
||||
caput(station + "-RSYS:CALC-VSUM-PHASE-OFFSET", float('nan'))
|
||||
caput(station + "-RSYS:CALC-VSUM-AMPLT-SCALE" , float('nan'))
|
||||
caput(station + "-RSYS:CALC-VOLT-POWER-SCALE" , float('nan'))
|
||||
|
||||
#update the plot dynamically
|
||||
arr_phase,arr_energy = [],[]
|
||||
arr_phase,arr_charge = [],[]
|
||||
def after(rec):
|
||||
global disp, energy0
|
||||
arr_phase.append(rec.positions[0])
|
||||
arr_energy.append(rec.values[1].mean/1000.0/disp*energy0)
|
||||
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(arr_energy,'d'))
|
||||
arr_charge.append(rec.values[1].mean)
|
||||
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(arr_phase, 'd'))
|
||||
caput(station + "-RSYS:GET-CHARGE-ARRAY", to_array(arr_charge,'d'))
|
||||
|
||||
try:
|
||||
Vb = create_averager(V, nb, 0.100)
|
||||
xb = create_averager(x, nb, 0.100)
|
||||
r = lscan(phase, [Vb, xb], start, stop, step , latency=lat, after_read = after)
|
||||
qb = create_averager(q, nb, 0.100)
|
||||
r = lscan(phase, [Vb, qb], start, stop, step , latency=lat, after_read = after)
|
||||
rf_phase = r.getPositions(0)
|
||||
energy = [val.mean/1000.0/disp*energy0 for val in r.getReadable(1)]
|
||||
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(energy, 'd'))
|
||||
charge = [val.mean for val in r.getReadable(1)]
|
||||
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
|
||||
caput(station + "-RSYS:GET-CHARGE-ARRAY", to_array(charge, 'd'))
|
||||
phase_fit_max = None
|
||||
try:
|
||||
(energy_max, angular_frequency, phase0, in_range, phase_fit_max, fit_x, fit_y) = hfit(energy , xdata = rf_phase)
|
||||
|
||||
Reference in New Issue
Block a user