Tilt scan

This commit is contained in:
gac-x11ma
2021-04-27 10:47:50 +02:00
parent 3ba3997b5e
commit 5225f36124
27 changed files with 267 additions and 40 deletions

View File

@@ -1,11 +1,11 @@
#Wed Mar 17 11:12:32 CET 2021
#Wed Apr 14 15:11:25 CEST 2021
environment=prod
testParameters=-testenv -user slssim\:4DMGBarXmr
sourceFolder=/sls/X11MA/Data1/e18976
sourceFolder=/sls/X11MA/Data1/e19148
prodParameters=\ -user slssim\:4DMGBarXmr
devParameters=-devenv -user slssim\:slssim
ownerGroup=
type=raw
parameters=-ingest -allowexistingsource -noninteractive -autoarchive
creationLocation=/PSI/SLS/SIM
principalInvestigator=guillaume.nataf@univ-tours.fr
principalInvestigator=arik.beck@psi.ch

View File

@@ -1,5 +1,5 @@
#Sat Mar 27 13:46:51 CET 2021
#Mon Apr 26 10:07:44 CEST 2021
keywords=List;[]
ownerEmail=String;arik.beck@psi.ch
contactEmail=String;armin.kleibert@psi.ch
owner=String;Arik Beck
ownerEmail=String;moritz.bigalke@giub.unibe.ch
contactEmail=String;carlos.vaz@psi.ch
owner=String;Erik Folven

View File

@@ -1,3 +1,2 @@
#Sat Mar 27 14:37:36 CET 2021
SessionCounter=14
CurrentSession=14
#Tue Apr 27 09:06:10 CEST 2021
SessionCounter=19

View File

@@ -1,16 +1,16 @@
#Mon Apr 12 14:15:30 CEST 2021
#Tue Apr 27 09:07:34 CEST 2021
HARMONIC_ID_1=1
RSYNC_USER=
OUTLIERS_THRESHOLD=1000000000
NORM_FILE=/sls/X11MA/data/X11MA/Data1/2021/Yona250121/s250121
AUTO_SWITCH_VALVE=true
AUTO_SWITCH_VALVE=false
DRY_RUN=false
POL_ID_2=Lin_Hor
OFFSET_ID_1=0.0
ID=ID2
OFFSET_ID_2=-1.1
proposal=proposal
ENERGY=707.8
ENERGY=800.0
proposer=proposer
POL_ID_1=Lin_Hor
RSYNC_HOST=

View File

@@ -1,4 +1,4 @@
#Mon Apr 12 14:26:20 CEST 2021
LastRunDate=210412
FileSequentialNumber=6615
DaySequentialNumber=8
#Tue Apr 27 10:43:38 CEST 2021
LastRunDate=210427
FileSequentialNumber=7047
DaySequentialNumber=5

View File

@@ -1,4 +1,4 @@
#Thu Apr 01 10:39:51 CEST 2021
#Mon Apr 26 13:48:18 CEST 2021
spatialCalOffsetY=NaN
spatialCalOffsetX=NaN
colormapLogarithmic=false
@@ -6,7 +6,7 @@ scale=1.0
grayscale=false
spatialCalScaleX=NaN
spatialCalScaleY=NaN
colormapMax=100.0
colormapMax=900.0
rescaleOffset=0.0
roiWidth=-1
colormap=Grayscale
@@ -19,7 +19,7 @@ spatialCalUnits=null
flipVertically=false
roiHeight=-1
flipHorizontally=false
colormapAutomatic=true
colormapAutomatic=false
roiY=0
roiX=0
transpose=false

0
script/Users/steven/March2021_Holder1-FINAL.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder1.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder2.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder3.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder4.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder5.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder6.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder7.py Normal file → Executable file
View File

0
script/Users/steven/March2021_Holder8.py Normal file → Executable file
View File

View File

