This commit is contained in:
voulot_d
2017-08-15 09:49:59 +02:00
parent 7110c6a35c
commit 73c0cf9798
38 changed files with 354 additions and 795 deletions

18
script/CPython/ext.py Normal file
View File

@@ -0,0 +1,18 @@
import numpy as np
def ext(x, y):
"""
Return extremum coordinates of quadratic fit
"""
p = np.polyfit(x, y, 2)
f = np.poly1d(p)
x_fit = 1.0 #np.linspace(min(x), max(x), 100)
#y_fit = 2.0 #f(x_fit)
if p[0] != 0:
x_ext = -p[1]/2/p[0]
y_ext = f(x_ext)
else:
x_ext = None
y_ext = None
return (x_ext, y_ext, x_ext)

View File

@@ -2,9 +2,14 @@ from jeputils import *
def hfitoff(data, xdeg):
ret = call_jep("CPython/hfitoff", "hfitoff", [to_npa(data),to_npa(xdeg)])
print ret
return (ret[0], ret[1], ret[2],ret[3], ret[4].data,ret[5].data)
return (ret[0], ret[1], ret[2],ret[3], ret[4].data, ret[5].data)
def ext(x, y):
ret = call_jep("CPython/ext", "ext", [to_npa(x),to_npa(y)])
#return (ret[0], ret[1], ret[2].data, ret[3].data)
return (ret[0], ret[1], ret[2])
def gfitoff(x, y, off=None, amp=None, com=None, sigma=None):
ret = call_jep("CPython/gfitoff", "gfitoff", [to_npa(x), to_npa(y), off, amp, com, sigma])
return ret if ret is None or is_list(ret) else ret.data
return ret if ret is None or is_list(ret) else ret.data

View File

@@ -1,13 +1,13 @@
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
#CAMERA = "S10DI01-DSCR020" #"simulation"
CAMERA = "SINDI02-DLAC055" #"simulation"
QUADRUPOLE = "S10CB02-MQUA230" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
CAMERA = "S10DI01-DSCR020"
#CAMERA = "SINDI02-DLAC055"
QUADRUPOLE = "S10CB01-MQUA430" # quadrupole for the scan with S10DI01-DSCR020: S10CB02-MQUA230
CHARGE_BPM = "SINEG01-DBPM340:Q1"
CHARGE_ICT = "SINEG01-DICT215:B1_CHARGE-OP"
RANGE = (-3.0, 0.0)
RANGE = (-0.485, 1.515)
STEPS = 100
SETTLING_TIME = 1
SETTLING_TIME = 0.1
#kill_camtool()
check_camtool()

View File

@@ -10,7 +10,7 @@ if get_exec_pars().source == CommandSource.ui:
step = 1.0
nb = 3
lat = 0.3
disp = -0.32
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
else:
@@ -69,7 +69,7 @@ dx_averager.monitored=True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
@@ -107,6 +107,6 @@ if do_elog:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC \n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunScanPlot.png")
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog("Gun scan", log_msg, [file_name,])
elog("Gun Energy Scan", log_msg, [file_name,])

View File

@@ -95,6 +95,8 @@ finally:
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog("Schottky scan", log_msg, attachments)
show_message("E-log entry")
#Setting the return value
index_max = charge.index(max(charge))

View File

@@ -1,32 +0,0 @@
import ch.psi.pshell.imaging.Data as Data
path = "2017/06/16/20170616_122305_snapshot.h5|/data"
path = "2017/06/19/20170619_113633_snapshot.h5|/data"
path = "2017/06/19/20170619_114839_snapshot.h5|/data"
path = "2017/06/19/20170619_115340_snapshot.h5|/data"
path = "2017/06/19/20170619_120203_snapshot.h5|/data"
path = "2017/06/19/20170619_141032_snapshot.h5|/data"
path = "2017/06/19/20170619_141203_snapshot.h5|/data"
path = "2017/06/19/20170619_142222_snapshot.h5|/data"
path = "2017/06/19/20170619_142310_snapshot.h5|/data"
path = "2017/06/19/20170619_142826_snapshot.h5|/data"
path = "2017/06/19/20170619_142836_snapshot.h5|/data"
path = "2017/06/19/20170619_144625_snapshot.h5|/data"
d = load_data(path)
atts = get_attributes(path)
data = Data(d)
iv = data.integrateVertically(False)
ih = data.integrateHorizontally(False)
xp = atts["x_profile"]
yp = atts["y_profile"]
p1, p2 = plot([xp, yp], ["X profile", "Y profile"])
p1.addSeries(LinePlotSeries("data X"))
p2.addSeries(LinePlotSeries("data Y"))
p1.getSeries(1).setData(iv)
p2.getSeries(1).setData(ih)
p1.addSeries(LinePlotSeries("error X", None, 2))
p2.addSeries(LinePlotSeries("error Y", None, 2))
p1.getSeries(2).setData(arrsub(xp,iv))
p2.getSeries(2).setData(arrsub(yp,ih))

View File

