This commit is contained in:
root
2018-05-15 10:29:52 +02:00
parent 1bcb32c8f2
commit dcdb3ee2ac
76 changed files with 3068 additions and 829 deletions
+29
View File
@@ -0,0 +1,29 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Actuator1", "SARUN07-UIND030:I-SET")
#S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S1 = ChannelDouble("Sensor1", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = -1.0
A1f = 1.2
nstep = 22
lat = 0.11
nav = 50
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
time.sleep(1.0)
r = lscan(A1, S1_averager, A1i, A1f, nstep, latency=2.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
+35
View File
@@ -0,0 +1,35 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Current", "SARUN15-UIND030:I-SET")
S1 = ChannelDouble("energy per pulse", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -0.5
A1f = 1.5
nstep = 20
lat = 0.11
nav = 50
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()
+44
View File
@@ -0,0 +1,44 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Gap", "SARUN03-UPHS060:GAP")
A1 = ChannelDouble("Gap", "SARUN03-UPHS060:GAP")
S1 = ChannelDouble("energy per pulse", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
S2 = ChannelDouble("HAMP", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
A1.initialize()
S1.initialize()
S2.initialize()
A1_init = A1.read()
A1i = -0.5
A1f = 1.5
nstep = 20
lat = 0.11
nav = 50
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
def before(position, scan):
caput(GAP + ":GO", 1)
start = time.time()
while abs(readout.read() - GAP.read()) > TOLERANCE:
time.sleep(0.1)
if time.time() - start > TIMEOUT:
raise Exception ("Timeout waiting gap change")
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
S2_averager.monitored=True
time.sleep(10.0)
r = lscan(A1, (S1_averager, S2_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
S1rms = [val.stdev for val in r.getReadable(0)]
S2mean = [val.mean for val in r.getReadable(1)]
S2rmsn = [val.stdev for val in r.getReadable(1)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
S2.close()
+16
View File
@@ -0,0 +1,16 @@
Eph1 = 2.165# actual photon energy
Eph2 = 2.185 # desired photon energy
# beam on-delay during change!
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09","SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
for und in undlist:
K1 = caget(und + "-UIND030:K_SET")
K2 = ((Eph1 / Eph2 * (K1**2 + 2) - 2))**0.5
print K1,K2
caput(und + "-UIND030:K_SET", 0.07)
time.sleep(10.0)
caput(und + "-UIND030:K_SET", K2)
print "finished"
+31
View File
@@ -0,0 +1,31 @@
Eph1 = 2.165 # actual photon energy
Eph2 = 2.185 # desired photon energy
do_elog = False
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09","SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
K1, K2 = {}, {}
for und in undlist:
K = caget(und + "-UIND030:K_SET")
K1[und] = K
K2[und] = ((Eph1 / Eph2 * (K**2 + 2) - 2))**0.5
# set laser on-delay
caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel",1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1)
if Eph2 < Eph1 :
for und in undlist: caput(und + "-UIND030:K_SET", 0.07)
time.sleep(40.0)
for und in undlist: caput(und + "-UIND030:K_SET", K2[und])
time.sleep(40.0)
# set laser on-beam
caput("SIN-TIMAST-TMA:Beam-Las-Delay-Sel",0)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1)
#Elog entry
if do_elog:
title = "Wavelength change"
log_msg = "Old photon energy: %0.2f" % Eph1 + " kev\n"
log_msg = log_msg + "New photon energy: %0.2f" % Eph2 + " keV\n"
attachments = none
elog(title, log_msg, attachments)