This commit is contained in:
gobbo_a
2023-08-17 15:16:51 +02:00
parent c545879253
commit 8beeb7dbc7
134 changed files with 3722 additions and 1287 deletions

1
script/Undulators/1DscanEarthField.py Executable file → Normal file
View File

@@ -1,6 +1,5 @@
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()

View File

@@ -1,14 +1,18 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("K value", "SARUN15-UIND030:K_SET")
S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
from mathutils import fit_polynomial, PolynomialFunction
A1 = ChannelDouble("K value", "SARUN08-UIND030:K_SET")
#S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US")
#S1 = ChannelDouble("Energy per pulse (uJ)", "SARFE10-PBPG050:HAMP-INTENSITY-CAL")
S1 = ChannelDouble("Hamp RAW", "SARFE10-PBIG050-EVR0:CALCI")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = A1_init - 0.005
A1f = A1_init + 0.005
nstep = 21
lat = 1.0
nav = 5
nstep = 10
lat = 0.01
nav = 100
wait = 3
plt = plot(None, title="Output")[0]
plt.clear()
plt.setStyle(plt.Style.ErrorY)
@@ -20,7 +24,7 @@ def after_sample(record, scan):
try:
S1_averager = create_averager(S1, nav, lat)
A1.write(A1i)
time.sleep(30.0)
time.sleep(wait)
r = lscan(A1, (S1_averager), A1i, A1f, nstep, latency=5.0, after_read = after_sample)
Act1 = r.getPositions(0)
S1mean = [val.mean for val in r.getReadable(0)]
@@ -29,3 +33,15 @@ finally:
A1.write(A1_init)
A1.close()
S1.close()
## add fitting:
pars_polynomial = fit_polynomial(S1mean, Act1, 3)
p1 = PolynomialFunction(pars_polynomial)
resolution = (A1f - A1i)/100
fit_polinomial = []
for x in frange(A1i, A1f, resolution, True):
fit_polinomial.append(p1.value(x))
x = frange(A1i, A1f+resolution, resolution)
#plot(x, fit_polinomial)
plots = plot([S1mean, fit_polinomial] ,
["data", "polinomial"], xdata = [Act1,x], title="Data")

View File

@@ -0,0 +1,28 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Phase (deg.)", "SARUN10-UPHS060:PHI_SET")
S1 = ChannelDouble("energy per pulse (uJ)", "SARFE10-PBIG050-EVR0:CALCI")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = 0.
A1f = 360.
nstep = 20
lat = 1.
nav = 10
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.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
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()

View File

@@ -0,0 +1,23 @@
udlylist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10",
"SATUN11","SATUN12","SATUN13","SATUN15","SATUN16",
"SATUN17","SATUN18","SATUN19","SATUN20","SATUN21")
#for udly in udlylist: caputq(udly + "-UDLY060:OFF-OP", caget(udly + "-CHIC:OFFSET"))
#for udly in udlylist: caputq(udly + "-UDLY060:DEL-OP", caget(udly + "-CHIC:DELAY"))
#for udly in udlylist: caputq(udly + "-UDLY060:PH-SHIFT-OP", caget(udly + "-CHIC:PHASE"))
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-U-SET-OP", caget(udly + "-CHIC:G1"))
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-D-SET-OP", caget(udly + "-CHIC:G2"))
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-U-SET-OP", caget(udly + "-UDLY060:GAP-U-SET"))
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-D-SET-OP", caget(udly + "-UDLY060:GAP-D-SET"))
#for udly in udlylist: caputq(udly + "-UDLY060:OFF-OP", 0.0)
#for udly in udlylist: caputq(udly + "-UDLY060:DEL-OP", 0.600)
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-U-SET", 75)
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-D-SET", 75)
for udly in udlylist: caputq(udly + "-UDLY060:PH-SHIFT-OP", 0.0)
#for udly in udlylist: caputq(udly + "-CHIC:OFFSET", 50.0)
#for udly in udlylist: caputq(udly + "-CHIC:DELAY", 0.600)
#for udly in udlylist: caputq(udly + "-CHIC:G1", 32)
#for udly in udlylist: caputq(udly + "-CHIC:G2", 28)
#for udly in udlylist: caputq(udly + "-CHIC:PHASE", 0.0)