@@ -9,6 +9,9 @@ class LEEM2000(TcpDevice):
self._names = None
self.high_voltage = Channel("X11MA-ES1-PEEM:UMON", alias = "PEEM high voltage", monitored=True)
self.debug = False
self.retries = 1
self.timeout = 1000
self.move_timeout = 30000
def doInitialize(self):
super(LEEM2000, self).doInitialize()
@@ -26,12 +29,16 @@ class LEEM2000(TcpDevice):
value = "%1.3f | %s" % (hv,pl) if hv!="" or pl!="" else None
self.setCache(value, None)
def send_receive(self, tx, timeout = 1000, retries = 1):
def send_receive(self, tx, timeout = None, retries = None):
if retries is None:
retries = self.retries
if timeout is None:
timeout = self.timeout
trailer = chr(0)
ret = self.sendReceive(tx+trailer, None,trailer, 0, 1000, 1)
ret = self.sendReceive(tx+trailer, None,trailer, 0, timeout, retries)
return str(ret[0:-1]).strip()
def get_value(self, name, timeout = 1000, retries = 1):
def get_value(self, name, timeout = None, retries = None):
cmd = "get " + name
ret = self.send_receive(cmd, timeout, retries)
try:
@@ -42,17 +49,17 @@ class LEEM2000(TcpDevice):
self.getLogger().info("Received invalid value for %s: %s" % (name, ret))
return None
def set_value(self, name, value, timeout = 1000, retries = 1):
def set_value(self, name, value, timeout = None, retries = None):
cmd = "set " + name + "=" + str(value)
ret = self.send_receive(cmd, timeout, retries)
if ret != '0':
raise Exception("Error writing %s to %s: %s" % (str(value), name, ret))
def get_mnemonic(self, index, timeout = 1000, retries = 1):
def get_mnemonic(self, index, timeout = None, retries = None):
cmd = "mne " + str(index)
return self.send_receive(cmd, timeout, retries)
def _get_mnemonics(self, timeout = 1000, retries = 1):
def _get_mnemonics(self, timeout = None, retries = None):
ret = []
for i in range(self.NUMBER_MNEMONICS):
mne = self.get_mnemonic(i, timeout, retries)
@@ -60,26 +67,26 @@ class LEEM2000(TcpDevice):
ret.append(mne)
return ret
def get_mnemonics(self, timeout = 1000, retries = 1):
def get_mnemonics(self, timeout = None, retries = None):
if self._mnemonics is None:
try:
self._mnemonics = self._get_mnemonics(timeout = 1000, retries = 1)
self._mnemonics = self._get_mnemonics(timeout, retries)
except:
self.getLogger().warning("Error retrieving microscope mnemonics")
return []
return self._mnemonics
def get_mnemonic_values(self, timeout = 1000, retries = 1):
def get_mnemonic_values(self, timeout = None, retries = None):
ret = {}
for mnemonic in self.get_mnemonics(timeout, retries):
ret[mnemonic] = self.get_value(mnemonic, timeout, retries)
return ret
def get_name(self, index, timeout = 1000, retries = 1):
def get_name(self, index, timeout = None, retries = None):
cmd = "nam " + str(index)
return self.send_receive(cmd, timeout, retries)
def _get_names(self, timeout = 1000, retries = 1):
def _get_names(self, timeout = None, retries = None):
ret = []
for i in range(self.NUMBER_MNEMONICS):
mne = self.get_name(i, timeout, retries)
@@ -87,26 +94,26 @@ class LEEM2000(TcpDevice):
ret.append(mne)
return ret
def get_names(self, timeout = 1000, retries = 1):
def get_names(self, timeout = None, retries = None):
if self._names is None:
try:
self._names = self._get_names(timeout = 1000, retries = 1)
self._names = self._get_names(timeout = timeout, retries = retries)
except:
self.getLogger().warning("Error retrieving microscope mnemonics")
return []
return self._names
def get_values(self, timeout=1000, retries=1):
def get_values(self, timeout=None, retries=None):
ret = {}
for name in self.get_names():
ret[name] = self.get_value(name, timeout, retries)
return ret
def get_preset_label(self, timeout=1000, retries=1):
def get_preset_label(self, timeout=None, retries=None):
cmd = "prl"
return self.send_receive(cmd, timeout, retries)
def get_high_voltage(self):
def get_high_voltage(c):
return self.high_voltage.get(False)
def get_child(self, var, name=None):
@@ -116,6 +123,57 @@ class LEEM2000(TcpDevice):
ret.initialize()
return ret
def get_motor(self, motor_id, name=None):
if name is None:
name=str(motor_id)
ret = LEEM2000Motor(name, motor_id, self)
ret.initialize()
return ret
def get_tilt(self, motor_id_pos, motor_id_neg, name=None):
if name is None:
name=str(motor_id_pos) + "_" + str(motor_id_neg)
ret = LEEM2000Tilt(name, motor_id_pos, motor_id_neg, self)
ret.initialize()
return ret
#motor_id = U, D, L or R
def move_tilt(self, motor_id, dist_us, timeout = None, retries = None):
if timeout is None:
timeout = self.move_timeout
cmd = "tlt " + str(motor_id) + " " + str(dist_us)
ret = self.send_receive(cmd, timeout, retries)
if ret != '0':
raise Exception("Error moving tilt %s to %s: %s" % (str(cmd), dist_us, ret))
#motor_id = 11 (X) or 10(Y)
def move_motor_rel_async(self, motor_id, dist_us, timeout = None, retries = None):
cmd = "mmd " + str(motor_id) + " " + str(dist_us)
ret = self.send_receive(cmd, timeout, retries)
if ret != '0':
raise Exception("Error relative moving motor %s to %s: %s" % (str(motor_id), dist_us, ret))
def stop_motor(self, motor_id, timeout = None, retries = None):
self.move_motor_rel_async( motor_id, 0.0, timeout = None, retries = None)
def is_motor_moving(self, motor_id, timeout = None, retries = None):
cmd = "mmd " + str(motor_id) + " 888888.0"
if ret == '0':
return False
if ret == '1':
return True
raise Exception("Error reading motor %s state: %s" % (str(motor_id), ret))
#motor_id = 11 (X) or 10(Y)
def move_motor(self, motor_id, pos_us, timeout = None, retries = None):
if timeout is None:
timeout = self.move_timeout
cmd = "mmp " + str(motor_id) + " " + str(pos_us)
ret = self.send_receive(cmd, timeout, retries)
if ret != '0':
raise Exception("Error moving motor %s to %s: %s" % (str(motor_id), pos_us, ret))
class LEEM2000Child(RegisterBase):
def __init__(self,name, var, microscope):
RegisterBase.__init__(self,name)
@@ -129,9 +187,81 @@ class LEEM2000Child(RegisterBase):
self.microscope.set_value(self.var, val)
class LEEM2000Motor(RegisterBase):
def __init__(self,name, motor_id, microscope):
RegisterBase.__init__(self,name)
self.motor_id = motor_id
self.microscope = microscope
self.pos = None
def doRead(self):
return self.pos
def doWrite(self, val):
self.microscope.move_motor(self.motor_id, val)
self.pos = val
class LEEM2000Tilt(RegisterBase):
def __init__(self,name, motor_id_pos, motor_id_neg, microscope):
RegisterBase.__init__(self,name)
self.motor_id_pos = motor_id_pos
self.motor_id_neg = motor_id_neg
self.microscope = microscope
self.pos = None
def doRead(self):
return self.pos
def doWrite(self, val):
if (val>0):
print "SET TILT ", self.motor_id_pos, " -> ", val
self.microscope.move_tilt(self.motor_id_pos, val)
elif (val<0):
print "SET TILT ", self.motor_id_neg, " -> ", -val
self.microscope.move_tilt(self.motor_id_neg, -val)
self.pos = val
add_device (LEEM2000("microscope"), True)
add_device (microscope.get_motor(11,"manip_x"), True)
add_device (microscope.get_motor(10,"manip_y"), True)
add_device (microscope.get_tilt('L','R', "tilt_h"), True)
add_device (microscope.get_tilt('D','U', "tilt_v"), True)
add_device (microscope.get_child("MOBJ","objective"), True)
add_device (microscope.get_child("OSTIGA","obj_stig_a"), True)
add_device (microscope.get_child("OSTIGB","obj_stig_b"), True)
microscope.setPolling(5000)
class TiltMotor(RegisterBase):
def __init__(self, name, tilt_motor):
RegisterBase.__init__(self, name)
self.position = 0
self.tilt_motor = tilt_motor
def doInitialize(self):
self.position = 0
def doRead(self):
return self.position
def doWrite(self, pos):
if abs(pos)>8000:
raise Exception("Exceeded device range")
offset = pos -self.position
self.tilt_motor.write(offset)
self.position = pos
def init_tilt():
tilt_vertical.initialize()
tilt_horizontal.initialize()
add_device(TiltMotor("tilt_vertical", tilt_v), True)
add_device(TiltMotor("tilt_horizontal", tilt_h), True)
tilt_vertical.polling=500
tilt_horizontal.polling=500