@@ -0,0 +1,112 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.Camtool as Camtool
#Parameters
dry_run = True
do_elog = False
if get_exec_pars().source == CommandSource.ui:
start = 45.0
stop = 55.0
step = 1.0
nb = 3
lat = 0.3
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
else:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
p0 = args[6]
plt = args[7]
A = p0 / disp / 1e6
B = p0
#Plot setup
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Momentum"))
plt.addSeries(LinePlotErrorSeries("Momentum Spread", None, 2))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -180.0
phase.config.maxValue = 180.0
phase.config.precision = 3
phase.config.resolution = 0.01
phase.config.rotation = False
phase.config.save()
phase.initialize()
phase0 = phase.read()
#Camtool setup
kill_camtool()
check_camtool()
camtool.start(camera_name)
wait_camtool_message()
x = camtool.stream.getChild("x_fit_mean")
dx = camtool.stream.getChild("x_fit_standard_deviation")
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
dx_averager = create_averager(dx, nb, -1)
dx_averager.monitored=True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
plt.getSeries(0).appendData(record.positions[0], p_mean, p_stdev)
plt.getSeries(1).appendData(record.positions[0], dp_mean, dp_stdev)
#The scan loop
try:
phase.write(start)
time.sleep(1.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
phase.close()
camtool.stop() # stops camtool but does not close it camtool is a global object
#Saving metadata
p = [A * val.mean + B for val in r.getReadable(0)]
dp = [abs(A) * val.mean for val in r.getReadable(1)]
save_dataset(get_exec_pars().group + "/p", p)
save_dataset(get_exec_pars().group + "/dp", dp)
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
else:
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog("Gun Energy Scan", log_msg, [file_name,])

View File

@@ -0,0 +1,121 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.Camtool as Camtool
#Parameters
dry_run = True
do_elog = False
if get_exec_pars().source == CommandSource.ui:
start = 45.0
stop = 55.0
step = 1.0
nb = 3
lat = 0.3
disp = -0.387
p0 = 7.1
plt = plot(None, title="Output")[0]
else:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
disp = args[5]
p0 = args[6]
plt = args[7]
A = p0 / disp / 1e6
B = p0
#Plot setup
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Momentum"))
plt.addSeries(LinePlotErrorSeries("Momentum Spread", None, 2))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("Momentum (MeV/c)")
plt.getAxis(plt.AxisId.Y2).setLabel("Momentum Spread (MeV/c)")
plt.setLegendVisible(True)
#Creating Phase positioner
if dry_run:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
camera_name = "simulation"
else:
phase = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
camera_name = "SINBD01-DSCR010"
phase.config.minValue = -180.0
phase.config.maxValue = 180.0
phase.config.precision = 3
phase.config.resolution = 0.01
phase.config.rotation = False
phase.config.save()
phase.initialize()
phase0 = phase.read()
#Camtool setup
kill_camtool()
check_camtool()
camtool.start(camera_name)
wait_camtool_message()
x = camtool.stream.getChild("x_fit_mean")
dx = camtool.stream.getChild("x_fit_standard_deviation")
#Creating averagers
x_averager = create_averager(x, nb, -1) # -1 event based, waits for the next value
dx_averager = create_averager(dx, nb, -1)
dx_averager.monitored=True # not blocking, will return last nb values
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B
x_pos_mean, x_pos_stdev = record.values[0].mean, record.values[0].stdev
x_width_mean, x_width_stdev = record.values[1].mean, record.values[1].stdev
p_mean, p_stdev = A * x_pos_mean + B, abs(A) * x_pos_stdev
dp_mean, dp_stdev = abs(A) * x_width_mean, abs(A) * x_width_stdev
plt.getSeries(0).appendData(record.positions[0], p_mean, p_stdev)
plt.getSeries(1).appendData(record.positions[0], dp_mean, dp_stdev)
#The scan loop
try:
phase.write(start)
time.sleep(1.0)
r = lscan(phase, [x_averager, dx_averager], start, stop, step , latency=lat, after_read = after_sample)
finally:
phase.write(phase0)
phase.close()
camtool.stop() # stops camtool but does not close it camtool is a global object
#Saving metadata
ph = r.getPositions(0)
p = [A * val.mean + B for val in r.getReadable(0)]
dp = [abs(A) * val.mean for val in r.getReadable(1)]
save_dataset(get_exec_pars().group + "/p", p)
save_dataset(get_exec_pars().group + "/dp", dp)
try:
run("CPython/wrapper")
(ph_p_max, p_max, ph_p_fit, p_fit) = ext(ph[i_max-5:i_max+6], p[i_max-5:i_max+6])
(ph_dp_min, dp_min, ph_dp_fit, dp_fit) = ext(ph[i_min-5:i_min+6], dp[i_min-5:i_min+6])
#plt.getSeries(2).appendData(ph_p_fit, p_fit)
#plt.getSeries(3).appendData(ph_dp_fit, dp_fit)
except:
raise Exception("Fit failure")
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
else:
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % phase0 + " deg beam phase\n"
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/GunEnergyScanPlot.png")
plt.saveSnapshot(file_name , "png")
elog("Gun Energy Scan", log_msg, [file_name,])

View File

@@ -1,49 +0,0 @@
# Tool to align the solenoid on the gun.
# S. Bettoni, A. Gobbo, D. Voulot
# 30/05/2016
# Procedure:
# switch off all the magnets between the gun solenoid and the screen or BPM used for the measurement
# change the current of the gun soleoid
# look at the centroid position (BPM or screen) downstream of the gun.
I_set = Channel("SINEG01-MSOL130:I-SET")
I_get = Channel("SINEG01-MSOL130:I-READ")
# cam_x, cam_y = ... # some camtool command / channel?
bpm_x = ai1 # Channel("SINEG01-DBPM340:X1")
bpm_y = ai2 # Channel("SINEG01-DBPM340:Y1")
def ccr(mag):
n = 1
while n > 0:
sleep(0.5)
n = caget(mag + ":I-COMP")
def laser_on():
print(laser_on) #caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0)
def laser_off():
print(laser_off) #caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1)
I1 = 2.0
I2 = 5.0
dI = 0.5
# Switch off magnets
mag = ["SINEG01-MCRX120","SINEG01-MCRY120"]
for m in mag:
caput(m + ":I-SET", 0.0)
for m in mag:
ccr(m)
# Scan using the screen
#r = lscan(I_set, [I_get, cam_x, cam_y], I1, I2, dI, passes = 2, zigzag = True)
# Scan using the BPM
r = lscan(I_set, [I_get, bpm_x, bpm_y], I1, I2, dI, 1.0, before_read = laser_on(), after_read = laser_off())
# take the result of the scan and do the plots
plot(r.getReadable(2), xdata=r.getReadable(1), title = "Centroid excursion")
# save the entry in the logbook
msg = str(r)
msg = msg + "\nFile: " + get_exec_pars().path
msg = msg + "\n\n" + r.print()
elog("Gun solenoid current scan", msg , get_plot_snapshots())

View File

@@ -1,25 +0,0 @@
rsys = "SINSB01-RSYS"
bpm = "SINLH02-DBPM210"
phi1 = -175.0
phi2 = 180.0
dphi = 5.0
def laser_on():
caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 0)
def laser_off():
caput("SIN-CVME-TIMAST-TMA:LaserDelayControl", 1)
phi_set = Channel(rsys + ":SET-VSUM-PHASE")
phi_get = Channel(rsys + ":GET-VSUM-PHASE")
amp_get = Channel(rsys + ":GET-VSUM-AMPLT")
bpm_x = Channel(bpm + ":X1")
r = lscan(phi_set, [phi_get, amp_get, bpm_x], phi1, phi2, dphi, 0.5, before_read = laser_on(), after_read = laser_off())
plot(r.getReadable(2), xdata = r.getReadable(0), title = "Phase scan")
(amplitude, angular_frequency, phase, ok, maximum, fit_x, fit_y) = hfit(r.getReadable(2), xdata = r.getReadable(0))
caput(rsys + ":SET-ON-CREST-VSUM-PHASE", maximum)
set_return(r.print())

