Closedown

This commit is contained in:
voulot_d
2017-01-27 16:36:10 +01:00
parent 329ca31e90
commit 0dc9ecdfd4
3 changed files with 9 additions and 42 deletions

View File

@@ -9,21 +9,16 @@ if get_exec_pars().source == CommandSource.ui:
else:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
step = args[2]
nb = int(args[3])
lat = args[4]
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM", "SINEG01-RSYS:GET-VSUM-PHASE-SIM")
phase.config.minValue =-45.0
phase.config.maxValue = 360.0
phase.config.resolution = 0.5
phase.initialize()
V = Channel("SINEG01-RSYS:GET-VSUM-AMPLT-SIM", type = 'd', alias='Amplitude Readback')
P = Channel("SINEG01-RSYS:GET-KLY-POWER-SIM", type = 'd', alias='Power Readback')
#camtool = Camtool(url)
#camtool.startPipeline(camera_name)
#camtool.startReceiver()
@@ -39,40 +34,12 @@ try:
rf_phase = r.getPositions(0)
E = [val.mean/1000.0/disp*energy0 for val in r.getReadable(0)]
dE = [val.mean/1000.0/disp*energy0 for val in r.getReadable(1)]
caput("SINEG01-RSYS:GET-PHASE-ARRAY", to_array(rf_phase,'d'))
caput("SINEG01-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)
except:
raise Exception("Fit failure")
caput("SINEG01-RSYS:GET-ONCREST-VSUM-PHASE", phase_fit_max)
caput("SINEG01-RSYS:GET-ONCREST-E-GAIN", energy_max)
caput("SINEG01-RSYS:GET-FIT-PHASE-ARRAY", fit_x)
caput("SINEG01-RSYS:GET-FIT-ENERGY-ARRAY", fit_y)
phase_min, phase_max = min(rf_phase), max(rf_phase)
if not (phase_min <= phase_fit_max <= phase_max):
raise Exception("Fit maximum outside scan range")
phase.write(phase_fit_max)
time.sleep(lat)
Ampl = V.read()
Power = P.read()
caput("SINEG01-RSYS:GET-ONCREST-VSUM-AMPLT", Ampl)
caput("SINEG01-RSYS:GET-ONCREST-KLY-POWER", Power)
finally:
phase.close()
V.close()
P.close()
st.close()
print ("------------------------------------")
print ("Valid fit")
energy_gain = energy_max
phase_offset = 90 - phase_fit_max
amplitude_scale = energy_gain / Ampl
power_scale = Power / math.pow(Ampl,2)
caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
caput("SINEG01-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
caput("SINEG01-RSYS:SET-VOLT-POWER-SCALE", power_scale)
p = plot([E, dE],"data", rf_phase, title="Phase scan")[0]
p.addSeries(LinePlotSeries("fit"))
p.getSeries(1).setData(fit_x, fit_y)