scanspec

Build Status Test Coverage Latest PyPI version Apache License

Specify step and flyscan Paths using combinations of:

  • Specs like Line or Spiral

  • Optionally Snaking

  • Zip, Product and Concat to compose

  • Masks with multiple Regions to restrict

Serialize the Spec rather than the expanded Path and reconstruct it on the server. It can them be iterated over like a cycler, or scan Dimensions can be produced and expanded Paths created to consume chunk by chunk.

PyPI

pip install scanspec

Source code

https://github.com/dls-controls/scanspec

Documentation

https://dls-controls.github.io/scanspec

An example ScanSpec of a 2D snaked grid flyscan inside a circle spending 0.4s at each point looks like:

from scanspec.specs import Line, fly
from scanspec.regions import Circle

grid = Line(ymotor, 2.1, 3.8, 12) * ~Line(xmotor, 0.5, 1.5, 10)
spec = fly(grid, 0.4) & Circle(xmotor, ymotor, 1.0, 2.8, radius=0.5)

plot

You can then either iterate through the scan positions directly for convenience:

for positions in spec.positions():
    print(positions)
# ...
# {ymotor: 3.2813559322033896, xmotor: 0.8838383838383839, "TIME": 0.4}
# {ymotor: 3.2813559322033896, xmotor: 0.8737373737373737, "TIME": 0.4}

or create a Path from the Dimensions and consume chunks of a given length from it for performance:

from scanspec.core import Path

dims = spec.create_dimensions()
len(dims[0].shape)  # 44
dims[0].keys()  # (ymotor, xmotor, "TIME")

path = Path(dims, start=5, num=30)
chunk = path.consume(10)
chunk.positions  # {xmotor: <ndarray len=10>, ymotor: <ndarray len=10>, "TIME": <ndarray len=10>}
chunk.upper  # bounds are same dimensionality as positions

How the documentation is structured

Tutorials

Tutorials for installation, library and commandline usage. New users start here.

How-to Guides

Practical step-by-step guides for the more experienced user.

Explanations

Explanation of how the library works and why it works that way.

Reference

Technical reference material, for classes, methods, APIs, commands, and contributing to the project.