This commit is contained in:
gac-bernina
2024-02-19 16:44:57 +01:00
parent a0fb826e6f
commit 3edd5ecda9
50 changed files with 1166 additions and 89 deletions
+12 -9
View File
@@ -2,7 +2,7 @@ import math
import sys, traceback
from mathutils import fit_polynomial, PolynomialFunction
from plotutils import plot_line, plot_function
from ch.psi.pshell.swing.Shell import STDOUT_COLOR
from ch.psi.pshell.swing.Shell import getColorStdout
import org.apache.commons.math3.stat.correlation.PearsonsCorrelation as PearsonsCorrelation
import ch.psi.pshell.bs.PipelineServer as PipelineServer
@@ -13,15 +13,17 @@ TYPE_CAMERA= 2
if get_exec_pars().source == CommandSource.ui:
dx = "SINDI01-RLLE-STA:SLAVE1-CPUTIMER"
dx="SARFE10-PBPS053:INTENSITY"
#dx = "SLG-LCAM-C042 x_rms"
dxtype = TYPE_STREAM
dxtype = TYPE_CHANNEL
#dxtype = TYPE_CHANNEL
#dxtype = TYPE_CAMERA
#dy = "SINDI01-RLLE-STA:SLAVE1-DLTIMER"
dy = "SLG-LCAM-C042 y_rms"
dy = "SINDI01-RLLE-STA:SLAVE1-DLTIMER"
#dy = "SLG-LCAM-C042 y_rms"
dy="SARFE10-PBPS053:INTENSITY"
dytype = TYPE_STREAM
dytype = TYPE_CHANNEL
dytype = TYPE_CAMERA
#dytype = TYPE_CHANNEL
#dytype = TYPE_CAMERA
interval = 0.10
window = 40
p = plot(None)[0]
@@ -115,7 +117,7 @@ try:
_stream.initialize()
_stream.start(True)
if _camname != None:
shared = _camname.endswith("_sp1")
shared = _camname.endswith("_sp")
print "Camera: " , _camname, " shared: ", shared
cam_server.start(_camname, shared )
cam_server.stream.waitCacheChange(10000);
@@ -140,7 +142,8 @@ try:
#Sample and plot data
if bs == True:
_stream.waitValueNot(_stream.take(), 10000)
bsdata = list(_stream.take().values)
bsdata = list(_stream.take().values())
#print bsdata
if dxtype==TYPE_CHANNEL:
x=dx.read()
@@ -174,7 +177,7 @@ try:
if marker is not None:
p.removeMarker(marker)
marker = p.addMarker(x2+res, p.AxisId.X, s, p.getBackground())
marker.setLabelPaint(STDOUT_COLOR)
marker.setLabelPaint(getColorStdout())
if linear_fit:
#Calculate, print and plot linear fit
pars_lin = (a0,a1) = fit_polynomial(ay, ax, 1)
@@ -3,7 +3,7 @@ import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SARES20-PROF141-M1"
CHANNEL = "intensity"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
@@ -3,7 +3,7 @@ import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SAROP21-PPRM138"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
@@ -20,7 +20,7 @@ bins = 100
panels = OrderedDict()
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
@@ -22,7 +22,7 @@ panels = OrderedDict()
CAMERA_NAME='SAROP21-PPRM138'
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
@@ -3,7 +3,7 @@ import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SAROP21-PPRM102"
#CAMERA_NAME = "SAROP21-PPRM138"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
+1 -1
View File
@@ -3,7 +3,7 @@ import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SARES20-PROF142-M1"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
Executable → Regular
+3 -1
View File
@@ -8,7 +8,9 @@ from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator, Gaussian
from plotutils import plot_function, plot_data
import java.awt.Color as Color
run("psss/psss")
#run("psss/psss")
run ("pointing/local")
###################################################################################################
# DRY RUN
+5
View File
@@ -0,0 +1,5 @@
st.waitCacheChange(5000)
val=st.take()
fit_pos = val["x_fit_mean"], val["y_fit_mean"]
offset = fit_pos[0] - marker_pos[0], fit_pos[1] - marker_pos[1]
set_return(offset)
+18
View File
@@ -0,0 +1,18 @@
BEAMLINE_NAME = "Bernina"
CAMERA_NAME = "SAROP21-PPRM094"
APERTURE_SLOPE_W_MIN = 0.2
APERTURE_SLOPE_H_MIN = 0.2
APERTURE_OFFSET_W_MIN = 0.2
APERTURE_OFFSET_H_MIN = 0.2
APERTURE_SLOPE_W_DEFAULT = 5.0
APERTURE_SLOPE_H_DEFAULT = 5.0
APERTURE_OFFSET_W_DEFAULT = 5.0
APERTURE_OFFSET_H_DEFAULT = 5.0
ATENUATOR_CAL = 0.01
ATENUATOR_DEFAULT = 0.05
+3
View File
@@ -0,0 +1,3 @@
attenuator.write(ATENUATOR_DEFAULT)
st.close()
+14
View File
@@ -0,0 +1,14 @@
run("pointing/config")
def check():
if beamline_name.read() != BEAMLINE_NAME:
raise "Invalid beamline mode"
camera_screen.setSettlingCondition(ChannelSettlingCondition("SAROP21-PPRM094:IN_POS", 1, None, 'i'))
def get_saturated_pixels(img):
img = flatten(img)
return sum([1 if v>=4095 else 0 for v in img])
+63
View File
@@ -0,0 +1,63 @@
#check()
run("pointing/start")
#Close aperture offset
aperture_offset_width.move(APERTURE_OFFSET_W_MIN)
aperture_offset_height.move(APERTURE_OFFSET_H_MIN)
#Move marker to the fit position
val=st.take()
fit_pos = val["x_fit_mean"], val["y_fit_mean"]
x_axis, y_axis = val["x_axis"], val["y_axis"]
fit_pos_px_x = int(fit_pos[0] / cam_server.config.spatialCalScaleX - cam_server.config.spatialCalOffsetX)
fit_pos_px_y = int(fit_pos[1] / cam_server.config.spatialCalScaleY - cam_server.config.spatialCalOffsetY)
fit_pos_px = [fit_pos_px_x, fit_pos_px_y]
print fit_pos_px
#marker_pos_px = cam_server.getInstanceConfigValue("Marker")
#marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX
#marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY
#marker_pos = [marker_pos_x, marker_pos_y]
#print marker_pos_px
cam_server.setInstanceConfigValue("Marker", fit_pos_px)
marker_pos_px = fit_pos_px
#Open aperture offset
aperture_offset_width.move(APERTURE_OFFSET_W_DEFAULT)
aperture_offset_height.move(APERTURE_OFFSET_H_DEFAULT)
time.sleep(0.5)
st.waitCacheChange(5000)
val=st.take()
fit_pos = val["x_fit_mean"], val["y_fit_mean"]
marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX
marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY
marker_pos = [marker_pos_x, marker_pos_y]
offset = fit_pos[0] - marker_pos[0], fit_pos[1] - marker_pos[1]
print offset
#1/0
#camera_screen.move("Free")
#aperture_slope_width.move(APERTURE_SLOPE_W_MIN)
#aperture_slope_height.move(APERTURE_SLOPE_H_MIN)
run("pointing/end")
+40
View File
@@ -0,0 +1,40 @@
try:
#Close aperture offset
aperture_offset_width.moveAsync(APERTURE_OFFSET_W_MIN)
aperture_offset_height.move(APERTURE_OFFSET_H_MIN)
aperture_offset_width.waitReady(-1)
#Move marker to the fit position
val=st.take()
fit_pos = val["x_fit_mean"], val["y_fit_mean"]
x_axis, y_axis = val["x_axis"], val["y_axis"]
fit_pos_px_x = int(fit_pos[0] / cam_server.config.spatialCalScaleX - cam_server.config.spatialCalOffsetX)
fit_pos_px_y = int(fit_pos[1] / cam_server.config.spatialCalScaleY - cam_server.config.spatialCalOffsetY)
fit_pos_px = [fit_pos_px_x, fit_pos_px_y]
print fit_pos_px
#marker_pos_px = cam_server.getInstanceConfigValue("Marker")
#marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX
#marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY
#marker_pos = [marker_pos_x, marker_pos_y]
#print marker_pos_px
cam_server.setInstanceConfigValue("Marker", fit_pos_px)
marker_pos_px = fit_pos_px
marker_pos_x = (marker_pos_px[0] + cam_server.config.spatialCalOffsetX) * cam_server.config.spatialCalScaleX
marker_pos_y = (marker_pos_px[1] + cam_server.config.spatialCalOffsetY) * cam_server.config.spatialCalScaleY
marker_pos = [marker_pos_x, marker_pos_y]
finally:
#Open aperture offset
aperture_offset_width.moveAsync(APERTURE_OFFSET_W_DEFAULT)
aperture_offset_height.move(APERTURE_OFFSET_H_DEFAULT)
aperture_offset_width.waitReady(-1)
time.sleep(0.5)
+17
View File
@@ -0,0 +1,17 @@
aperture_offset_width = aperture_slope_width #TODO: REMOVE
aperture_offset_height = aperture_slope_height
camera_screen.move("Wafer 100um")
time.sleep(0.2)
camera_screen.getSettlingCondition().waitSettled() #ecj
cam_server.start(CAMERA_NAME + '_sp', True)
cam_server.averaging=10
st = cam_server.stream
print('Started camera')
#Fix this with a specific pipeline
time.sleep(0.5)
st.waitCacheChange(5000)
#show_panel(cam_server)
add_device(st, True)
attenuator.write(ATENUATOR_CAL)
Executable → Regular
+1 -1
View File
@@ -159,7 +159,7 @@ def enable_psss_image(enabled, renderer):
cam_server.config.colormap=Colormap.Temperature
cam_server.start(PSSS_CAMERA_NAME + "_sp", PSSS_CAMERA_NAME + "_sp1")
cam_server.start(PSSS_CAMERA_NAME + "_sp", True)
#ovmin, ovmax= Overlays.Crosshairs(renderer.getPenMarker(), Dimension(-1,1)), \
# Overlays.Crosshairs(renderer.getPenMarker(), Dimension(-1,1))
ovmin, ovmax= Overlays.Line(renderer.getPenMarker()), Overlays.Line(renderer.getPenMarker())
+28
View File
@@ -0,0 +1,28 @@
CAMERA = "SARES20-CAMS142-M3"
CAMERA = "SARFE10-PSSS059"
CAMERA = "SATBD02-DSCR050"
CAMERA = "SATES31-CAMS187-RIXS1"
CAMERA = "SAROP21-PPRM138"
CAMERA = "SARES20-PROF142-M1"
#CAMERA = "SARES20-CAMS142-M5"
CAMERA = "SLAAR02-LPMO01-C321"
CAMERA = "SLAAR02-LPMO02-C322"
CAMERA = "SLAAR21-LCAM-CS841"
CAMERA = "SLAAR21-LCAM-CS842"
CAMERA = "SARES20-CAMS142-C2"
CAMERA_URL = caget(CAMERA + ":BSREADCONFIG").replace("tcp://daq", "tcp://")
#CAMERA_URL= "tcp://sf-sioc-cs-83:9020"
#CAMERA_URL= "tcp://sf-sioc-cs-64:9000"
CAMERA_URL = "tcp://sf-daqsync-02:31852"
print CAMERA_URL
st1 = Stream("st1", CAMERA_URL, SocketType.PULL)
st1.initialize()
st1.start()
st1.waitCacheChange(3000)
try:
#r=bscan (st1, records=5, timeout=10.0, save=False, enabled_plots=[st1,])
#v= st1.getValues()
show_panel(st1)
finally:
st1.close()
Executable → Regular
+1 -1
View File
@@ -3,7 +3,7 @@ import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
CAMERA_NAME = "SARES20-PROF141-M1"
CHANNEL = "intensity"
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
dev = cam_server.stream.getChild(CHANNEL)
add_device(dev, True) #To see it in Device panel
Executable → Regular
+1 -1
View File
@@ -8,7 +8,7 @@ range_min, range_max = float('nan'),float('nan')
bins = 100
for camera_name in CAMERA_NAMES:
cam_server.start(camera_name + "_sp", camera_name + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(camera_name + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
Executable → Regular
+1 -1
View File
@@ -25,7 +25,7 @@ bins = 100
panels = OrderedDict()
for camera_name in CAMERA_NAMES:
cam_server.start(camera_name + "_sp", camera_name + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(camera_name + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
Executable → Regular
+1 -1
View File
@@ -24,7 +24,7 @@ bins = 100
panels = OrderedDict()
cam_server.start(CAMERA_NAME + "_sp", CAMERA_NAME + "_sp1") #Start or connect to ScreenPanel pipeline
cam_server.start(CAMERA_NAME + "_sp", True) #Start or connect to ScreenPanel pipeline
cam_server.stream.waitCacheChange(2000)
for channel in CHANNELS:
+5
View File
@@ -0,0 +1,5 @@
s1 = Stream("s1", dispatcher)
s1.addScalar("SARFE10-PSSS059:SPECTRUM_Y_SUM", "SARFE10-PSSS059:SPECTRUM_Y_SUM", 1, 0)
s1.addScalar("SARFE10-PBPS053:INTENSITY" , "SARFE10-PBPS053:INTENSITY", 1, 0)
s1.initialize()
bscan(s1, 10, 3.0)
Regular → Executable
View File
+1 -1
View File
@@ -1,6 +1,6 @@
import ch.psi.pshell.device.HistogramGenerator as HistogramGenerator
cam_server.start("SARES20-PROF141-M1_sp", "SARES20-PROF141-M1_sp1")
cam_server.start("SARES20-PROF141-M1_sp", True)
channels = ["intensity",
"x_center_of_mass",
+136
View File
@@ -0,0 +1,136 @@
"""
Run as:
pshell_be -l -test -c -f="users/roman/correlation_bs.py" -args="CHS:['SAROP21-PBPS103:INTENSITY', 'SAROP21-PBPS133:INTENSITY']"
or with additional parameters:
pshell_be -l -test -c -f="users/roman/correlation_bs.py" -args="CHS:['SAROP21-PBPS103:INTENSITY', 'SAROP21-PBPS133:INTENSITY'],VERBOSE:False,TIME_INTERVAL:2.0"
"""
if not "VERBOSE" in globals():
VERBOSE = False
if not "TIME_INTERVAL" in globals():
TIME_INTERVAL = 1.0
EMPTY_VALUE = 1112223330
channel_list = CHS
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()