Files
dev/script/test/TestPyArray.py
2018-01-19 10:56:53 +01:00

56 lines
2.2 KiB
Python
Executable File

def lscan(writables, readables, start, end, steps, latency=0.0, relative=False, passes=1, zigzag=False, before_read=None, after_read=None, title=None):
"""Line Scan: positioners change together, linearly from start to end positions.
Args:
writables(list of Writable): Positioners set on each step.
readables(list of Readable): Sensors to be sampled on each step.
start(list of float): start positions of writables.
end(list of float): final positions of writables.
steps(int or float or list of float): number of scan steps (int) or step size (float).
relative (bool, optional): if true, start and end positions are relative to
current at start of the scan
latency(float, optional): settling time for each step before readout, defaults to 0.0.
passes(int, optional): number of passes
zigzag(bool, optional): if true writables invert direction on each pass.
before_read (function, optional): callback on each step, before each readout. Callback may have as
optional parameters list of positions.
after_read (function, optional): callback on each step, after each readout. Callback may have as
optional parameters a ScanRecord object.
title(str, optional): plotting window name.
Returns:
ScanResult object.
"""
latency_ms=int(latency*1000)
writables=to_list(string_to_obj(writables))
readables=to_list(string_to_obj(readables))
start=to_list(start)
end=to_list(end)
if type(steps) is float or is_list(steps):
steps = to_list(steps)
scan = LineScan(writables,readables, start, end , steps, relative, latency_ms, passes, zigzag)
scan.before_read=before_read
scan.after_read=after_read
scan.setPlotTitle(title)
scan.start()
ret = scan.getResult()
return ret
a= lscan(inp, (sin,out), 0, 4, 10, 0.1)
x = a.getPositions(0)
y= a.getReadable(0)
plt = plot(None,name="data")[0]
plt.addSeries(LinePlotSeries("1"))
plt.addSeries(LinePlotSeries("2"))
plt.getSeries(0).setData(x,y)
plt.getSeries(1).setData(list(x), list(y))
plt.getSeries(2).setData(to_array(x,'d'), to_array(y,'d'))