Closedown
This commit is contained in:
@@ -1,28 +1,6 @@
|
||||
"""
|
||||
Demonstrate the use of Line Scan: one or multiple positioners move together linearly.
|
||||
Diode scan
|
||||
"""
|
||||
|
||||
#This optional preference limits the displayed plots
|
||||
#set_preference(Preference.ENABLED_PLOTS, [ai1, ai2,])
|
||||
|
||||
#This optional preference displays wf1 as a 1d plot at each scan point, instead of a matrix plot
|
||||
#set_preference(Preference.PLOT_TYPES, {wf1:1})
|
||||
|
||||
#Execute the scan: 200 steps, a1 from 0 to 40
|
||||
a= lscan(ao1, (diode,current), 0, 40, 200, 0.01)
|
||||
|
||||
#Also samples an image:
|
||||
#a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 200, 0.01)
|
||||
|
||||
#Alternative: Steps of size 0.1, a1 from 0 to 40
|
||||
#a= lscan(ao1, (ai1,ai2,wf1), 0, 40, 0.5, 0.01)
|
||||
|
||||
#2 positioners moving together in 200 steps, a1 from 0 to 40 and a2 from 0 to 100
|
||||
#a= lscan((ao1,ao2), (ai1,ai2,wf1), (0, 0), (40, 100), 200, 0.01)
|
||||
|
||||
#Setting attributes to the scan group
|
||||
path = get_current_group()
|
||||
set_attribute(path, "AttrString", "Value")
|
||||
set_attribute(path, "AttrInteger", 1)
|
||||
set_attribute(path, "AttrDouble", 2.0)
|
||||
set_attribute(path, "AttrBoolean", True)
|
||||
|
||||
@@ -59,66 +59,11 @@ def fit(ydata, xdata = None):
|
||||
p.addMarker(max_x, None, "Max="+str(round(max_x,2)), Color.GRAY)
|
||||
print "Invalid gaussian fit: " + str(mean)
|
||||
return (None, None, None)
|
||||
|
||||
|
||||
|
||||
#fit([1,2,3, 3,3,3,4,5,6,12,33,23,15,3,2,1, 1, 1, 1, 1])
|
||||
run("rock")
|
||||
|
||||
|
||||
#def rock(axis = None):
|
||||
# from rock import rock
|
||||
# rock()
|
||||
# #run("rock", {"rock_axis":None})
|
||||
|
||||
|
||||
def rock(axis = th1, ffail = False, tt = 0.2, seti0 = False, dx = None, noref = False):
|
||||
"""
|
||||
"""
|
||||
if axis is None:
|
||||
axis = th1
|
||||
if noref == False:
|
||||
caput('X06DA-OP-MO:MONOBEAM', -1 )
|
||||
e = get_energy()
|
||||
if dx is None:
|
||||
dx = 7.5e-2/e
|
||||
|
||||
# reinforce theta1 and 2 setting (setting could be RDBD 0.0001 and RTRY 1 when seteq does not finish nicely)
|
||||
# put 'Retry deadband' to 0.00004 and 'Retries Max' to 5
|
||||
time.sleep(0.2)
|
||||
caput('X06DA-OP-MO1:ROX1.RDBD',0.00004)
|
||||
caput('X06DA-OP-MO1:ROX2.RDBD',0.00004)
|
||||
caput('X06DA-OP-MO1:ROX1.RTRY',5)
|
||||
caput('X06DA-OP-MO1:ROX2.RTRY',5)
|
||||
|
||||
#time stamp
|
||||
print time.strftime('%X %x')
|
||||
|
||||
#MVR,axis,-dx
|
||||
#SCAN,axis,0,2*dx,20,/fit,/centre,SILENT = silent,FFAIL = ffail,time=tt,/deriv,$
|
||||
#data=d
|
||||
axis_pos = axis.read()
|
||||
result = lscan(axis, mono_beam, -dx, dx, 20, latency = 0.3, relative = True, context = None, before_read = None, after_read = None)
|
||||
(ydata, xdata) = (result.getReadable(0), result.getPositions(0))
|
||||
(norm, mean, sigma) = fit(ydata, xdata)
|
||||
if (mean is not None) and (mean <= (axis_pos + dx)) and (mean >= (axis_pos - dx)):
|
||||
axis.move(mean)
|
||||
else:
|
||||
print 'fit failed - centering on maximum'
|
||||
max_x= xdata[ydata.index(max(ydata))]
|
||||
axis.move(max_x)
|
||||
|
||||
if seti0 and not ffail:
|
||||
time.sleep(2)
|
||||
run("setI0")
|
||||
#add after_rock BPM1:SUM as reference for monitoring monochromator thermal drift
|
||||
if (noref==False) and not ffail:
|
||||
time.sleep(3) # wait a bit until mono theta finish moving
|
||||
br = mono_beam.read()
|
||||
caput('X06DA-OP-MO:MONOBEAM', br)
|
||||
print 'rock_success new mono beam at ' + str(br) + ' at' + str(e) + ' keV'
|
||||
|
||||
|
||||
|
||||
#from rock import rock
|
||||
|
||||
def fbm():
|
||||
"""
|
||||
|
||||
@@ -2,22 +2,20 @@
|
||||
#
|
||||
###################################################################################################
|
||||
|
||||
from startup import *
|
||||
#from startup import * #Not needed: executed from local
|
||||
|
||||
def rock(axis = None, ffail = False, tt = 0.2, seti0 = False, dx = None, noref = False):
|
||||
def rock(axis = th1, ffail = False, tt = 0.2, seti0 = False, dx = None, noref = False):
|
||||
"""
|
||||
"""
|
||||
inject()
|
||||
#inject() #Not needed: executed from local
|
||||
if axis is None:
|
||||
axis = th1
|
||||
|
||||
axis = th1
|
||||
if noref == False:
|
||||
caput('X06DA-OP-MO:MONOBEAM', -1 )
|
||||
e = get_energy()
|
||||
if dx is None:
|
||||
dx = 7.5e-2/e
|
||||
|
||||
# reinforce theta1 and 2 setting (setting could be RDBD 0.0001 and RTRY 1 when seteq does not finish nicely)
|
||||
|
||||
# put 'Retry deadband' to 0.00004 and 'Retries Max' to 5
|
||||
time.sleep(0.2)
|
||||
caput('X06DA-OP-MO1:ROX1.RDBD',0.00004)
|
||||
@@ -25,12 +23,7 @@ def rock(axis = None, ffail = False, tt = 0.2, seti0 = False, dx = None, noref =
|
||||
caput('X06DA-OP-MO1:ROX1.RTRY',5)
|
||||
caput('X06DA-OP-MO1:ROX2.RTRY',5)
|
||||
|
||||
#time stamp
|
||||
print time.strftime('%X %x')
|
||||
|
||||
#MVR,axis,-dx
|
||||
#SCAN,axis,0,2*dx,20,/fit,/centre,SILENT = silent,FFAIL = ffail,time=tt,/deriv,$
|
||||
#data=d
|
||||
print time.strftime('%X %x')
|
||||
axis_pos = axis.read()
|
||||
result = lscan(axis, mono_beam, -dx, dx, 20, latency = 0.3, relative = True, context = None, before_read = None, after_read = None)
|
||||
(ydata, xdata) = (result.getReadable(0), result.getPositions(0))
|
||||
@@ -52,5 +45,4 @@ def rock(axis = None, ffail = False, tt = 0.2, seti0 = False, dx = None, noref =
|
||||
caput('X06DA-OP-MO:MONOBEAM', br)
|
||||
print 'rock_success new mono beam at ' + str(br) + ' at' + str(e) + ' keV'
|
||||
|
||||
if __name__ == "__builtin__":
|
||||
rock(rock_axis)
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
|
||||
axis = th1
|
||||
ffail = False
|
||||
tt = 0.2
|
||||
seti0 = False
|
||||
dx = None
|
||||
noref = False
|
||||
|
||||
|
||||
if noref == False:
|
||||
caput('X06DA-OP-MO:MONOBEAM', -1 )
|
||||
e = get_energy()
|
||||
if dx is None:
|
||||
dx = 7.5e-2/e
|
||||
|
||||
# reinforce theta1 and 2 setting (setting could be RDBD 0.0001 and RTRY 1 when seteq does not finish nicely)
|
||||
# put 'Retry deadband' to 0.00004 and 'Retries Max' to 5
|
||||
time.sleep(0.2)
|
||||
caput('X06DA-OP-MO1:ROX1.RDBD',0.00004)
|
||||
caput('X06DA-OP-MO1:ROX2.RDBD',0.00004)
|
||||
caput('X06DA-OP-MO1:ROX1.RTRY',5)
|
||||
caput('X06DA-OP-MO1:ROX2.RTRY',5)
|
||||
|
||||
#time stamp
|
||||
print time.strftime('%X %x')
|
||||
|
||||
#MVR,axis,-dx
|
||||
#SCAN,axis,0,2*dx,20,/fit,/centre,SILENT = silent,FFAIL = ffail,time=tt,/deriv,$
|
||||
#data=d
|
||||
axis_pos = axis.read()
|
||||
result = lscan(axis, mono_beam, -dx, dx, 20, latency = 0.3, relative = True, context = None, before_read = None, after_read = None)
|
||||
(ydata, xdata) = (result.getReadable(0), result.getPositions(0))
|
||||
(norm, mean, sigma) = fit(ydata, xdata)
|
||||
if (mean is not None) and (mean <= (axis_pos + dx)) and (mean >= (axis_pos - dx)):
|
||||
axis.move(mean)
|
||||
else:
|
||||
print 'fit failed - centering on maximum'
|
||||
max_x= xdata[ydata.index(max(ydata))]
|
||||
axis.move(max_x)
|
||||
|
||||
if seti0 and not ffail:
|
||||
time.sleep(2)
|
||||
run("setI0")
|
||||
#add after_rock BPM1:SUM as reference for monitoring monochromator thermal drift
|
||||
if (noref==False) and not ffail:
|
||||
time.sleep(3) # wait a bit until mono theta finish moving
|
||||
br = mono_beam.read()
|
||||
caput('X06DA-OP-MO:MONOBEAM', br)
|
||||
print 'rock_success new mono beam at ' + str(br) + ' at' + str(e) + ' keV'
|
||||
Reference in New Issue
Block a user