View File

@@ -0,0 +1,27 @@
dry_run = False
do_elog = True
if get_exec_pars().source == CommandSource.ui:
bph_ref_user = 0.0
plt = None
else:
bph_ref_user = args[0]
plt = args[1]
phaseOffset_old = caget("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE")
phaseOffset_new = phaseOffset_old - bph_ref_user
if not dry_run:
caput("SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phaseOffset_new)
caput("SINEG01-RSYS:CMD-LOAD-CALIB-BEAM", 1)
if do_elog:
log_msg = "SINEG01-RSYS:SET-VSUM-PHASE-OFFSET-BASE \n"
log_msg = log_msg + "Old: %0.1f" % phaseOffset_old + "deg \n"
log_msg = log_msg + "New: %0.1f" % phaseOffset_new + "deg \n"
log_msg = log_msg + "Charge on-set at %0.1f" % -phaseOffset_new + "deg RF phase (0.0 deg beam phase)\n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanSetPlot.png")
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog("Set gun phase", log_msg, attachments)
show_message("Success setting phase reference")

View File

@@ -2,13 +2,14 @@ import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = True
do_elog = False
if get_exec_pars().source == CommandSource.ui:
start = -20
start = -50.0
stop = 150.0
step = 5.0
nb = 3
lat = 0.250
step = 2.0
nb = 2
lat = 0.120
plt = None
else:
start = args[0]
@@ -26,13 +27,13 @@ if plt is not None:
if dry_run:
bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
rph = ChannelDouble('RF phase', "SINEG01-RSYS:SET-VSUM-PHASE-SIM")
rph = ChannelDouble("RF phase", "SINEG01-RSYS:SET-VSUM-PHASE-SIM")
q = ChannelDouble("Charge", "SINEG01-DICT215:B1_CHARGE-SIM")
q.initialize()
q.monitored=True
else:
bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
rph = ChannelDouble('RF phase', "SINEG01-RSYS:SET-VSUM-PHASE")
rph = ChannelDouble("RF phase", "SINEG01-RSYS:SET-VSUM-PHASE")
#st = Stream("ICTstream", dispatcher)
#q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
#st.initialize()
@@ -52,6 +53,7 @@ bph.initialize()
rph.initialize()
rph.monitored=True
bph0 = bph.read()
rph0 = rph.read()
#Record callback: uptate of output plot
@@ -71,32 +73,34 @@ try:
chargerms = [val.stdev for val in r.getReadable(1)]
finally:
rph.write(rph0)
#bph.write(bph0)
bph.close()
rph.close()
q.close()
##Elog entry
# Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
# log_msg = "Data file: " + get_exec_pars().path + "\n\n"
# log_msg = log_msg + "Laser: " + Laser + "\n"
# if Laser == "Alcor":
# log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
# else:
# log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
# if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
# log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
# else:
# log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
# log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC \n"
# attachments = []
# if plt is not None:
# sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
# file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanPlot.png")
# plt.saveSnapshot(file_name , "png")
# attachments = [file_name]
# elog("Schottky scan", log_msg, attachments)
#Elog entry
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
Laser = str(caget("SLGTV-LMTO-M055:MOT-KNOWN-POS"))
log_msg = "Data file: " + get_exec_pars().path + "\n\n"
log_msg = log_msg + "Laser: " + Laser + "\n"
if Laser == "Alcor":
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGTH01-LMRM-M074:MOT.RBV") + " deg \n"
else:
log_msg = log_msg + "Energy plate: %0.2f" % caget("SLGJG-LMRM-M031:MOT.RBV") + " deg \n"
if caget("SLGTV-LMTO-M053:MOT-ACT-POS") == "IRIS":
log_msg = log_msg + "Collimator: IRIS %0.2f" % caget("SLGTV-LAPP:SIZE-GET") + " mm \n"
else:
log_msg = log_msg + "Collimator: " + str(caget("SLGTV-LMTO-M053:MOT-ACT-POS")) + "\n"
log_msg = log_msg + "Charge: %0.2f" % caget("SINEG01-DICT215:B1_CHARGE-OP") + " pC at %0.2f" % bph0 + " deg beam phase\n"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanPlot.png")
plt.saveSnapshot(file_name , "png")
attachments = [file_name]
elog("Schottky scan", log_msg, attachments)
#Setting the return value
index_max = charge.index(max(charge))
bph_ref_guess = 0.0
set_return([bph_ref_guess])

