Line Generator¶
-
class
scanpointgenerator.
LineGenerator
(axes, units, start, stop, size, alternate=False)[source]¶ Generate a line of equally spaced N-dimensional points
Parameters: - axes (str/list(str)) – The scannable axes E.g. “x” or [“x”, “y”]
- units (str/list(str)) – The scannable units. E.g. “mm” or [“mm”, “mm”]
- start (float/list(float)) – The first position to be generated. e.g. 1.0 or [1.0, 2.0]
- stop (float or list(float)) – The final position to be generated. e.g. 5.0 or [5.0, 10.0]
- size (int) – The number of points to generate. E.g. 5
- alternate (bool) – Specifier to reverse direction if generator is nested
-
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]¶ Create a LineGenerator instance from a serialised dictionary
Parameters: d (dict) – Dictionary of attributes Returns: New LineGenerator instance Return type: LineGenerator
Examples¶
This example defines a motor “x” with engineering units “mm” which is being scanned from 0mm to 1mm with 5 scan points inclusive of the start. Note that the capture points are as given, so the bounds will be +-0.5*step of each capture point.
from scanpointgenerator import LineGenerator
from scanpointgenerator.plotgenerator import plot_generator
gen = LineGenerator("x", "mm", 0.0, 1.0, 5)
plot_generator(gen)
(Source code, png, hires.png, pdf)
LineGenerator is N dimensional; just pass in ND lists for name, start and stop.
from scanpointgenerator import LineGenerator
from scanpointgenerator.plotgenerator import plot_generator
gen = LineGenerator(["x", "y"], ["mm", "mm"], [1.0, 2.0], [5.0, 10.0], 5)
plot_generator(gen)
(Source code, png, hires.png, pdf)