View File

@@ -0,0 +1,22 @@
udlylist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10",
"SATUN11","SATUN12","SATUN13","SATUN15","SATUN16",
"SATUN17","SATUN18","SATUN19","SATUN20","SATUN21")
uindlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
#for udly in udlylist: caputq(udly + "-UDLY060:OFF-OP-SIMU", caget(udly + "-UDLY060:OFF-OP"))
#for udly in udlylist: caputq(udly + "-UDLY060:DEL-OP-SIMU", caget(udly + "-UDLY060:DEL-OP"))
#for udly in udlylist: caputq(udly + "-UDLY060:PH-SHIFT-OP-SIMU", caget(udly + "-UDLY060:PH-SHIFT-OP"))
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-U-SET-SIMU", caget(udly + "-CHIC:G1"))
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-D-SET-SIMU", caget(udly + "-CHIC:G2"))
for udly in udlylist: caputq(udly + "-UDLY060:GAP-U-SET-SIMU", caget(udly + "-UDLY060:GAP-U-SET"))
for udly in udlylist: caputq(udly + "-UDLY060:GAP-D-SET-SIMU", caget(udly + "-UDLY060:GAP-D-SET"))
#for udly in udlylist: caputq(udly + "-UDLY060:OFF-OP-SIMU", 0.0)
#for udly in udlylist: caputq(udly + "-UDLY060:DEL-OP-SIMU", 0.020)
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-U-SET-SIMU", 70)
#for udly in udlylist: caputq(udly + "-UDLY060:GAP-D-SET-SIMU", 60)
#for udly in udlylist: caputq(udly + "-UDLY060:PH-SHIFT-OP-SIMU", 0.0)
#for udly in udlylist: caputq(udly + "-UDLY060:PH-SHIFT-OP-SIMU", caget(udly + "-UDLY060:PH-SHIFT-OP-SIMU") + 360)
#for uind in uindlist: caputq(uind + "-UIND030:K_SET_SIMU", caget(uind + "-UIND030:K_SET"))
#for uind in uindlist: caputq(uind + "-UIND030:POL-SET-SIMU", caget(uind + "-UIND030:POL-SET"))
#caputq("SATCB01:ENE-FILT-OP-SIMU", caget("SATCB01:ENE-FILT-OP"))

View File