View File

@@ -40,8 +40,8 @@ diag_channels_names = { \
"PEEM leakage current": "X11MA-ES1-PEEM:IMON", \
"Pressure in PEEM": "X11MA-ES1-MAIN:PRESSURE", \
"Pressure in Column": "X11MA-ES1-COLU:PRESSURE", \
"Sample temperature": "X11MA-ES1-SW:Pt100-K", \
"Pt100 resistance": "X11MA-ES1-SW:Pt100-R", \
"Sample temperature": "X11MA-PC-SW:Pt100-K", \
"Pt100 resistance": "X11MA-PC-SW:Pt100-R", \
}
eiger_diag_channels_names = { \

View File

@@ -4,6 +4,10 @@
import ntpath
import traceback
from rsync import *
from mathutils import estimate_peak_indexes, fit_gaussians, create_fit_point_list, Gaussian
from mathutils import fit_polynomial,fit_gaussian, fit_harmonic, calculate_peaks
from mathutils import PolynomialFunction, Gaussian, HarmonicOscillator
ProviderCSV.setDefaultItemSeparator(", ")
get_context().dataManager.createLogs=False
@@ -603,7 +607,48 @@ def restore_beamline_setup():
OFFSET_ID_2 = float(get_setting("OFFSET_ID_2"))
apply_beamline_setup(ID,ENERGY,POL_ID_1,ALPHA_ID_1,HARMONIC_ID_1,OFFSET_ID_1,POL_ID_2,ALPHA_ID_2,HARMONIC_ID_2,OFFSET_ID_2)
###################################################################################################
#Maths
###################################################################################################
def fit(ydata, xdata = None):
"""
Gaussian fit
"""
if xdata is None:
xdata = frange(0, len(ydata), 1)
#ydata = to_list(ydata)
#xdata = to_list(xdata)
max_y= max(ydata)
index_max = ydata.index(max_y)
max_x= xdata[index_max]
print "Max index:" + str(index_max),
print " x:" + str(max_x),
print " y:" + str(max_y)
gaussians = fit_gaussians(ydata, xdata, [index_max,])
(norm, mean, sigma) = gaussians[0]
p = plot([ydata],["data"],[xdata], title="Fit" )[0]
fitted_gaussian_function = Gaussian(norm, mean, sigma)
scale_x = [float(min(xdata)), float(max(xdata)) ]
points = max((len(xdata)+1), 100)
resolution = (scale_x[1]-scale_x[0]) / points
fit_y = []
fit_x = frange(scale_x[0],scale_x[1],resolution, True)
for x in fit_x:
fit_y.append(fitted_gaussian_function.value(x))
p.addSeries(LinePlotSeries("fit"))
p.getSeries(1).setData(fit_x, fit_y)
if abs(mean - xdata[index_max]) < ((scale_x[0] + scale_x[1])/2):
print "Mean -> " + str(mean)
p.addMarker(mean, None, "Mean="+str(round(norm,2)), Color.MAGENTA.darker())
return (norm, mean, sigma)
else:
p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY)
print "Invalid gaussian fit: " + str(mean)
return (None, None, None)
###################################################################################################
#Settings
###################################################################################################

