Compound Generator¶
-
class
scanpointgenerator.
CompoundGenerator
(generators, excluders, mutators, duration=-1, continuous=True)[source]¶ Nest N generators, apply exclusion regions to relevant generator pairs and apply any mutators before yielding points
Parameters: - generators (list(Generator)) – List of Generators to nest
- excluders (list(Excluder)) – List of Excluders to filter points by
- mutators (list(Mutator)) – List of Mutators to apply to each point
- duration (double) – Point durations in seconds (-1 for variable)
- continuous (boolean) – Make points continuous (set upper/lower bounds)
-
size
= None¶ int – Final number of points to be generated - valid only after calling prepare
-
shape
= None¶ tuple(int) – Final shape of the scan - valid only after calling prepare
-
dimensions
= None¶ list(Dimension) – Dimension instances - valid only after calling prepare
-
prepare
()[source]¶ Prepare data structures required for point generation and initialize size, shape, and dimensions attributes. Must be called before get_point or iterator are called.
-
iterator
()[source]¶ Iterator yielding generator positions at each scan point
Yields: Point – The next point
-
get_point
(n)[source]¶ Retrieve the desired point from the generator
Parameters: n (int) – point to be generated Returns: The requested point Return type: Point
-
classmethod
from_dict
(d)[source]¶ Create a CompoundGenerator instance from a serialised dictionary
Parameters: d (dict) – Dictionary of attributes Returns: New CompoundGenerator instance Return type: CompoundGenerator
Raster Scan Example¶
This scan will create an outer “y” line scan with 4 points, then nest an “x” line scan inside it with 5 points.
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import plot_generator
xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate=False)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
gen = CompoundGenerator([ys, xs], [], [])
plot_generator(gen)
(Source code, png, hires.png, pdf)
Snake Scan Example¶
This scan will create an outer “y” line scan with 4 points, then nest an “x” line scan inside it with 5 points. On every second row, the “x” line scan will be run in reverse to give a snake scan.
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import plot_generator
xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate=True)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
gen = CompoundGenerator([ys, xs], [], [])
plot_generator(gen)
(Source code, png, hires.png, pdf)
Restrictions¶
Generators with axes filtered by an excluder or between any such generators
must have a common alternate
setting. An exception is made for the
outermost generator as it is not repeated.