scanspec#
Specify step and flyscan paths in a serializable, efficient and Pythonic way using combinations of:
Specs like Line or Spiral
Optionally Snaking
Zip, Product and Concat to compose
Serialize the Spec rather than the expanded Path and reconstruct it on the server. It can then be iterated over like a cycler, or a stack of scan Frames can be produced and expanded Paths created to consume chunk by chunk.
Source |
|
|---|---|
PyPI |
|
Docker |
|
Documentation |
|
Releases |
An example ScanSpec of a 2D snaked grid flyscan inside a circle spending 0.4s at each point:
from scanspec.specs import Ellipse, Fly
spec = Fly(0.4 @ Ellipse(x, 1, 1, 1/9, y, 2.8, y_step=1.7/11, snake=True))
Which when plotted looks like:

Scan points can be iterated through directly for convenience:
for point in spec.midpoints():
print(point)
# ...
# {'y': 3.1818181818181817, 'x': 0.8333333333333333}
# {'y': 3.1818181818181817, 'x': 0.7222222222222222}
or a Path created from the stack of Frames and chunks of a given length consumed from it for performance:
from scanspec.core import Path
stack = spec.calculate()
len(stack[0]) # 44
stack[0].axes() # ['y', 'x']
path = Path(stack, start=5, num=30)
chunk = path.consume(10)
chunk.midpoints # {'x': <ndarray len=10>, 'y': <ndarray len=10>}
chunk.upper # bounds are same dimensionality as positions
chunk.duration # duration of each frame
How the documentation is structured#
Documentation is split into four categories, also accessible from links in the top bar.