103 lines
2.6 KiB
Python
103 lines
2.6 KiB
Python
DETS = (sin,arr, image.getDataMatrix())
|
|
|
|
s1 = tscan(DETS, 10, 0.1)
|
|
|
|
s2 = lscan(motor, DETS, -2.0, 2.0, 10, latency=0.2, relative=True, print_scan=True)
|
|
print s2[motor]
|
|
print s2["sin"]
|
|
|
|
s3 = lscan(pe, DETS, 0.0, 10.0, 10, latency=0.1, passes=4, zigzag=True)
|
|
|
|
|
|
s4 = ascan((motor,pe), DETS, (0.0,0.0), (2.0,1.0), (8,8), latency=0.1, zigzag=True)
|
|
|
|
vector = [ 1, 3, 5, 10, 25, 40, 45, 47, 49]
|
|
s5 = vscan(pe, DETS, vector, False, latency=0.5, print_scan=True)
|
|
|
|
def spiral_gen(radius, step, resolution=.1, angle=0.0, origin=[0.0, 0.0]):
|
|
d = 0.0
|
|
while d * math.hypot(math.cos(angle), math.sin(angle)) < radius:
|
|
pos=[ origin[0] + d * math.cos(angle), \
|
|
origin[1] + d * math.sin(angle) ]
|
|
yield(pos)
|
|
d+=step
|
|
angle+=resolution
|
|
s6 = vscan((pe,pe2),(sin),spiral_gen(10, 0.1), latency=0.1, range = [-10.0,10.0, -10.0, 10.0])
|
|
|
|
|
|
s7 = rscan(pe, DETS, [(0,5,5), (10,15,20), (20,25,5)] , 0.1)
|
|
|
|
s8 = cscan(motor, DETS, -2.0, 2.0 , steps=10, relative=True)
|
|
|
|
motor.moveRelAsync(3.0)
|
|
mscan(motor.readback, DETS, -1, 2.0, async=False)
|
|
|
|
|
|
#Scan Callbacks
|
|
def before_read(position, scan):
|
|
outi.write(1)
|
|
outi.write(0)
|
|
print "In position: " + str(position[0]) + ", " + str(position[1])
|
|
|
|
def after_read(rec, scan):
|
|
print "Aquired frame %i: at %f, %f: %f" % (rec.index, rec[pe], rec["pe2"], rec[DETS[0]])
|
|
|
|
s9= lscan((pe,pe2), (DETS), (0,0), (4,8), steps=20, latency = 0.01, before_read=before_read, after_read=after_read)
|
|
|
|
|
|
|
|
#Setting attributes to the scan group
|
|
path = get_exec_pars().scanPath
|
|
set_attribute(path, "AttrString", "Value")
|
|
set_attribute(path, "AttrInteger", 1)
|
|
set_attribute(path, "AttrDouble", 2.0)
|
|
set_attribute(path, "AttrBoolean", True)
|
|
|
|
|
|
#Manipulating sampled data
|
|
s10= lscan(pe, DETS, 0, 40, 40, 0.01, False)
|
|
s11= lscan(pe, DETS, 0, 40, 40, 0.01, False)
|
|
from operator import add
|
|
result = map(add, s10[sin], s11[sin])
|
|
plot(result)
|
|
|
|
|
|
|
|
#Pseudo-devices
|
|
class Clock(Readable):
|
|
def read(self):
|
|
return time.clock()
|
|
|
|
class PseudoSensor(Readable):
|
|
def read(self):
|
|
v = arr.take() #Gets the CACHED waveform
|
|
return reduce(lambda x, y: x + y, v) / len(v)
|
|
|
|
class PseudoPositioner(Writable):
|
|
def write(self,pos):
|
|
print "Step = " + str(pos)
|
|
|
|
clock=Clock()
|
|
averager=PseudoSensor()
|
|
positioner=PseudoPositioner()
|
|
|
|
s12 = lscan(positioner,(sin, averager,clock),0, 40,20,0.1)
|
|
|
|
|
|
#Resampling
|
|
index=0
|
|
def after_read(rec):
|
|
if rec[pe2] < 0:
|
|
time.sleep(1.0)
|
|
rec.invalidate()
|
|
s13 = lscan(pe, DETS+(pe2,), 0.0, 0.4, 10, 1.0, after_read=after_read)
|
|
|
|
|
|
|
|
#Averaging
|
|
av = create_averager(sin, 3, 0.1)
|
|
res= lscan(pe, (av, av.samples), 0, 20, 10)
|
|
|
|
|
|
|