@@ -0,0 +1,65 @@
caputq("SATUN06-UDLY060:GAP-U-SET-SIMU", 45.5284121698225)
caputq("SATUN06-UDLY060:GAP-D-SET-SIMU", 45.7245793466707)
caputq("SATUN07-UDLY060:GAP-U-SET-SIMU", 45.6122875866939)
caputq("SATUN07-UDLY060:GAP-D-SET-SIMU", 45.5495116792557)
caputq("SATUN08-UDLY060:GAP-U-SET-SIMU", 45.0316550113184)
caputq("SATUN08-UDLY060:GAP-D-SET-SIMU", 45.0726322443132)
caputq("SATUN09-UDLY060:GAP-U-SET-SIMU", 45.1859352796807)
caputq("SATUN09-UDLY060:GAP-D-SET-SIMU", 45.2128432714865)
caputq("SATUN10-UDLY060:GAP-U-SET-SIMU", 46.7937047025798)
caputq("SATUN10-UDLY060:GAP-D-SET-SIMU", 46.7513031527526)
caputq("SATUN11-UDLY060:GAP-U-SET-SIMU", 52.9447733636882)
caputq("SATUN11-UDLY060:GAP-D-SET-SIMU", 53.5729790819476)
caputq("SATUN12-UDLY060:GAP-U-SET-SIMU", 53.7916892349295)
caputq("SATUN12-UDLY060:GAP-D-SET-SIMU", 53.8300506580993)
caputq("SATUN13-UDLY060:GAP-U-SET-SIMU", 50.4352560592426)
caputq("SATUN13-UDLY060:GAP-D-SET-SIMU", 50.4669477318729)
caputq("SATUN15-UDLY060:GAP-U-SET-SIMU", 64.6414630104251)
caputq("SATUN15-UDLY060:GAP-D-SET-SIMU", 64.6278536657919)
caputq("SATUN16-UDLY060:GAP-U-SET-SIMU", 70.4210617446455)
caputq("SATUN16-UDLY060:GAP-D-SET-SIMU", 70.4253663428239)
caputq("SATUN17-UDLY060:GAP-U-SET-SIMU", 72.8843248347666)
caputq("SATUN17-UDLY060:GAP-D-SET-SIMU", 72.8889551373701)
caputq("SATUN18-UDLY060:GAP-U-SET-SIMU", 68.716248761714)
caputq("SATUN18-UDLY060:GAP-D-SET-SIMU", 68.7308510402703)
caputq("SATUN19-UDLY060:GAP-U-SET-SIMU", 73.4248071668705)
caputq("SATUN19-UDLY060:GAP-D-SET-SIMU", 73.414136218251)
caputq("SATUN20-UDLY060:GAP-U-SET-SIMU", 71.6780919568848)
caputq("SATUN20-UDLY060:GAP-D-SET-SIMU", 71.5809359122368)
caputq("SATUN21-UDLY060:GAP-U-SET-SIMU", 69.6290129308302)
caputq("SATUN21-UDLY060:GAP-D-SET-SIMU", 69.4142627102515)
caputq("SATUN06-UIND030:K_SET_SIMU", 1.51136800800815)
caputq("SATUN07-UIND030:K_SET_SIMU", 2.02084710399842)
caputq("SATUN08-UIND030:K_SET_SIMU", 1.53640591569033)
caputq("SATUN09-UIND030:K_SET_SIMU", 2.54178242706297)
caputq("SATUN10-UIND030:K_SET_SIMU", 2.54185323315769)
caputq("SATUN11-UIND030:K_SET_SIMU", 2.54186507638525)
caputq("SATUN12-UIND030:K_SET_SIMU", 2.54190460717311)
caputq("SATUN13-UIND030:K_SET_SIMU", 2.5418814596268)
caputq("SATUN15-UIND030:K_SET_SIMU", 2.54190138849029)
caputq("SATUN16-UIND030:K_SET_SIMU", 2.54186507638525)
caputq("SATUN17-UIND030:K_SET_SIMU", 2.54190460717311)
caputq("SATUN18-UIND030:K_SET_SIMU", 2.54190138849029)
caputq("SATUN19-UIND030:K_SET_SIMU", 2.54186507638525)
caputq("SATUN20-UIND030:K_SET_SIMU", 2.54186507638525)
caputq("SATUN21-UIND030:K_SET_SIMU", 2.54186507638525)
caputq("SATUN22-UIND030:K_SET_SIMU", 2.54182934195365)
caputq("SATUN06-UDLY060:PH-SHIFT-OP-SIMU", -14.0)
caputq("SATUN07-UDLY060:PH-SHIFT-OP-SIMU", -108.5)
caputq("SATUN08-UDLY060:PH-SHIFT-OP-SIMU", 101.0)
caputq("SATUN09-UDLY060:PH-SHIFT-OP-SIMU", -58.0)
caputq("SATUN10-UDLY060:PH-SHIFT-OP-SIMU", 158.0)
caputq("SATUN11-UDLY060:PH-SHIFT-OP-SIMU", -129.5)
caputq("SATUN12-UDLY060:PH-SHIFT-OP-SIMU", -48.5)
caputq("SATUN13-UDLY060:PH-SHIFT-OP-SIMU", 180.0)
caputq("SATUN15-UDLY060:PH-SHIFT-OP-SIMU", -12.8)
caputq("SATUN16-UDLY060:PH-SHIFT-OP-SIMU", 47.7)
caputq("SATUN17-UDLY060:PH-SHIFT-OP-SIMU", -9.0)
caputq("SATUN18-UDLY060:PH-SHIFT-OP-SIMU", 28.0)
caputq("SATUN19-UDLY060:PH-SHIFT-OP-SIMU", 14.1)
caputq("SATUN20-UDLY060:PH-SHIFT-OP-SIMU", -119.4)
caputq("SATUN21-UDLY060:PH-SHIFT-OP-SIMU", 112.5)

View File

