Static Point Generator

class scanpointgenerator.StaticPointGenerator(size)[source]

Generate ‘empty’ points with no axis information

to_dict()[source]

Abstract method to convert object attributes into a dictionary

prepare_arrays(index_array)[source]

Abstract method to create position or bounds array from provided index array. index_array will be np.arange(self.size) for positions and np.arange(self.size + 1) - 0.5 for bounds.

Parameters:index_array (np.array) – Index array to produce parameterised points
Returns:Dictionary of axis names to position/bounds arrays
Return type:Positions
classmethod from_dict(d)[source]

Abstract method to create a ScanPointGenerator instance from a serialised dictionary

Parameters:d (dict) – Dictionary of attributes
Returns:New ScanPointGenerator instance
Return type:Generator

Examples

Produce empty points to “multiply” existing generators within a Compound Generator, adding an extra dimension.

>>> from scanpointgenerator import StaticPointGenerator, LineGenerator, CompoundGenerator
>>> line_gen = LineGenerator("x", "mm", 0.0, 1.0, 3)
>>> nullpoint_gen = StaticPointGenerator(2)
>>> gen = CompoundGenerator([nullpoint_gen, line_gen], [], [])
>>> gen.prepare()
>>> [point.positions for point in gen.iterator()]
[{'x': 0.0}, {'x': 0.5}, {'x': 1.0}, {'x': 0.0}, {'x': 0.5}, {'x': 1.0}]

Using a StaticPointGenerator on its own in a compound generator is also allowed.

>>> from scanpointgenerator import StaticPointGenerator, CompoundGenerator
>>> nullpoint_gen = StaticPointGenerator(3)
>>> gen = CompoundGenerator([nullpoint_gen], [], [])
>>> gen.prepare()
>>> [point.positions for point in gen.iterator()]
[{}, {}, {}]