0
script/templates/EnergyScan_img.py Normal file → Executable file
View File

0
script/templates/EnergyScan_v2.py Normal file → Executable file
View File

View File

@@ -0,0 +1,23 @@
CENTER = [400.0, 600.0]
RANGE = 400
STEP = 200.0
SETTLING_TIME = 1.0
RANGE_H = [CENTER[0]-RANGE, CENTER[0]+RANGE]
RANGE_V = [CENTER[1]-RANGE, CENTER[1]+RANGE]
STEP_H = STEP
STEP_V = STEP
INIT_TILT = True # True - tilt must be manually set to 0,0 before the scan
# False - tilt set 0.0 al leasts once at PShell startut
if INIT_TILT:
init_tilt()
try:
ascan ( [tilt_horizontal, tilt_vertical], machine_cur, \
[RANGE_H[0], RANGE_V[0]], [RANGE_H[1], RANGE_V[1]], [float(STEP_H), float(STEP_V)], \
latency=SETTLING_TIME, zigzag=True, save=True)
finally:
if INIT_TILT:
tilt_horizontal.write(0.0)
tilt_vertical.write(0.0)

View File

@@ -35,7 +35,7 @@ for t in range(T_min, T_max, T_step):
f.write("Time\t\t Temp. RBV [K]\t Temp. SP [K]\t Filament Volt. [mA]\r\n")
caput('X11MA-PC-LEEM:PID-MainSwitch', 'On')
for n in range(360): #180*10(wait time)=1800s=30min
Tmp=caget("X11MA-ES1-SW:Pt100-K")
Tmp=caget("X11MA-PC-SW:Pt100-K")
Fil=caget("X11MA-PC-LEEM:FIL_SP")
Tim=time.strftime('%H:%M:%S',time.localtime())
f.write(Tim + "\t " + str(Tmp) + "\t" + str(t) + "\t\t" + str(Fil) + "\t" + "\r\n")

