Compound Generator

class scanpointgenerator.CompoundGenerator(generators, excluders, mutators)[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
iterator()[source]

Top level iterator to mutate points and yield them

Yields:Point – Mutated points
contains_point(point)[source]

Filter a Point through all Excluders

Parameters:point (Point) – Point to check
Returns:Whether point is contained by all Excluders
Return type:bool
to_dict()[source]

Convert object attributes into a dictionary

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, plot_generator

xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate_direction=False)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
gen = CompoundGenerator([ys, xs], [], [])
plot_generator(gen)

(Source code)

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, plot_generator

xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate_direction=True)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
gen = CompoundGenerator([ys, xs], [], [])
plot_generator(gen)

(Source code)