@@ -0,0 +1,16 @@
caputq("SATUN06-UIND030:K_SET_SIMU", 2.04088453330036)
caputq("SATUN07-UIND030:K_SET_SIMU", 2.59901953158514)
caputq("SATUN08-UIND030:K_SET_SIMU", 2.06761290521536)
caputq("SATUN09-UIND030:K_SET_SIMU", 3.18987112455146)
caputq("SATUN10-UIND030:K_SET_SIMU", 3.18995231615947)
caputq("SATUN11-UIND030:K_SET_SIMU", 3.18996589651639)
caputq("SATUN12-UIND030:K_SET_SIMU", 3.19001122560207)
caputq("SATUN13-UIND030:K_SET_SIMU", 3.18998468281204)
caputq("SATUN15-UIND030:K_SET_SIMU", 3.19000753480694)
caputq("SATUN16-UIND030:K_SET_SIMU", 3.18996589651639)
caputq("SATUN17-UIND030:K_SET_SIMU", 3.19001122560207)
caputq("SATUN18-UIND030:K_SET_SIMU", 3.19000753480694)
caputq("SATUN19-UIND030:K_SET_SIMU", 3.18996589651639)
caputq("SATUN20-UIND030:K_SET_SIMU", 3.18996589651639)
caputq("SATUN21-UIND030:K_SET_SIMU", 3.18996589651639)
caputq("SATUN22-UIND030:K_SET_SIMU", 3.18992492068136)

3
script/Undulators/K-calc_AR.py Executable file → Normal file
View File

@@ -3,7 +3,8 @@ Eph2 = 2.425 # desired photon energy in keV. Don't forget .0 at the end!!
do_elog = True
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09","SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09",
"SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
K1, K2 = {}, {}
for und in undlist:

3
script/Undulators/K-calc_AT.py Executable file → Normal file
View File

@@ -3,7 +3,8 @@ Eph2 = 0.710 # desired photon energy in keV. Don't forget .0 at the end!!
do_elog = False
undlist = ("SATUN06", "SATUN07", "SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13","SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
K1, K2 = {}, {}
for und in undlist:

View File

@@ -0,0 +1,20 @@
from random import random
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09",
"SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
i = 0
for und in undlist:
K_taper = (-1)**i * 0.25 + random() * 0.050 - 0.025
i = i + 1
K = caget(und + "-UIND030:K_SET")
K_min = caget(und + "-UIND030:K_SET.DRVL")
K_max = caget(und + "-UIND030:K_SET.DRVH")
if K + K_taper > K_max:
K_taper = K_max - K - random() * 0.025
if K + K_taper < K_min:
K_taper = K_min - K + random() * 0.025
print(K, K_taper, K + K_taper)
caputq(und + "-UIND030:K_TAPER_SET", K_taper)
set_return("Success")

10
script/Undulators/K_AR_scale.py Executable file → Normal file
View File

@@ -3,9 +3,11 @@ Eph1 = caget("SARUN:FELPHOTENE")
Eph2 = Eph1 + dEph
do_elog = True
#do_elog = True
do_elog = False
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09","SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09",
"SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
K1, K2 = {}, {}
for und in undlist:
@@ -18,7 +20,7 @@ for und in undlist: caputq(und + "-UIND030:K_SET", K2[und])
#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"
log_msg = "Old photon energy: %0.3f" % Eph1 + " kev\n"
log_msg = log_msg + "New photon energy: %0.3f" % Eph2 + " keV\n"
elog(title, log_msg)

View File

@@ -0,0 +1,21 @@
print "ENTER"
taper_lin = caget("SARUN:TAPER-LIN") * 1e-6
taper_qua = caget("SARUN:TAPER-QUA") * 1e-6
taper_lin_start = caget("SARUN:TAPER-LIN-START.RVAL")
taper_lin_stop = caget("SARUN:TAPER-LIN-STOP.RVAL")
taper_qua_start = caget("SARUN:TAPER-QUA-START.RVAL")
taper_qua_stop = caget("SARUN:TAPER-QUA-STOP.RVAL")
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09",
"SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
u = 0
i, j = 0, 0
for und in undlist:
K_taper = taper_lin * i + taper_qua * j**2
if taper_lin_start <= u <= taper_lin_stop: i = i + 1
if taper_qua_start <= u <= taper_qua_stop: j = j + 1
caputq(und + "-UIND030:K_TAPER_SET", K_taper)
u = u + 1
set_return("Success")

View File

@@ -0,0 +1,10 @@
undlist = ("SARUN03","SARUN04","SARUN05","SARUN06","SARUN07","SARUN08","SARUN09",
"SARUN10","SARUN11","SARUN12","SARUN13","SARUN14","SARUN15")
for und in undlist:
K = caget(und + "-UIND030:K_SET")
K_taper = caget(und + "-UIND030:K_TAPER_SET")
K = K + K_taper
caputq(und + "-UIND030:K_SET", K)
caputq(und + "-UIND030:K_TAPER_SET", 0.0)

View File

@@ -0,0 +1,20 @@
from random import random
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09",
"SATUN10","SATUN11","SATUN12","SATUN13")
i = 0
for und in undlist:
K_taper = (-1)**i * 0.25 + random() * 0.050 - 0.025
i = i + 1
K = caget(und + "-UIND030:K_SET")
K_min = caget(und + "-UIND030:K_SET.DRVL")
K_max = caget(und + "-UIND030:K_SET.DRVH")
if K + K_taper > K_max:
K_taper = K_max - K - random() * 0.025
if K + K_taper < K_min:
K_taper = K_min - K + random() * 0.025
print(K, K_taper, K + K_taper)
caputq(und + "-UIND030:K_TAPER_SET", K_taper)
set_return("Success")