View File

@@ -1,51 +0,0 @@
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
if get_exec_pars().source == CommandSource.ui:
start = 20.0
stop = 140.0
step = 5.0
nb = 2
lat = 0.100
else:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
bph = ControlledVariable("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
bph.config.minValue =-180.0
bph.config.maxValue = 360.0
bph.config.precision = 3
bph.config.resolution = 1.0
bph.config.save()
bph.initialize()
rph = Channel("SINEG01-RSYS:SET-VSUM-PHASE-SIM", type = 'd', alias = 'RF phase')
q = Channel("SINEG01-DICT215:B1_CHARGE-SIM", type = 'd', alias = 'ICT-Q')
rph0 = rph.read()
try:
q_averager = create_averager(q, nb, 0.100)
rph_averager = create_averager(rph, nb, 0.100)
r = lscan(bph, (rph_averager, q_averager), start, stop, step, latency=lat)
beamphase = r.getPositions(0)
rfphase = [val.mean for val in r.getReadable(0)]
rfphaserms = [val.stdev for val in r.getReadable(0)]
charge = [val.mean for val in r.getReadable(1)]
chargerms = [val.stdev for val in r.getReadable(1)]
finally:
rph.write(rph0)
bph.close()
rph.close()
q.close()
#Setting the return value
index_max = charge.index(max(charge))
bph_ref = beamphase[index_max] - 80
rph_ref = rfphase[index_max] - 80
print bph_ref
print rph_ref
set_return(bph_ref, rph_ref)

View File

@@ -1,11 +0,0 @@
st = Stream("ICTstream", dispatcher)
q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
st.initialize()
st.start()
try:
qb = create_averager(q, 5, 0.100)
r = tscan((qb), 10, 1.0)
finally:
st.close()

View File

@@ -1,21 +0,0 @@
###################################################################################################
# Demonstrate use of scan callbacks to trigger a detector at falling edge.
###################################################################################################
def BeforeReadout():
ao1.write(1)
ao1.write(0)
#Example with an epics direct channel access
#caput("CHANNEL_NAME", 1)
#caput("CHANNEL_NAME", 0)
index=0
def AfterReadout():
global index
print "Aquired frame: " + str(index)
index=index+1
a= lscan((m1,m2), (ai1, ai2), (0,0), (4,8), steps=20, latency = 0.01, before_read=BeforeReadout, after_read=AfterReadout)

View File

@@ -1,33 +0,0 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
t = ChannelDouble("fine delay (ns)", "SINEG01-DICT215:Pul1-Delay-SP-SIM")
q = ChannelDouble("charge (pC)", "SINEG01-DICT215:AL1-ICT-CHARGE-SIM")
V = ChannelDouble("DC output (V)", "SINEG01-DICT215:AL1-ICT-VOLTAGE-SIM")
t.initialize()
q.initialize()
V.initialize()
t0 = t.read()
start = 0.0
stop = 10.0
step = 0.1
nb = 2
lat = 0.080
try:
q_averager = create_averager(q, nb, lat)
V_averager = create_averager(V, nb, lat)
V_averager.monitored=True
r = lscan(t, (q_averager, V_averager), start, stop, step, latency=lat)
delay = r.getPositions(0)
charge = [val.mean for val in r.getReadable(0)]
chargerms = [val.stdev for val in r.getReadable(0)]
volt = [val.mean for val in r.getReadable(1)]
voltrms = [val.stdev for val in r.getReadable(1)]
finally:
t.write(t0)
t.close()
q.close()
V.close()

View File

@@ -1,12 +0,0 @@
knob = Channel("SARUN20-MCRX080:I-SET")
sensor1 = Channel("SINEG01-DICT215:B1_CHARGE")
sensor2 = Channel("S10DI01-DICT025:B1_CHARGE")
start = -1.0
stop = 1.0
nstep = 10
lat = 0.5
r = lscan(knob, (sensor1, sensor2), start, stop, nstep, lat)
plot(r.getReadable(0), name = 'plotname', xdata = r.getReadable(1))

View File

@@ -1,11 +0,0 @@
knob = Channel("SARUN20-MCRX080:I-SET")
sensor1 = Channel("SINEG01-DICT215:B1_CHARGE")
sensor2 = Channel("S10DI01-DICT025:B1_CHARGE")
start = -0.5
stop = 0.5
nstep = 10
lat = 0.5
av = create_averager(sensor1, 10, 0.1)
lscan(knob, (av, sensor2), start, stop, nstep, lat)

View File

@@ -1,4 +0,0 @@
data = tscan(Channel('SINEG01-DICT215:B1_CHARGE'), 100, 0.1)
samples = data.getReadable(0)
print "mean=", mean(samples)
print "stdev=", stdev (samples)

View File

@@ -1,36 +0,0 @@
"""
Parameters:
prefix
"""
prefix = "MINSB03-RSYS"
start = -179.0
stop = 180.0
step = 10.0
rf_phase_setpoint = Channel(prefix + ":SET-VSUM-PHASE")
rf_phase_readback = Channel(prefix + ":GET-VSUM-PHASE")
rf_ampl_readback = Channel(prefix + ":GET-VSUM-AMPLT")
r = lscan(rf_phase_setpoint, [rf_phase_readback, rf_ampl_readback, sim], start, stop, step , latency=0.2)
plot(r.getReadable(2), xdata = r.getReadable(0), title = "data")
#fit(r.getReadable(1))
set_return(r.print())
"""
r = lscan(rf_phase, [rf_phase_rb, rf_ampl_rb, sim], -179.0, 180, 10.0, latency=0.2)
plot(r.getReadable(2), xdata = r.getReadable(0), title = "data")
fit(r.getReadable(1))
set_return(r.print())
"""

View File

@@ -1,112 +0,0 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = True
do_elog = False
if get_exec_pars().source == CommandSource.ui:
station = "STEST01"
bpm_ch = "SINBC02-DBPM140"
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")
phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE")
phase.config.minValue =-180.0
phase.config.maxValue = 180.0
phase.config.precision = 3
phase.config.rotation = True
phase.config.resolution = 0.5
phase.initialize()
V = ChannelDouble("Amplitude Readback", station + "-RSYS:GET-VSUM-AMPLT")
P = ChannelDouble("Power Readback", station + "-RSYS:GET-KLY-POWER")
if dry_run:
x = ChannelDouble("BPM-X", bpm_ch + ":X1-SIMU")
else:
x = ChannelDouble("BPM-X", bpm_ch + ":X1")
V.initialize()
P.initialize()
x.initialize()
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'))
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'))
#update the plot dynamically
arr_phase,arr_energy = [],[]
def after(rec):
global disp, energy0
arr_phase.append(rec.positions[0])
arr_energy.append(energy0 * (1 + rec.values[0].mean / 1000.0 / disp))
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(arr_phase, 'd'))
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(arr_energy,'d'))
try:
x_averager = create_averager(x, nb, 0.100)
r = lscan(phase, x_averager, start, stop, step, latency=lat, after_read = after)
rf_phase = r.getPositions(0)
energy = [energy0 * (1 + val.mean / 1000.0 / disp) 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'))
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])
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", ph_crest)
caput(station + "-RSYS:GET-ONCREST-E-GAIN", fit_amplitude)
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", fit_x)
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("On-crest phase outside scan range")
phase.write(ph_crest)
time.sleep(lat)
Ampl = V.read()
Power = P.read()
caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", Ampl)
caput(station + "-RSYS:GET-ONCREST-KLY-POWER", Power)
finally:
phase.write(phase0)
phase.close()
V.close()
P.close()
x.close()
phase_offset = 90 - ph_crest
amplitude_scale = fit_amplitude / Ampl
power_scale = Power / math.pow(Ampl,2)
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale)
if do_elog:
if get_option("Generated data file:\n" + get_exec_pars().path +"\n\n" + "Save to ELOG?", "YesNo") == "Yes":
title = "Phase scan" + station
log_msg = "Data file: " + get_exec_pars().path + "\n"
log_msg = log_msg + "Energy Gain: %0.3f" % energy_gain + "MeV\n"
log_msg = log_msg + "Phase Offset: %0.2f" % phase_offset + "deg\n"
log_msg = log_msg + "Amplitude Scale: %0.3f" % amplitude_scale + "MV\n"
log_msg = log_msg + "Power Scale: %0.3f" % power_scale + "MW/MV^2"
attachments = []
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
file_name = os.path.abspath(get_context().setup.getContextPath() + "/SchottkyScanPlot.png")
plt.saveSnapshot(file_name, "png")
attachments = [file_name,]
elog(title, log_msg, attachments)

