Correlation Stream

This commit is contained in:
root
2021-02-24 10:49:05 +01:00
parent 9547784e17
commit 5237b9ddc3
64 changed files with 458 additions and 185 deletions
+4 -1
View File
@@ -1,4 +1,4 @@
#Thu Nov 07 14:59:30 CET 2019
#Fri Aug 14 16:52:45 CEST 2020
hostName=
userManagement=false
instanceName=OP
@@ -16,6 +16,7 @@ dataScanReleaseRecords=false
depthDimension=0
dataScanPreserveTypes=false
logLevel=Fine
dataScanSaveOutput=false
dataScanFlushRecords=false
logPath={logs}/{date}_{time}
dataLayout=sf
@@ -28,6 +29,8 @@ terminalPort=3579
tasksFile={config}/tasks.properties
dataScanStrategy=default
scanStreamerPort=-1
dataScanSaveScript=false
dataScanSaveSetpoints=false
parallelInitialization=false
scanDataRelease=false
createSessionFiles=false
+8 -7
View File
@@ -1,11 +1,12 @@
#Thu Apr 27 10:45:41 CEST 2017
ch.psi.jcae.ContextFactory.addressList=172.26.0.255 172.26.2.255 172.26.8.255 172.26.16.255 172.26.24.255 172.26.32.255 172.26.40.255 172.26.120.255
#Tue Feb 23 17:41:13 CET 2021
ch.psi.jcae.ContextFactory.maxArrayBytes=50000000
ch.psi.jcae.ChannelFactory.retries=1
ch.psi.jcae.ChannelFactory.timeout=1250
ch.psi.jcae.impl.DefaultChannelService.retries=4
ch.psi.jcae.impl.DefaultChannelService.timeout=1000
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.ContextFactory.autoAddressList=true
ch.psi.jcae.ChannelFactory.timeout=1250
ch.psi.jcae.ContextFactory.maxSendArrayBytes=100000
ch.psi.jcae.ChannelFactory.retries=1
ch.psi.jcae.ContextFactory.useShellVariables=true
ch.psi.jcae.ContextFactory.addLocalBroadcastInterfaces=false
ch.psi.jcae.ContextFactory.addressList=172.26.0.255 172.26.2.255 172.26.8.255 172.26.16.255 172.26.24.255 172.26.32.255 172.26.40.255 172.26.120.255
ch.psi.jcae.ContextFactory.serverPort=
ch.psi.jcae.impl.DefaultChannelService.retries=4
ch.psi.jcae.ContextFactory.autoAddressList=true
+1
View File
@@ -0,0 +1 @@
Correlation/correlation_stream=-1.0
+2 -2
View File
@@ -1,2 +1,2 @@
#Mon Aug 03 14:24:23 CEST 2020
FileSequentialNumber=2478
#Wed Feb 24 10:42:43 CET 2021
FileSequentialNumber=4432
+15 -14
View File
@@ -1,7 +1,4 @@
#Thu Aug 13 08:13:01 CEST 2020
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000=
\u0000\u0000\u0000\u0000=
#Wed Feb 24 10:45:54 CET 2021
\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
@@ -9,36 +6,40 @@
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000=
\u0000\u0000\u0000=
\u0000\u0000=
\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000=
\u0000=
\u0000\u0000\u0000\u0000=
colormapLogarithmic=false
spatialCalScaleX=-1.0
spatialCalScaleY=-1.0
spatialCalScaleX=-27.972029584893434
spatialCalScaleY=-27.855154398999183
serverURL=null
rescaleOffset=0.0
roiWidth=-1
colormap=Flame
imageWidth=2560
imageWidth=1920
invert=false
colormapMin=814.0
colormapMin=77.0
rotationCrop=false
roiHeight=-1
colormapAutomatic=true
roiY=0
roiX=0
spatialCalOffsetY=-50.048780487804876
spatialCalOffsetX=-50.03903200624512
spatialCalOffsetY=-91.59477274098214
spatialCalOffsetX=-132.60829335501532
scale=1.0
regionStart=
grayscale=false
colormapMax=3092.0
colormapMax=878.0
spat=
rotation=0.0
rescaleFactor=1.0
imageHeight=2160
imageHeight=1200
spatialCalUnits=null
flipVertically=false
r=
t=
flipHorizontally=false
transpose=false
regionStartX=1
regionStartY=1
regionStartX=8
regionStartY=8
+3 -3
View File
@@ -1,4 +1,4 @@
#Tue Apr 28 11:13:53 CEST 2020
#Mon Nov 30 03:01:09 CET 2020
offset=0.0
maxValue=51500.0
precision=1
@@ -9,10 +9,10 @@ maxSpeed=2000.0
resolution=0.1
homingType=None
startRetries=1
minValue=-56300.0
minValue=-56937.0
unit=um
defaultSpeed=2000.0
hasEnable=false
sign_bit=0
monitorByPosition=false
minSpeed=50.0
minSpeed=1.0
+4 -3
View File
@@ -1169,7 +1169,7 @@ ChannelDouble channelEndY;
}//GEN-LAST:event_buttonParkActionPerformed
//String caqtdm = "caqtdm -noMsg -stylefile sfop.qss -attach";
String caqtdm = "startDM -noMsg -stylefile sfop.qss";
//String caqtdm = "startDM -noMsg -stylefile sfop.qss";
ch.psi.pshell.core.Plugin calibrationPlugin;
private void buttonCalibrationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonCalibrationActionPerformed
try {
@@ -1185,8 +1185,9 @@ ChannelDouble channelEndY;
}//GEN-LAST:event_buttonCalibrationActionPerformed
private void buttonScannerPanelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonScannerPanelActionPerformed
try {
String cmd = caqtdm + " -macro 'SYS=" + comboWireScanner.getSelectedItem() + "' /sf/common/config/qt/S_DI_WSC_EXPERT.ui";
try {
//String cmd = caqtdm + " -macro 'SYS=" + comboWireScanner.getSelectedItem() + "' /sf/common/config/qt/S_DI_WSC_EXPERT.ui";
String cmd = "caqtdm -macro \"SYS=" + comboWireScanner.getSelectedItem() + "\" S_DI_WSC_EXPERT.ui";
System.out.println(cmd);
Runtime.getRuntime().exec(new String[]{"bash", "-c", cmd.toString()});
} catch (Exception ex) {
+2 -2
View File
@@ -58,8 +58,8 @@ X2_averager.monitored = True # not blocking, will return last n
#Record callback: uptate of output plot
def after_sample(record, scan):
global plt,i
X1_mean, X1_stdev = record.values[0].mean, record.values[0].stdev
X2_mean, X2_stdev = record.values[1].mean, record.values[1].stdev
X1_mean, X1_stdev = record[0].mean, record[0].stdev
X2_mean, X2_stdev = record[1].mean, record[1].stdev
plt.getSeries(i).appendData(X1_mean, X2_mean, X1_stdev, X2_stdev)
#The scan loop
+4 -4
View File
@@ -71,10 +71,10 @@ if not dry_run:
def after_sample(record, scan):
x = record.values[0]
y = record.values[1]
stdev_x = record.values[2]
stdev_y = record.values[3]
x = record[0]
y = record[1]
stdev_x = record[2]
stdev_y = record[3]
if source in ["camtool", "server"]:
#x, y, stdev_x, stdev_y = x.mean, y.mean, stdev_x.mean, stdev_y.mean
x, y, stdev_x, stdev_y = x.mean, y.mean, x.stdev, y.stdev
+4 -4
View File
@@ -73,10 +73,10 @@ if not dry_run:
def after_sample(record, scan):
x = record.values[0]
y = record.values[1]
stdev_x = record.values[2]
stdev_y = record.values[3]
x = record[0]
y = record[1]
stdev_x = record[2]
stdev_y = record[3]
if source in ["camtool", "server"]:
#x, y, stdev_x, stdev_y = x.mean, y.mean, stdev_x.mean, stdev_y.mean
x, y, stdev_x, stdev_y = x.mean, y.mean, x.stdev, y.stdev
+1 -1
View File
@@ -150,7 +150,7 @@ try:
#Sample and plot data
if bs == True:
_stream.waitValueNot(_stream.take(), 10000)
bsdata = list(_stream.take().values)
bsdata = list(_stream.take().values())
if dxtype==TYPE_CHANNEL:
x=dx.read()
+163
View File
@@ -0,0 +1,163 @@
"""
Run as:
pshell_be -l -test -c -f="users/edwin/correlation_stream.py" -args="PREFIX:'SLAAR-LBSTREAM1'"
or with additional parameters:
pshell_be -l -test -c -f="users/edwin/correlation_stream.py" -args="PREFIX:'SLAAR-LBSTREAM1',VERBOSE:False,TIME_INTERVAL:2.0"
"""
if not "PREFIX" in globals():
PREFIX = "SLAAR-LBSTREAM1"
if not "VERBOSE" in globals():
VERBOSE = False
if not "TIME_INTERVAL" in globals():
TIME_INTERVAL = 1.0
EMPTY_VALUE = 1112223330
if PREFIX[-1] != ":":
PREFIX = PREFIX + ":"
def get_channel_list():
ch=[]
try:
for i in range(20):
v= caget(PREFIX + "NAME" + str(i+1))
if v.strip()=="":
break
ch.append(str(v.strip()))
except:
pass
return ch
def ack_channel_list(channel_list):
try:
s=""
for c in channel_list:
s=s+c+"\n"
s=s+"\x00"
caput(PREFIX + "PACK_LIST",[ord(c) for c in s])
except:
pass
def start_stream(channel_list):
try:
st=None
print "Starting stream"
if len(channel_list)==0:
raise Exception ("No channel defined")
st = Stream("pulse_id", dispatcher)
for c in channel_list:
st.addScalar(c, c, 1, 0)
st.initialize()
st.start()
st.waitCacheChange(10000) #Wait stream be running before starting scan
if st.take() is None:
raise Exception("Error initializing data stream")
ack_channel_list(channel_list)
print "Stream started"
except:
stop_stream(st)
st=None
print sys.exc_info()[1]
return st
def stop_stream(st):
try:
if st:
st.close()
st=None
print "Stream closed"
except:
print sys.exc_info()[1]
finally:
ack_channel_list([])
#def on_start_change(val):
# fork(start_stream if (val==1) else stop_stream)
#start = Channel(PREFIX + "START_STOP", type = 'i', monitored = True, callback=on_start_change)
t0=None
pid=None
def handle_message(msg, channel_list, buf):
global t0, pid
if t0 is None:
t0 = time.time()
now=time.time()
num_channels = len(channel_list)
size_buffer= 300 #int((len(buf)-100)/(len(channel_list)+1))
buf[0] = msg.pulseId
buf[1] = num_channels
buf[4] = EMPTY_VALUE
#if (pid is not None) and ((pid+1) != msg.pulseId):
# print "Missing pid: ", (pid+1)
pid = msg.pulseId
#Count
if buf[2] < size_buffer:
buf[2] = buf[2]+1
#Index
buf[3] = buf[3]+1
if buf[3] == size_buffer:
buf[3]=0
index = int(buf[3])*(num_channels+1) + 10
buf[index] = msg.pulseId
index = index+1
for v in msg.values():
buf[index] = EMPTY_VALUE if ((v is None) or (math.isnan(v)))else v
index = index+1
if now >= (t0 + TIME_INTERVAL):
if VERBOSE:
print to_list(buf[0:5])
t0 = time.time()
return True
return False
def run():
channel_list = []
st=None
start = Channel(PREFIX + "START_STOP", type = 'i')
outp = Channel(PREFIX + "PACK_DATA", type = '[d')
buf = to_array([0]*outp.get_size(),'d')
buf[2] = 0
buf[3]= -1
try:
while True:
started = (start.get()==1)
if started and not st:
print "Started"
channel_list=get_channel_list()
print "Channel list: ", channel_list
st = start_stream(channel_list)
if st is not None:
class StreamListener (DeviceListener):
def onValueChanged(self, device, value, former):
if handle_message(value, channel_list, buf):
outp.putq(buf)
listener = StreamListener()
st.addListener(listener)
elif st and not started:
print "Stopped"
channel_list=[]
stop_stream(st)
st = None
"""
if st:
st.waitCacheChange(0)
if handle_message(st.take(), channel_list, buf):
outp.putq(buf)
time.sleep(0.001)
else:
time.sleep(0.1)
"""
time.sleep(0.1)
finally:
stop_stream(st)
if outp: outp.close()
if start: start.close()
if __name__ == "__main__":
run()
+1 -1
View File
@@ -58,7 +58,7 @@ park_pos = caget (prefix + ":P0_U0_SP")
#List of stream channels
channels = [] #[("m_pos", scanner.motor_bs_readback.get_name()), ]
channels = [] #[("m_pos", scanner.motor_bs_readback.getName()), ]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
series = LinePlotSeries(blms[i], None, min(i+1, 2))
+2 -2
View File
@@ -39,8 +39,8 @@ plt.setLegendVisible(True)
def plot_point(record, scan):
global plt
q_mean, q_stdev = record.values[0].mean, record.values[0].stdev
V_mean, V_stdev = record.values[1].mean, recFd.values[1].stdev
q_mean, q_stdev = record.readables[0].mean, record.readables[0].stdev
V_mean, V_stdev = record.readables[1].mean, recFd.readables[1].stdev
plt.getSeries(0).appendData(record.positions[0], q_mean, q_stdev)
plt.getSeries(1).appendData(record.positions[0], V_mean, V_stdev)
+7 -6
View File
@@ -83,9 +83,9 @@ if prefix not in get_wire_scanners():
scanner = WireScanner(prefix, scan_range, cycles, None, True)
#List of stream channels
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("cur_cycle", scanner.curr_cycl.get_name()),
("scanning", scanner.status_channels[0].get_name())]
channels = [("m_pos", scanner.motor_bs_readback.getName()),
("cur_cycle", scanner.curr_cycl.getName()),
("scanning", scanner.status_channels[0].getName())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B" + str(bunch) + "_LOSS"))
@@ -459,7 +459,7 @@ try:
st.getChild("blm1_ws_mode").waitValue(1, SET_BLM_WS_BS_READBACK_TIMEOUT)
print "Reading background..."
do_background()
stream_filter = scanner.curr_cycl.get_name() + ">0"
stream_filter = scanner.curr_cycl.getName() + ">0"
if filter_beam_ok:
stream_filter = stream_filter + " AND " + get_beam_ok_channel(bunch) + " == 1"
st.setFilter(stream_filter)
@@ -470,7 +470,8 @@ try:
do_scan(1)
finally:
try:
scanner.park(wait=False)
scanner.park(wait=False)
pass
except:
pass
if SET_BLM_WS_MODE and len(blms)>0:
@@ -504,4 +505,4 @@ if do_elog:
set_exec_pars(open=False)
print ret
set_return(ret)
set_return(ret)
@@ -20,7 +20,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
@@ -20,7 +20,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -22,7 +22,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -28,7 +28,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -30,7 +30,7 @@ def after_sample(record, scan):
record.invalidate()
print "Invalidating record: " + str(record)
else:
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -30,7 +30,7 @@ def after_sample(record, scan):
record.invalidate()
print "Invalidating record: " + str(record)
else:
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -19,7 +19,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat1)
A1.write(A1i)
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat1)
A1.write(A1i)
+28
View File
@@ -0,0 +1,28 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("actname", "S20SY02-MKAC040:I-SET")
S1 = ChannelDouble("sensname", "SARFE10-PBPG050:HAMP-INTENSITY-AVG")
A1.initialize()
S1.initialize()
A1_init = A1.read()
A1i = 244.58
A1f = 254.82
step = 0.5122
lat1 = 0.11
lat2 = 1.0
nav = 300
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, lat1)
A1.write(A1i)
time.sleep(2.0)
r = lscan(A1, (S1_averager), A1i, A1f, step, latency=lat2, after_read = after_sample)
Act1 = r.getPositions(0)
finally:
A1.write(A1_init)
A1.close()
S1.close()
+50
View File
@@ -0,0 +1,50 @@
import ch.psi.pshell.epics.ChannelDouble as ChannelDouble
A1 = ChannelDouble("Phase", "S20SY02-MKAC040:PHASE-SET")
S1 = ChannelDouble("BPM-Y", "SARMA02-DBPM040:Y1")
#S2 = ChannelDouble("SATSY01-DBPM010:Y1", "SATSY01-DBPM010:Y1")
#S3 = ChannelDouble("SATSY01-DBPM010:Q1", "SATSY01-DBPM010:Q1")
#S4 = ChannelDouble("S20SY02-DBPM120:Y1", "S20SY02-DBPM120:Y1")
A1.initialize()
S1.initialize()
#S2.initialize()
#S3.initialize()
#S4.initialize()
A1_init = A1.read()
A1i = 265.0
A1f = 275.0
step = 0.5
lat = 1.0
nav = 4
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)
#S2_averager = create_averager(S2, nav, lat)
#S2_averager.monitored=True
#S3_averager = create_averager(S3, nav, lat)
#S3_averager.monitored=True
#S4_averager = create_averager(S4, nav, lat)
#S4_averager.monitored=True
time.sleep(4.0)
#r = lscan(A1, (S1_averager, S2_averager, S3_averager, S4_averager), A1i, A1f, step, latency=0.5, after_read = after_sample)
r = lscan(A1, (S1_averager), A1i, A1f, step, latency=0.5, 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)]
#S3mean = [val.mean for val in r.getReadable(2)]
#S3rmsn = [val.stdev for val in r.getReadable(2)]
#S4mean = [val.mean for val in r.getReadable(3)]
#S4rmsn = [val.stdev for val in r.getReadable(3)]
finally:
A1.write(A1_init)
A1.close()
S1.close()
#S2.close()
#S3.close()
#S4.close()
+1 -1
View File
@@ -20,7 +20,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, 0.2)
S2_averager = create_averager(S2, nav, 0.2)
+1 -1
View File
@@ -30,7 +30,7 @@ def after_sample(record, scan):
record.invalidate()
print "Invalidating record: " + str(record)
else:
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, 0.1)
S2_averager = create_averager(S2, nav, 0.1)
+1 -1
View File
@@ -22,7 +22,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, 0.1)
r = ascan((A1,A2), (S1_averager), (A1i,A2i), (A1f,A2f), (nstep,nstep), latency=lat, after_read = after_sample)
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -20,7 +20,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
View File
+1
View File
@@ -0,0 +1 @@
[ "Linear", [ [ "Channel", "SATFE10-PEPG046:MOTOR_X.VAL", -1.0, 1.0, 0.1 ] ], [ [ "Channel", "SATFE10-PEPG046-DS1:READ.VAL", 10, 0, "Enabled" ], [ "Channel", "SATFE10-PEPG046-DS2:READ.VAL", 10, 0, "Enabled" ] ], false, [ ], "PEPG X-position scan", 1, 1.0, 20.0, false, false, true, true, "", "", " ", "", 0, null, null, "Positioner", false, true ]
+1
View File
@@ -0,0 +1 @@
[ "Linear", [ [ "Channel", "SATFE10-PEPG046:MOTOR_Y.VAL", -1.0, 1.0, 0.1 ] ], [ [ "Channel", "SATFE10-PEPG046-US1:READ.VAL", 10, 0, "Enabled" ], [ "Channel", "SATFE10-PEPG046-US2:READ.VAL", 10, 0, "Enabled" ] ], false, [ ], "PEPG Y-position scan", 1, 1.0, 20.0, false, false, true, true, "", "", " ", "", 0, null, null, "Positioner", false, true ]
+2 -2
View File
@@ -77,8 +77,8 @@ dx_averager.monitored = True # not blocking, will return last nb
#Record callback: uptate of output plot
def after_sample(record, scan):
global A, B, plt
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
x_pos_mean, x_pos_stdev = record[0].mean, record[0].stdev
x_width_mean, x_width_stdev = record[1].mean, record[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
phase = ((record.positions[0] + 90) % 360) - 90 if start < 0 else record.positions[0]
+32 -6
View File
@@ -7,17 +7,41 @@ if get_exec_pars().source == CommandSource.ui:
else:
las_offset_deg = args[0]
plt = args[1]
Laser = caget("SLG-LGEN:WHICH_LASER")
Bunch = caget("SLG-LGEN:WHICH_LASER")
B1las = caget("SIN-TIMAST-TMA:Bunch-1-Las-Sel")
B2las = caget("SIN-TIMAST-TMA:Bunch-2-Las-Sel")
cur_las_delay = 0.0
if Laser == "Alcor":
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
elif Laser == "Jaguar":
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
new_las_delay = cur_las_delay - 333.467 * las_offset_deg / 360.0
if Bunch == "Bunch 1":
if B1las == "Alcor":
Laser = "Alcor"
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
elif B1las == "Mizar":
Laser = "Mizar"
cur_las_delay = caget("SLGOS01-TSPL-MIZ:CURR_DELTA_T")
elif B1las == "Jaguar":
Laser = "Jaguar"
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
elif Bunch == "Bunch 2":
if B2las == "Alcor":
Laser = "Alcor"
cur_las_delay = caget("SLGOS01-TSPL-ALC:CURR_DELTA_T")
elif B2las == "Mizar":
Laser = "Mizar"
cur_las_delay = caget("SLGOS01-TSPL-MIZ:CURR_DELTA_T")
elif B2las == "Jaguar":
Laser = "Jaguar"
cur_las_delay = caget("SLGJG-TSPL-JAG:CURR_DELTA_T")
elif Laser == "Both":
Laser = None
cur_las_delay = None
new_las_delay = cur_las_delay - 333.467 * las_offset_deg / 360.0 # s-band: 1 / (142.8 MHz * 21) = 333.467 ps
if not dry_run:
if Laser == "Alcor":
caput("SLGOS01-TSPL-ALC:NEW_DELTA_T" , new_las_delay )
caput("SLGOS01-TSPL-ALC:SET_NEW_PHASE.PROC" , 1 )
elif Laser == "Mizar":
caput("SLGOS01-TSPL-MIZ:NEW_DELTA_T" , new_las_delay )
caput("SLGOS01-TSPL-MIZ:SET_NEW_PHASE.PROC" , 1 )
elif Laser == "Jaguar":
caput("SLGJG-TSPL-JAG:NEW_DELTA_T" , new_las_delay )
caput("SLGJG-TSPL-JAG:SET_NEW_PHASE.PROC" , 1 )
@@ -26,6 +50,8 @@ if do_elog:
log_msg = ""
if Laser == "Alcor":
log_msg = "SLGOS01-TSPL-ALC:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
elif Laser == "Mizar":
log_msg = "SLGOS01-TSPL-MIZ:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
elif Laser == "Jaguar":
log_msg = "SLGJG-TSPL-JAG:NEW_DELTA_T: %12.4f" % new_las_delay + " ps (was %12.4f" % cur_las_delay + " ps)\n"
attachments = []
@@ -1,41 +1,46 @@
E1 = 288.91 # old energy
E2 = 300.00 # new energy
E1 = 2428.0 # old energy gain
E2 = 2357.0 # new energy gain
do_elog = True
stationlist = ("SINSB03","SINSB04","SINXB01")
#stationlist = ("SINSB01","SINSB02","SINSB03","SINSB04","SINXB01")
#stationlist = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09")
#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04")
#stationlist = ("S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13")
stationlist = ("S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13")
# set RF on-delay
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
# energy calibration
A1, A2 = {}, {}
P1, P2 = {}, {}
new_acc_volt = {}
for station in stationlist:
A = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE") # MV/unit
P = caget(station + "-RSYS:SET-VOLT-POWER-SCALE") # MW/MV^2
vsum_ampl = caget(station + "-RSYS:GET-VSUM-AMPLT") # unit
A1[station] = A
A2[station] = A * E2 / E1
P1[station] = P
P2[station] = P * (E1 / E2)**2
# set RF on-delay
caput("SIN-TIMAST-TMA:Beam-RF-Delay-Sel",1)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1)
new_acc_volt[station] = vsum_ampl * A2[station]
for station in stationlist:
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", A2[station])
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", P2[station])
caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1)
caput(station + "-RSYS:SET-ACC-VOLT", new_acc_volt[station])
# set RF on-beam
caput("SIN-TIMAST-TMA:Beam-RF-Delay-Sel",0)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC",1)
caput("SIN-TIMAST-TMA:Beam-RF-OnDelay-Sel", 0)
caput("SIN-TIMAST-TMA:Beam-Apply-Cmd.PROC", 1)
#Elog entry
if do_elog:
title = "Energy calibration scaling"
log_msg = "Old energy: %0.2f" % E1 + " MeV/c\n"
log_msg = log_msg + "New energy: %0.2f" % E2 + " MeV/c\n\n"
log_msg = log_msg + " A1 A2 P1 P2 \n"
log_msg = "Old energy gain: %0.2f" % E1 + " MeV/c\n"
log_msg = log_msg + "New energy gain: %0.2f" % E2 + " MeV/c\n\n"
log_msg = log_msg + " A1 A2 P1 P2 \n"
for station in stationlist:
log_msg = log_msg + station + "%10.2f%10.2f%10.6f%10.6f" % (A1[station],A2[station],P1[station],P2[station]) + " \n"
attachments = None
elog(title, log_msg)
+1 -1
View File
@@ -61,7 +61,7 @@ q_averager.monitored=True
#Record callback: uptate of output plot
def after_sample(record, scan):
plt.getSeries(0).appendData((record.positions[0] + 90) % 360 - 90, record.values[1].mean, record.values[1].stdev)
plt.getSeries(0).appendData((record.positions[0] + 90) % 360 - 90, record.readables[1].mean, record.readables[1].stdev)
#The scan loop
try:
+1 -1
View File
@@ -66,7 +66,7 @@ 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)
arr_energy.append(A * rec.readables[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'))
+4 -3
View File
@@ -14,18 +14,19 @@ if (phase_set == 'True'):
caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", phase_offset)
n = n + 1
if (ampli_set == 'True'):
vsum_ampl = caget(station + "-RSYS:GET-VSUM-AMPLT")
amplitude_scale = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE-CALC")
amplitude_scale_old = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE")
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", amplitude_scale)
caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1)
new_acc_volt = vsum_ampl * amplitude_scale
caput(station + "-RSYS:SET-ACC-VOLT", new_acc_volt)
n = n + 1
if (power_set == 'True'):
power_scale = caget(station + "-RSYS:SET-VOLT-POWER-SCALE-CALC")
power_scale_old = caget(station + "-RSYS:SET-VOLT-POWER-SCALE")
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", power_scale)
caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1)
n = n + 1
if n > 0:
if n > 0:
if do_elog == True:
title = "Set RF calibration:" + station
log_msg = ""
+17
View File
@@ -0,0 +1,17 @@
dph = 34.0
stationlist0 = ("SINSB01","SINSB02","SINSB03","SINSB04","SINXB01")
stationlist1 = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09")
stationlist2 = ("S20CB01","S20CB02","S20CB03","S20CB04")
stationlist3 = ("S20CB01","S20CB02","S20CB03","S20CB04","S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13")
stationlist = stationlist1 + stationlist2 + stationlist3
Ph = {}
for station in stationlist:
ph0 = caget(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE") # deg
Ph[station] = ph0 - dph
for station in stationlist:
#caput(station + "-RSYS:SET-VSUM-PHASE-OFFSET-BASE", Ph[station])
print(Ph[station])
+20
View File
@@ -0,0 +1,20 @@
scan_range = 100.0
nb_steps = 21
stationlist = ("SINSB01","SINSB02","SINSB03","SINSB04","SINXB01")
#stationlist = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09")
#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04")
#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04","S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13")
P1, P2 = {}, {}
for station in stationlist:
Ph_Vsum = caget(station + "-RSYS:SET-VSUM-PHASE")
Ph_Beam = caget(station + "-RSYS:SET-BEAM-PHASE")
P1[station] = Ph_Vsum - scan_range / 2 + 90 - Ph_Beam
P2[station] = Ph_Vsum + scan_range / 2 + 90 - Ph_Beam
for station in stationlist:
caput(station + "-RSYS:SET-SCAN-START", P1[station])
caput(station + "-RSYS:SET-SCAN-STOP", P2[station])
caput(station + "-RSYS:SET-SCAN-STEP", scan_range / (nb_steps - 1))
-36
View File
@@ -1,36 +0,0 @@
E1 = 3493.0 # old energy
E2 = 3752.0 # new energy
do_elog = True
stationlist = ("S10CB01","S10CB02","S10CB03","S10CB04","S10CB05","S10CB06","S10CB07","S10CB08","S10CB09")
#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04")
#stationlist = ("S20CB01","S20CB02","S20CB03","S20CB04","S30CB01","S30CB02","S30CB03","S30CB04","S30CB05","S30CB06","S30CB07","S30CB08","S30CB09","S30CB10","S30CB11","S30CB12","S30CB13")
A1, A2 = {}, {}
P1, P2 = {}, {}
for station in stationlist:
A = caget(station + "-RSYS:SET-VSUM-AMPLT-SCALE") # MV/unit
P = caget(station + "-RSYS:SET-VOLT-POWER-SCALE") # MW/MV^2
A1[station] = A
A2[station] = A * E2 / E1
P1[station] = P
P2[station] = P * (E1 / E2)**2
for station in stationlist:
caput(station + "-RSYS:SET-VSUM-AMPLT-SCALE", A2[station])
caput(station + "-RSYS:SET-VOLT-POWER-SCALE", P2[station])
caput(station + "-RSYS:CMD-LOAD-CALIB-BEAM", 1)
#Elog entry
if do_elog:
title = "Energy calibration scaling"
log_msg = "Old energy: %0.2f" % E1 + " MeV/c\n"
log_msg = log_msg + "New energy: %0.2f" % E2 + " MeV/c\n\n"
log_msg = log_msg + " A1 A2 P1 P2 \n"
for station in stationlist:
log_msg = log_msg + station + "%10.2f%10.2f%10.6f%10.6f" % (A1[station],A2[station],P1[station],P2[station]) + " \n"
attachments = None
elog(title, log_msg)
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
time.sleep(1.0)
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -21,7 +21,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
+1 -1
View File
@@ -19,7 +19,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
#S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
+1 -1
View File
@@ -15,7 +15,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
+2 -2
View File
@@ -1,5 +1,5 @@
Eph1 = 11.65 # actual photon energy
Eph2 = 12.05 # desired photon energy
Eph1 = 9.8 # actual photon energy
Eph2 = 8.4 # desired photon energy
do_elog = True
+9 -25
View File
@@ -1,38 +1,22 @@
undlist = ("SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
### getting current photon energy:
Eph1 = caget(undlist[0] + "-UIND030:FELPHOTENE")
#Eph1 = 0.530 # actual photon energy in keV
print("Photon energy at start (at ", undlist[0],") : ", round(Eph1,4))
### give desired photon energy via relative or absolute method.
### please comment the other out!
### relative change in photon energy:
#step = -0.002 # desired step to scale in keV
#Eph2 = Eph1 + step
### absolute change in photon energy:
Eph2 = 0.540 # desired photon energy in keV
print("Photon energy at end: ", round(Eph2,4))
Eph1 = 1095.0 # actual photon energy. Don't forget .0 at the end!!
Eph2 = 350.0 # desired photon energy. Don't forget .0 at the end!!
do_elog = True
undlist = ("SATUN08","SATUN09","SATUN10","SATUN11","SATUN12","SATUN13","SATUN15","SATUN16","SATUN17","SATUN18","SATUN19","SATUN20","SATUN21","SATUN22")
### actual code:
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)
print(K2)
print K1,K2
for und in undlist: caput(und + "-UIND030:K_SET", K2[und])
### create Elog entry
#Elog entry
if do_elog:
title = "Athos wavelength change"
log_msg = "Old photon energy: %0.4f" % Eph1 + " kev\n"
log_msg = log_msg + "New photon energy: %0.4f" % Eph2 + " keV\n"
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)
+14 -11
View File
@@ -97,15 +97,17 @@ def switch_off_magnets(magnets = None):
def is_timing_ok():
return caget("SIN-TIMAST-TMA:SOS-COUNT-CHECK") == 0
def get_repetition_rate(bunch=1, setp=False):
#return caget("SIN-TIMAST-TMA:Evt-15-Freq-I")
if setp:
sel = caget("SIN-TIMAST-TMA:Bunch-" + str(bunch) + "-Freq-Sel")
return float(sel.split(" ")[0])
if bunch==2:
return caget("SIN-TIMAST-TMA:Bunch-2-Appl-Freq-RB", 'd')
else:
return caget("SIN-TIMAST-TMA:Bunch-1-Appl-Freq-RB", 'd')
def get_repetition_rate(bunch=1, setp=None):
if not setp:
if bunch==2:
ret = caget("SIN-TIMAST-TMA:Bunch-2-Appl-Freq-RB", 'd')
else:
ret = caget("SIN-TIMAST-TMA:Bunch-1-Appl-Freq-RB", 'd')
if setp==False or ret > 0:
return ret
print "Readback is 0: returning Setpoint"
sel = caget("SIN-TIMAST-TMA:Bunch-" + str(bunch) + "-Freq-Sel")
return float(sel.split(" ")[0])
def ws_status():
"""
@@ -500,9 +502,10 @@ if get_context().isServerEnabled():
import ch.psi.pshell.epics.CAS as CAS
#CAS.setServerPort(5062)
class ServerUrl(ReadonlyRegisterBase):
class ServerUrl(RegisterBase):
def doRead(self):
return get_context().server.baseURL
return get_context().server.baseURL
d = ServerUrl()
d.initialize()
+2
View File
@@ -0,0 +1,2 @@
print('Hello World')
elog('Test entry', 'This is a test for pshell print')
+1 -1
View File
@@ -64,7 +64,7 @@ q_averager.monitored=True
#Record callback: uptate of output plot
def after_sample(record, scan):
plt.getSeries(0).appendData((record.positions[0] + 90) % 360 - 90, record.values[1].mean, record.values[1].stdev)
plt.getSeries(0).appendData((record.positions[0] + 90) % 360 - 90, record.readables[1].mean, record.readables[1].stdev)
#The scan loop
try:
+1 -1
View File
@@ -64,7 +64,7 @@ q_averager.monitored=True
#Record callback: uptate of output plot
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[1].mean, record.values[1].stdev)
plt.getSeries(0).appendData(record.positions[0], record.readables[1].mean, record.readables[1].stdev)
#The scan loop
try:
+1 -1
View File
@@ -26,7 +26,7 @@ if prefix not in get_wire_scans():
scanner = WireScanner(prefix, sel, start, end, cycles, velocity, True)
#Stream channels
bs_position = scanner.motor_bs_readback.get_name()
bs_position = scanner.motor_bs_readback.getName()
bpms = get_wire_scans_bpms(prefix)
if bpms is None:
raise Exception("Cannot determine wire scan bpms: " + prefix)
+3 -3
View File
@@ -29,9 +29,9 @@ if prefix not in get_wire_scanners():
scanner = WireScanner(prefix, scan_range, cycles, velocity, True)
#List of stream channels
channels = [("m_pos", scanner.motor_bs_readback.get_name()),
("cur_cycle", scanner.curr_cycl.get_name()),
("scanning", scanner.status_channels[0].get_name())]
channels = [("m_pos", scanner.motor_bs_readback.getName()),
("cur_cycle", scanner.curr_cycl.getName()),
("scanning", scanner.status_channels[0].getName())]
for i in range (len(blms)):
channels.append (("blm" + str(i+1), blms[i] + ":B1_LOSS"))
for i in range (len(bpms)):
+1 -1
View File
@@ -16,7 +16,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)
+1 -1
View File
@@ -14,7 +14,7 @@ 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)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
time.sleep(1.0)
+2 -2
View File
@@ -22,8 +22,8 @@ plt.setStyle(plt.Style.ErrorY)
plt.addSeries(LinePlotErrorSeries("Sensor1", Color.red))
plt.addSeries(LinePlotErrorSeries("Sensor2", Color.blue))
def after_sample(record, scan):
plt.getSeries(0).appendData(record.positions[0], record.values[0].mean, record.values[0].stdev)
plt.getSeries(1).appendData(record.positions[0], record.values[1].mean, record.values[1].stdev)
plt.getSeries(0).appendData(record.positions[0], record.readables[0].mean, record.readables[0].stdev)
plt.getSeries(1).appendData(record.positions[0], record.readables[1].mean, record.readables[1].stdev)
try:
S1_averager = create_averager(S1, nav, lat)
S2_averager = create_averager(S2, nav, lat)