View File

@@ -0,0 +1,20 @@
from random import random
undlist = ("SATUN15","SATUN16","SATUN17","SATUN18",
"SATUN19","SATUN20","SATUN21","SATUN22")
i = 0
for und in undlist:
K_taper = (-1)**i * 0.25 + random() * 0.050 - 0.025
i = i + 1
K = caget(und + "-UIND030:K_SET")
K_min = caget(und + "-UIND030:K_SET.DRVL")
K_max = caget(und + "-UIND030:K_SET.DRVH")
if K + K_taper > K_max:
K_taper = K_max - K - random() * 0.025
if K + K_taper < K_min:
K_taper = K_min - K + random() * 0.025
print(K, K_taper, K + K_taper)
caputq(und + "-UIND030:K_TAPER_SET", K_taper)
set_return("Success")

View File

@@ -0,0 +1,22 @@
from random import random
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09",
"SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18",
"SATUN19","SATUN20","SATUN21","SATUN22")
i = 0
for und in undlist:
K_taper = (-1)**i * 0.25 + random() * 0.180 - 0.090
i = i + 1
K = caget(und + "-UIND030:K_SET")
K_min = caget(und + "-UIND030:K_SET.DRVL")
K_max = caget(und + "-UIND030:K_SET.DRVH")
if K + K_taper > K_max:
K_taper = K_max - K - random() * 0.025
if K + K_taper < K_min:
K_taper = K_min - K + random() * 0.025
print(K_taper)
caputq(und + "-UIND030:K_TAPER_SET", K_taper)
set_return("Success")

View File