View File

@@ -1,114 +0,0 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = True
do_elog = True
if get_exec_pars().source == CommandSource.ui:
station = "STEST01"
bpm_ch = "SINBC02-DBPM140"
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")
A = energy0 / disp / 1e3
B = energy0
phase = Positioner("Phase", station + "-RSYS:SET-VSUM-PHASE", station + "-RSYS:GET-VSUM-PHASE")
phase.config.minValue =-360.0
phase.config.maxValue = 360.0
phase.config.precision = 4
phase.config.rotation = False
phase.config.resolution = 0.01
phase.initialize()
V = ChannelDouble("Amplitude Readback", station + "-RSYS:GET-VSUM-AMPLT")
P = ChannelDouble("Power Readback", station + "-RSYS:GET-KLY-POWER")
if dry_run:
x = ChannelDouble("BPM-X", bpm_ch + ":X1-SIMU")
else:
x = ChannelDouble("BPM-X", bpm_ch + ":X1")
V.initialize()
P.initialize()
x.initialize()
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'))
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'))
#update the plot dynamically
arr_phase,arr_energy = [],[]
def after(rec):
global A, B
arr_phase.append(rec.positions[0])
arr_energy.append(A * rec.values[0].mean + B)
caput(station + "-RSYS:GET-PHASE-ARRAY", to_array(arr_phase, 'd'))
caput(station + "-RSYS:GET-ENERGY-ARRAY", to_array(arr_energy,'d'))
try:
phase.write(start)
time.sleep(1.0)
x_averager = create_averager(x, nb, 0.100)
r = lscan(phase, x_averager, start, stop, step, latency=lat, after_read = after)
rf_phase = r.getPositions(0)
energy = [A * val.mean + B 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'))
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")
plt = plot([energy, fit_y], ["data", "fit"], [rf_phase, fit_x])
caput(station + "-RSYS:GET-ONCREST-VSUM-PHASE", ph_crest)
caput(station + "-RSYS:GET-ONCREST-E-GAIN", fit_amplitude)
caput(station + "-RSYS:GET-FIT-PHASE-ARRAY", fit_x)
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("On-crest phase outside scan range")
phase.write(ph_crest)
time.sleep(lat)
Ampl = V.read()
Power = P.read()
caput(station + "-RSYS:GET-ONCREST-VSUM-AMPLT", Ampl)
caput(station + "-RSYS:GET-ONCREST-KLY-POWER", Power)
finally:
phase.write(phase0)
phase.close()
V.close()
P.close()
x.close()
phase_offset = 90 - ph_crest
amplitude_scale = fit_amplitude / Ampl
power_scale = Power / math.pow(fit_amplitude,2)
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE-CALC", phase_offset)
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC", amplitude_scale)
caput(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC", power_scale)
if do_elog:
title = "Phase scan " + station
log_msg = "Data file: " + get_exec_pars().path + "\n"
log_msg = log_msg + "Energy Gain: %0.3f" % fit_amplitude + "MeV\n"
log_msg = log_msg + "Phase Offset: %0.2f" % phase_offset + "deg\n"
log_msg = log_msg + "Amplitude Scale: %0.3f" % amplitude_scale + "MV\n"
log_msg = log_msg + "Power Scale: %0.3f" % power_scale + "MW/MV^2"
if plt is not None:
sleep(0.1) #Give some time to plot to be finished - it is not sync with acquisition
attachments = [file_name]
attachments = []
elog(title, log_msg, attachments)

View File

@@ -1,15 +0,0 @@
prefix = "MINSB03-RSYS" # SINEG01-RSYS
start = -175.0
stop = 180.0
step = 5.0
rf_phase_setpoint = ao1 # Channel(prefix + ":SET-VSUM-PHASE")
rf_phase_readback = phase # Channel(prefix + ":GET-VSUM-PHASE")
rf_ampl_readback = ai2 # Channel(prefix + ":GET-VSUM-AMPLT")
bpm_q = bpm # SINEG01-DBPM340:Q1, SINEG01-DWCM170:Q_B1
r = lscan(rf_phase_setpoint, [rf_phase_readback, rf_ampl_readback, bpm_q], start, stop, step , latency=0.5)
plot(r.getReadable(2), xdata = r.getReadable(0), title = "data")
set_return(r.print())

View File

@@ -1,29 +0,0 @@
###################################################################################################
# Demonstrate the use of Line Scan: one or multiple positioners move together linearly.
###################################################################################################
#This optional preference limits the displayed plots
#set_preference(Preference.ENABLED_PLOTS, [ai1, ai2,])
#This optional preference displays wf1 as a 1d plot at each scan point, instead of a matrix plot
#set_preference(Preference.PLOT_TYPES, {wf1:1})
#Execute the scan: 200 steps, a1 from 0 to 40
a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 200, 0.01)
#Also samples an image:
#a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 200, 0.01)
#Alternative: Steps of size 0.1, a1 from 0 to 40
#a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 0.5, 0.01)
#2 positioners moving together in 200 steps, a1 from 0 to 40 and a2 from 0 to 100
#a= lscan((ao1,ao2), (ai1,ai2,wf1), (0, 0), (40, 100), 200, 0.01)
#Setting attributes to the scan group
path = get_current_group()
set_attribute(path, "AttrString", "Value")
set_attribute(path, "AttrInteger", 1)
set_attribute(path, "AttrDouble", 2.0)
set_attribute(path, "AttrBoolean", True)

View File

@@ -1 +0,0 @@
lscan(SINSB01_phase, energy_BC1, 0.0, 360.0, 10.0, 2.0)

View File

@@ -1,93 +0,0 @@
import ch.psi.pshell.epics.Positioner as Positioner
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
dry_run = True
if get_exec_pars().source == CommandSource.ui:
start = -30.0
stop = -10.0
step = 1.0
nb = 25
lat = 0.1
plt = None
else:
start = args[0]
stop = args[1]
step = args[2]
nb = int(args[3])
lat = args[4]
plt = args[5]
if plt is not None:
plt.clear()
#plt.setStyle(plt.Style.ErrorY) #Must be set by Plugin otherwise first scan is not shown
plt.addSeries(LinePlotErrorSeries("Values"))
plt.getAxis(plt.AxisId.X).setLabel("Gun Beam Phase (deg)")
plt.getAxis(plt.AxisId.Y).setLabel("SINEG01-DICT215:B1_CHARGE")
if dry_run:
bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE-SIM", "SINEG01-RSYS:SET-BEAM-PHASE-SIM")
rph = ChannelDouble('RF phase', "SINEG01-RSYS:SET-VSUM-PHASE-SIM")
st = Stream("ICTstream", dispatcher)
q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
st.initialize()
st.start()
st.waitValueChange(10000)
#q = ChannelDouble("Charge", "SINEG01-DICT215:B1_CHARGE-SIM")
#q.initialize()
#q.monitored=True
else:
bph = Positioner("Beam phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
rph = ChannelDouble('RF phase', "SINEG01-RSYS:SET-VSUM-PHASE")
st = Stream("ICTstream", dispatcher)
q = st.addScalar("Charge", "SINEG01-DICT215:B1_CHARGE", 1, 0)
st.initialize()
st.start()
st.waitValueChange(10000)
#q = ChannelDouble("Charge", "SINEG01-DICT215:B1_CHARGE")
#q.initialize()
#q.monitored=True
bph.config.minValue = -360.0
bph.config.maxValue = 360.0
bph.config.precision = 3
bph.config.rotation = False
bph.config.resolution = 0.01
bph.config.save()
bph.initialize()
rph.initialize()
rph.monitored=True
rph0 = rph.read()
#Record callback: uptate of output plot
def after_sample(record, scan):
if plt is not None:
plt.getSeries(0).appendData(record.positions[0], record.values[1].mean, record.values[1].stdev)
try:
rph_averager = create_averager(rph, nb, 0.1) # Set polling time to -1 for BS data to get all messages
q_averager = create_averager(q, nb, 0.1)
q_averager.monitored=True
r = lscan(bph, (rph_averager, q_averager), start, stop, step, latency=lat, after_read = after_sample)
beamphase = r.getPositions(0)
rfphase = [val.mean for val in r.getReadable(0)]
rfphaserms = [val.stdev for val in r.getReadable(0)]
charge = [val.mean for val in r.getReadable(1)]
chargerms = [val.stdev for val in r.getReadable(1)]
finally:
rph.write(rph0)
bph.close()
rph.close()
#q.close()
st.close()
#Setting the return value
index_max = charge.index(max(charge))
#bph_ref_guess = beamphase[index_max] - 80
#rph_ref_guess = rfphase[index_max] - 80
bph_ref_guess = (start + stop)/2
set_return([bph_ref_guess])

View File

@@ -1,31 +0,0 @@
import ch.psi.pshell.epics.ControlledVariable as ControlledVariable
import ch.psi.pshell.epics.Camtool as Camtool
phase = ControlledVariable("Phase", "SINEG01-RSYS:SET-BEAM-PHASE", "SINEG01-RSYS:GET-BEAM-PHASE")
phase.config.minValue =-180.0
phase.config.maxValue = 360.0
phase.config.precision = 3
phase.config.resolution = 1.0
phase.config.save()
phase.initialize()
kill_camtool()
check_camtool()
camtool.start("SINBD01-DSCR010")
wait_camtool_message()
x = camtool.stream.getChild("gr_x_fit_mean")
dx = camtool.stream.getChild("gr_x_fit_standard_deviation")
try:
xb = create_averager(x, nb, -1) # -1 event based, waits for the next value
dxb = create_averager(dx, nb, -1)
dxb.monitored=True # not blocking, will return last nb values
r = lscan(phase, [xb, dxb], start, stop, step , latency=lat)
rf_phase = r.getPositions(0)
E = [energy0 * (1 + val.mean / 1e6 / disp) for val in r.getReadable(0)]
dE = [energy0 * ( val.mean / 1e6 / disp) for val in r.getReadable(1)]
finally:
phase.write(phase0)
phase.close()
camtool.stop() # stops camtool but does not close it camtool is a global object

View File

@@ -1,3 +0,0 @@
print "Start"
time.sleep(3.0)
print "Stop"

View File

@@ -1,9 +0,0 @@
x = Channel("SINBC02-DBPM140:X1-SIMU", type = 'd', alias='BPM-X')
xb = create_averager(x, 5, 0.100)
print 'xb =', xb
print 'xb.min =', xb.min
print 'xb.max =', xb.max
print 'xb.mean =', xb.mean
print 'xb.stdev =', xb.stdev
print 'xb.variance =', xb.variance
x.close()

View File

@@ -1,12 +0,0 @@
y = [ -1.36633487e+01, -1.13808691e+01, -8.92628692e+00, -6.53052299e+00, \
-5.26897045e+00, -5.75429171e+00, -1.75746114e+00, -1.39318500e-01, \
-1.04863080e+00, 1.46985567e-02, 1.04432984e+00, 1.14839620e+00, \
-1.45837648e+00, -2.62571957e+00, -4.64780802e+00, -4.02915206e+00, \
-6.94357281e+00, -1.02403468e+01, -1.30960565e+01, -1.55355021e+01]
x = [ 50.0, 51.05263158, 52.10526316, 53.15789474, 54.21052632, \
55.26315789, 56.31578947, 57.36842105, 58.42105263, 59.47368421, \
60.52631579, 61.57894737, 62.63157895, 63.68421053, 64.73684211, \
65.78947368, 66.84210526, 67.89473684, 68.94736842, 70. ]
r = hfitoff(y, x)
plot([y,r[5]], ["data", "fit"], [x, r[4]])

View File

@@ -1,13 +0,0 @@
y = [ -1.36633487e+01, 1.13808691e+01, -8.92628692e+00, 6.53052299e+00, \
-5.26897045e+00, 5.75429171e+00, -1.75746114e+00, 1.39318500e-01, \
-1.04863080e+00, 1.46985567e-02, -1.04432984e+00, 1.14839620e+00, \
-1.45837648e+00, 2.62571957e+00, -4.64780802e+00, 4.02915206e+00, \
-6.94357281e+00, 1.02403468e+01, -1.30960565e+01, 1.55355021e+01]
x = [ 50.0, 51.05263158, 52.10526316, 53.15789474, 54.21052632, \
55.26315789, 56.31578947, 57.36842105, 58.42105263, 59.47368421, \
60.52631579, 61.57894737, 62.63157895, 63.68421053, 64.73684211, \
65.78947368, 66.84210526, 67.89473684, 68.94736842, 70. ]
r = hfitoff(y, x)
#plot([y,r[5]], ["data", "fit"], [x, r[4]])
plot([y,r[5]], [x, r[4]])

View File

@@ -1,21 +0,0 @@
###################################################################################################
# Demonstrate use of Vector Scan: one or multiple positioners set according to a position vector.
###################################################################################################
#1D vector scan, plot to 1D Vector tab
vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49]
a= vscan(ao1,(ai1,ai2),vector,False, 0.5, title = "1D Vector")
#2D vector scan, plot to 2D Vector tab
vector = [ [1,1] , [1,2] , [1,3] , [1,4] ,
[1.5,2.5] ,
[2,1] , [2,2] , [2,3] , [2,4] ,
[2.5,2.5] ,
[3,1] , [3,2] , [3,3] , [3,4] ]
a= vscan((m1,m2),(ai1,ai2),vector,False, 0.1, title = "2D Vector")