View File

@@ -0,0 +1,20 @@
#ascan ([manip_x,manip_y],machine_cur, [-950,900], [-960,910], [5.0,5.0], latency=1.0,zigzag=True, save=False)
RANGE_V = [-2000, 2000]
RANGE_H = [-2000, 2000]
STEP_V = 500.0
STEP_H = 500.0
SETTLING_TIME = 1.0
#We start at 0,0 absolute position
tilt_vertical.initialize()
tilt_horizontal.initialize()
try:
ascan ( [tilt_horizontal, tilt_vertical], machine_cur, \
[RANGE_H[0], RANGE_V[0]], [RANGE_H[1], RANGE_V[1]], [float(STEP_H), float(STEP_V)], \
latency=SETTLING_TIME,zigzag=True, save=True)
finally:
tilt_vertical.write(0)
tilt_horizontal.write(0)

0
script/test/TestOTF2.py Normal file → Executable file
View File

10
script/test/test_autofocus.py Executable file
View File

@@ -0,0 +1,10 @@
RANGE = [1477.0, 1481.0]
STEP_SIZE = 0.1
SETTLING_TIME = 0.5
r=lscan (objective, image.contrast, RANGE[0], RANGE[1], STEP_SIZE, latency=(SETTLING_TIME + eiger.getExposure()))
(norm, mn, std )= fit (r["image_contrast"], r["objective"])
if (mn<RANGE[0] or mn>RANGE[1]):
raise Exception("Invalid fit")
objective.write(mn)

0
script/test/test_eiger Normal file → Executable file
View File

0
script/test/test_eiger.py Normal file → Executable file
View File