@@ -1,11 +1,10 @@
dEph = caget("SATUN:USER-DELTA")
Eph1 = caget("SATUN13-UIND030:FELPHOTENE")
Eph1 = caget("SATUN:FELPHOTENE")
Eph2 = Eph1 + dEph
do_elog = True
undlist = ("SATUN06", "SATUN07", "SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13","SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
K1, K2 = {}, {}
for und in undlist:
@@ -13,31 +12,9 @@ for und in undlist:
K1[und] = K
K2[und] = ((Eph1 / Eph2 * (K**2 + 2) - 2))**0.5
print K1,K2
for und in undlist: caputq(und + "-UIND030:K_SET", K2[und])
time.sleep(0.5) # Make sure the new K values have been written
onPVlist, goPVlist = [], []
for und in undlist:
caputq(und + "-UIND030:K_SET", K2[und])
onPVlist.append(und + '-UIND030:RADIAL-ON.PROC')
goPVlist.append(und + '-UIND030:RADIAL-GO.PROC')
time.sleep(0.5)
#Switching on radial motors (and pushing go) to ensure proper movements
for onPV in onPVlist: caput(onPV, 1)
time.sleep(0.5)
for goPV in goPVlist: caput(goPV, 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"
elog(title, log_msg)
#Setting the gas detector photon energy
caputq("SATFE10-PEPG046:ENERGY", Eph2)
#Run Eugenio's phase-shifter/CHIC calculation
time.sleep(5.0)
caputq("SATUN-CHIC:PHOTON-ENERGY", Eph2)
time.sleep(0.2)
caputq("SATUN-CHIC:APPLY-DELAY-OFFSET-PHASE", 1)
for und in undlist: caput(und + "-UIND030:RADIAL-ON.PROC", 1)
for und in undlist: caput(und + "-UIND030:RADIAL-GO.PROC", 1)

View File

@@ -0,0 +1,19 @@
dEph = caget("SATUN:USER-DELTA")
Eph1 = caget("SATUN06-UIND030:FELPHOTENE")
Eph2 = Eph1 + dEph
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13")
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
print K1,K2
for und in undlist: caputq(und + "-UIND030:K_SET", K2[und])
time.sleep(0.5) # Make sure the new K values have been written
#Switching on radial motors (and pushing go) to ensure proper movements
for und in undlist: caput(und + "-UIND030:RADIAL-ON.PROC", 1)
for und in undlist: caput(und + "-UIND030:RADIAL-GO.PROC", 1)

View File

@@ -0,0 +1,19 @@
dEph = caget("SATUN:USER-DELTA")
Eph1 = caget("SATUN15-UIND030:FELPHOTENE")
Eph2 = Eph1 + dEph
undlist = ("SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
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
print K1,K2
for und in undlist: caputq(und + "-UIND030:K_SET", K2[und])
time.sleep(0.5) # Make sure the new K values have been written
#Switching on radial motors (and pushing go) to ensure proper movements
for und in undlist: caput(und + "-UIND030:RADIAL-ON.PROC", 1)
for und in undlist: caput(und + "-UIND030:RADIAL-GO.PROC", 1)

View File

@@ -1,33 +0,0 @@
dEph = caget("SATUN:USER-DELTA")
Eph1 = caget("SATUN:FELPHOTENE")
Eph2 = Eph1 + dEph
do_elog = True
undlist = ("SATUN06", "SATUN07", "SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13","SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
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
print K1,K2
for und in undlist: caputq(und + "-UIND030:K_SET", K2[und])
time.sleep(0.5) # Make sure the new K values have been written
#Switching on radial motors (and pushing go) to ensure proper movements
for und in undlist: caput(und + "-UIND030:RADIAL-ON.PROC", 1)
for und in undlist: caput(und + "-UIND030:RADIAL-GO.PROC", 1)
time.sleep(5.0) # Make sure the undulators finished moving
#Run Eugenio's phase-shifter/CHIC calculation
caput("SATUN-CHIC:PHOTON-ENERGY", Eph2)
caput("SATUN-CHIC:APPLY-DELAY-OFFSET-PHASE", 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"
elog(title, log_msg)

View File

@@ -0,0 +1,18 @@
taper_lin = caget("SATUN:TAPER-LIN") * 1e-6
taper_qua = caget("SATUN:TAPER-QUA") * 1e-6
taper_lin_start = caget("SATUN:TAPER-LIN-START.RVAL")
taper_lin_stop = caget("SATUN:TAPER-LIN-STOP.RVAL")
taper_qua_start = caget("SATUN:TAPER-QUA-START.RVAL")
taper_qua_stop = caget("SATUN:TAPER-QUA-STOP.RVAL")
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
u = 0
i, j = 0, 0
for und in undlist:
K_taper = taper_lin * i + taper_qua * j**2
if taper_lin_start <= u <= taper_lin_stop: i = i + 1
if taper_qua_start <= u <= taper_qua_stop: j = j + 1
caputq(und + "-UIND030:K_TAPER_SET", K_taper)
u = u + 1

View File

@@ -0,0 +1,18 @@
taper_lin = caget("SATUN:TAPER-LIN") * 1e-6
taper_qua = caget("SATUN:TAPER-QUA") * 1e-6
taper_lin_start = caget("SATUN:TAPER-LIN-START.RVAL")
taper_lin_stop = caget("SATUN:TAPER-LIN-STOP.RVAL")
taper_qua_start = caget("SATUN:TAPER-QUA-START.RVAL")
taper_qua_stop = caget("SATUN:TAPER-QUA-STOP.RVAL")
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
u = 0
i, j = 0, 0
for und in undlist:
K_taper = taper_lin * i + taper_qua * j**2
if taper_lin_start <= u <= taper_lin_stop: i = i + 1
if taper_qua_start <= u <= taper_qua_stop: j = j + 1
if 0 <= u <= 7: caputq(und + "-UIND030:K_TAPER_SET", K_taper)
u = u + 1

View File

@@ -0,0 +1,18 @@
taper_lin = caget("SATUN:TAPER-LIN") * 1e-6
taper_qua = caget("SATUN:TAPER-QUA") * 1e-6
taper_lin_start = caget("SATUN:TAPER-LIN-START.RVAL")
taper_lin_stop = caget("SATUN:TAPER-LIN-STOP.RVAL")
taper_qua_start = caget("SATUN:TAPER-QUA-START.RVAL")
taper_qua_stop = caget("SATUN:TAPER-QUA-STOP.RVAL")
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
u = 0
i, j = 0, 0
for und in undlist:
K_taper = taper_lin * i + taper_qua * j**2
if taper_lin_start <= u <= taper_lin_stop: i = i + 1
if taper_qua_start <= u <= taper_qua_stop: j = j + 1
if 8 <= u <= 15: caputq(und + "-UIND030:K_TAPER_SET", K_taper)
u = u + 1

View File

@@ -0,0 +1,10 @@
undlist = ("SATUN06","SATUN07","SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13",
"SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
for und in undlist:
K = caget(und + "-UIND030:K_SET")
K_taper = caget(und + "-UIND030:K_TAPER_SET")
K = K + K_taper
caputq(und + "-UIND030:K_SET", K)
caputq(und + "-UIND030:K_TAPER_SET", 0.0)

View File

@@ -0,0 +1,26 @@
unit = "SATUN06"
bpmlist = ("SATUN01-DBPM070","SATUN02-DBPM070", "SATUN03-DBPM070", "SATUN04-DBPM070", "SATUN05-DBPM410", "SATUN06-DBPM070", "SATUN07-DBPM070", "SATUN08-DBPM070", "SATUN09-DBPM070", "SATUN10-DBPM070", "SATUN11-DBPM070", "SATUN12-DBPM070", "SATUN13-DBPM070", "SATUN14-DBPM410", "SATUN15-DBPM070", "SATUN16-DBPM070", "SATUN17-DBPM070", "SATUN18-DBPM070", "SATUN19-DBPM070", "SATUN20-DBPM070", "SATUN21-DBPM070", "SATUN22-DBPM070", "SATMA02-DBPM030", "SATMA02-DBPM060", "SATBD01-DBPM020", "SATBD01-DBPM060", "SATBD01-DBPM100")
bpmlist2 = ("SATUN01-DBPM070","SATUN02-DBPM070", "SATUN03-DBPM070", "SATUN04-DBPM070", "SATUN05-DBPM410", "SATUN06-DBPM070", "SATUN07-DBPM070", "SATUN08-DBPM070", "SATUN09-DBPM070", "SATUN10-DBPM070")
def read(bpmlist):
X, Y = [], []
for bpm in bpmlist:
X.append(caget(bpm + ":X2"))
Y.append(caget(bpm + ":Y2"))
return X, Y
def average(bpmlist):
X,Y = [0 for i in range(27)], [0 for i in range(27)]
for i in range(10):
x, y = read(bpmlist)
X = arradd(X,x)
Y = arradd(Y,y)
print(i)
for val in X: val = val / 10
for val in Y: val = val / 10
return X, Y
X1, Y1 = average(bpmlist)
print(X1, Y1)
res = Lscan

View File

@@ -0,0 +1,20 @@
devlist = ['SARUN03', 'SARUN04', 'SARUN05', \
'SARUN06', 'SARUN07', 'SARUN08', 'SARUN09', 'SARUN10', \
'SARUN11', 'SARUN12', 'SARUN13', 'SARUN14', 'SARUN15']
bpm_x = "-DBPM070:OFFS-X"
bpm_y = "-DBPM070:OFFS-Y"
gm_x = "-UIND030:GM-X-SET"
gm_y = "-UIND030:GM-Y-SET"
for i,dev in enumerate(devlist):
off_x = round(caget(dev + bpm_x),3)
off_y = round(caget(dev + bpm_y),3)
#off_y = 0.01
gm_pos_x = round(caget(dev + gm_x),3)
gm_pos_y = round(caget(dev + gm_y),3)
gm_new_pos_x = gm_pos_x + off_x
gm_new_pos_y = gm_pos_y + off_y
#print(dev + gm_x + ': gm_new_pos_x = ' + str(gm_new_pos_x) + ' mm, offset = ' + str(off_x) + ' mm')
print(dev + gm_y + ': gm_new_pos_y = ' + str(gm_new_pos_y) + ' mm, offset = ' + str(off_y) + ' mm')
#caput(dev + gm_x, float(gm_new_pos_x))
caput(dev + gm_y, float(gm_new_pos_y))

View File

@@ -0,0 +1,24 @@
# PPRM113 position: OAPU044 closed (um)
x1_scr = 29.0
y1_scr = 75.0
# PPRM113 position: OAPU092 closed (um)
x2_scr = 14.0
y2_scr = 75.0
# PPRM113 position: max intensity (um)
xm_scr = 20.0
ym_scr = 75.0
z_sarun09 = 537.248
z_oapu044 = 612.238
z_oapu092 = 656.239
z_pprm113 = 680.843
d1 = z_pprm113 - z_oapu044
d2 = z_oapu044 - z_sarun09
d3 = z_pprm113 - z_oapu092
d4 = z_oapu092 - z_sarun09
k = d1 / d2 - d3 / d4
dx_offset = 1 / k * (x1_scr - x2_scr)
dy_offset = 1 / k * (y1_scr - y2_scr)
dx_slope = -(dx_offset / d4 + (xm_scr - x2_scr) / (d1 + d2)) * 4.750
dy_slope = -(dy_offset / d4 + (ym_scr - y2_scr) / (d1 + d2)) * 4.750
print(dx_offset, dy_offset)
print(dx_slope, dy_slope)

View File

@@ -0,0 +1,64 @@
IN_POSITION_BAND = 10.0
# EInkommentieren fuer Messungen Mit PSCR136
# Auskommentieren fuer Messungen Mit PCEL
#
#cam_server.start("SATOP31-PSCR136_sp1", True)
cam_server.start("SATOP31-PSRD175_sp1", True)
#cam_server.start("SATOP31-PPRM176_sp1", True)
cam_server.stream.waitCacheChange(-1)
i= cam_server.stream.getChild("intensity")
i_avg = create_averager(i, 20, interval = -1)
# muss auskommentiert bleiben
#Keithley = Channel("SATOP31-CSSU-PCEL1381:READOUT",'d', monitored ='True')
#K_avg = create_averager(Keithley, 5, interval = -1)
def beam_ok():
I0 = caget ("SATFE10-PEPG046:PHOTON-ENERGY-PER-PULSE-AVG")
if I0 > 100:
return "Yes"
else :
return "Yes"
def before_sampling(rec):
while beam_ok() == "No":
time.sleep(0.1)
print(".")
def after_sampling(rec):
if beam_ok() == "No":
rec.invalidate()
i0 = Channel("SATFE10-PEPG046:PHOTON-ENERGY-PER-PULSE-AVG",'d')
class VLSSGM(RegisterBase):
def doWrite(self, value):
caput ("SATOP11-OSGM087:SetEnergy", value)
time.sleep(0.2)
cawait('SATOP11-OSGM087:MOVING', 1, timeout = 20.0, type = 'i')
def doRead(self):
return caget("SATOP11-OSGM087:photonenergy")
athos = VLSSGM()
athos.initialize()
# startenergy, stopenergy, schrittweite, wartezeit,
lscan( athos, [i0,i_avg], 1600.0, 1720.0, 5.0, 0.5, setpoints=True,zigzag=True) # Scans mit PSCR136
#lscan( athos, [i0,K_avg], 833.5, 837, 0.05, 0.5, setpoints=True,zigzag=True) # Scans mit PCEL
#lscan( athos, [i0,i_avg], 760.0, 820.0, 2.0, 0.5, setpoints=True,zigzag=True) # Scans mit PSCR136
#lscan( athos, [i0,i_avg], 380.0, 410.0, 1.0, 0.5, setpoints=True,zigzag=True) # Scans mit PSCR136
#caput ("ATHOS:SetEnergy", 680.0)
#tscan( [i], 10, 1 , passes=1)