Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
0db41f7
Add means of pre-calculating value arrays in generators
c-mita Oct 20, 2016
f861456
Adjust SectorROI contains_point calculation
c-mita Oct 24, 2016
4d77d8e
Fix PointROI contains_point bug
c-mita Oct 24, 2016
2ba7de3
Add mask generation for points in regions
c-mita Oct 24, 2016
9b026a4
Rewrite compound generator to handle new point generation mechanism
c-mita Nov 4, 2016
4310c6a
Handle generators that alternate directions in compound generator
c-mita Nov 8, 2016
ed7f078
Call mutators in CompoundGenerator.iterator
c-mita Nov 9, 2016
c428a68
Rewrite tests for CompoundGenerator after its big change
c-mita Nov 9, 2016
8739983
Fix up other tests after Generator changes
c-mita Nov 9, 2016
ae15b8d
Add time-sensitive test for compound generator for a large scan.
c-mita Nov 9, 2016
3c69be5
Change the way CompoundGenerator handles alternating generators
c-mita Nov 11, 2016
0082b8f
Rename internal index dict to dimension in compound generator
c-mita Nov 14, 2016
88d745d
Add dimension indexes to points in CompoundGenerator
c-mita Nov 14, 2016
deae585
Use scisoftpy in Jython instead of numpy
c-mita Nov 15, 2016
f2bf5b9
Use in-place array operators in roi mask calculations
c-mita Nov 15, 2016
f6938bf
Permit omission of the alternate setting on outermost generator
c-mita Nov 21, 2016
7aabf9f
Change RectangularROI to include points on both sides of boundary
c-mita Nov 21, 2016
aa400d9
Do not merge dimensions with rectangular regions over line generators
c-mita Nov 21, 2016
831dbd7
Handle single point case in LineGenerator
c-mita Nov 21, 2016
ec085a0
Fix point bounds in compound generator and add tests.
c-mita Nov 22, 2016
550ebcb
Change generator bounds to be a single array
c-mita Nov 22, 2016
400929b
Tidy CompoundGenerator a little bit
c-mita Nov 23, 2016
467351c
Fix LissajousGenerator point generation to properly add offsets
c-mita Nov 23, 2016
c6fdd91
Remove iterator from Generators (except CompoundGenerator)
c-mita Nov 24, 2016
3aade71
Restore index_dims attribute to CompoundGenerator
c-mita Nov 24, 2016
a321c4f
Tidy-up Lissajous point generation code
c-mita Nov 25, 2016
ca35058
Remove unused Lock import in CompoundGenerator
c-mita Nov 25, 2016
5de5594
Fix LineGenerator point calculation to ensure float division
c-mita Dec 5, 2016
8ed4063
Add produce_points to Generator and stop CompoundGenerator deriving it.
c-mita Dec 5, 2016
dc05577
Merge remote-tracking branch 'origin/master' into generation_rewrite
c-mita Dec 6, 2016
903d2ad
Remove ArrayGenerator
c-mita Dec 6, 2016
1460605
Only apply bounds to innermost generator in CompoundGenerator
c-mita Dec 6, 2016
d16c61d
Update documentation following vectorisation changes.
c-mita Dec 6, 2016
a142209
Rename generator.points to generator.positions
c-mita Dec 15, 2016
af63151
Add parameterised generator.prepare_array for position/bounds generation
c-mita Dec 15, 2016
6235893
Reset internal state in CompoundGenerator.prepare
c-mita Dec 21, 2016
e6aadbb
Force integer divisions to actually return integers
c-mita Dec 21, 2016
3d490e7
Change Mutators to act on individual points, not iterators
c-mita Dec 21, 2016
554f518
Pass linear index to mutator and rewrite RandomOffsetMutator
c-mita Jan 9, 2017
2501c05
Fix documentation following changes to generator point production.
c-mita Jan 9, 2017
c4031a8
Remove redundant attributes in generator __init__'s
c-mita Jan 9, 2017
daf887f
Move Dimension from compoundgenerator.py to new dimension.py
c-mita Feb 20, 2017
16b1d28
Rename generator.num to generator.size
c-mita Feb 20, 2017
d1d8465
Fix spelling of indices in compoundgenerator.py
c-mita Feb 21, 2017
58b441b
Make CompoundGenerator.prepare a no-op on successive calls
c-mita Feb 22, 2017
c13849c
Add test class for Dimension
c-mita Feb 22, 2017
3f3cd50
Use Dimension size attribute instead of multiplying generator sizes
c-mita Feb 22, 2017
a1775d7
Move comment on polygonal roi test
c-mita Feb 22, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions docs/architecture.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
Architecture
============

Every scan point generator inherits from the ScanPointGenerator baseclass. This
baseclass provides the following API:
Scan points are produced by a :ref:`compoundgenerator` that wraps base generators,
:ref:`excluders` and :ref:`mutators`.

All Generators inherit from the Generator baseclass, which provides the
following API:

.. module:: scanpointgenerator

Expand All @@ -18,13 +21,11 @@ API:
Using the API
-------------

You would use a generator in a step scan like this::

>>> for point in generator.iterator():
>>> for mname, mpos in point.positions():
>>> motors[mname].move(mpos)
>>> det.write_data_to_index(point.indexes)



A basic use case that uses two generators looks like this::

cgen = CompoundGenerator([outer_generator, inner_generator], [], [])
cgen.prepare()
for point in cgen.iterator():
for mname, mpos in point.positions():
motors[mname].move(mpos)
det.write_data_to_index(point.indexes)
34 changes: 0 additions & 34 deletions docs/arraygenerator.rst

This file was deleted.

30 changes: 28 additions & 2 deletions docs/compoundgenerator.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _compoundgenerator:

Compound Generator
==================

Expand All @@ -16,7 +18,8 @@ line scan inside it with 5 points.
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, plot_generator
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import plot_generator

xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate_direction=False)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
Expand All @@ -34,9 +37,32 @@ be run in reverse to give a snake scan.
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, plot_generator
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import 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)


.. _compoundgenerator_restrictions:

Restrictions
------------

:ref:`excluders` must be defined on axes that are given by consecutive
generators. Generators with axes filtered by an excluder must also have a
common ``alternate_direction`` setting. An exception is made for the outermost
generator as it is not repeated.

The following is `not` legal::

from scanpointgenerator import LineGenerator, CompoundGenerator, \
Excluder, CircularROI

xs = LineGenerator("x", "mm", 0, 1, 2)
ys = LineGenerator("y", "mm", 0, 1, 2)
zs = LineGenerator("z", "mm", 0, 1, 2)
exc = Excluder(CircularROI([0, 0], 1), ["x", "z"])
gen = CompoundGenerator([zs, ys, xs], [exc], []) # xs and zs are not consecutive
18 changes: 9 additions & 9 deletions docs/creating.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Creating a Generator

The idea of CompoundGenerator is that you can combine generators, excluders
and mutators arbitrarily. The following will show some more extensive examples
to show the capabilities of scanpointgenerator.
to show the capabilities of scanpointgenerator. Remember to account for the
restrictions specified in :ref:`compoundgenerator_restrictions`.


A spiral scan with an offset rectangular roi overlay and randomly offset
Expand All @@ -13,8 +14,8 @@ points in the y direction
:include-source:

from scanpointgenerator import LineGenerator, SpiralGenerator, \
CompoundGenerator, Excluder, RandomOffsetMutator, plot_generator
from scanpointgenerator.rectangular_roi import RectangularROI
CompoundGenerator, Excluder, RandomOffsetMutator, RectangularROI
from scanpointgenerator.plotgenerator import plot_generator

spiral = SpiralGenerator(["x", "y"], "mm", [0.0, 0.0], 10.0,
alternate_direction=True)
Expand All @@ -36,6 +37,7 @@ A spiral scan at each point of a line scan with alternating direction
spiral = SpiralGenerator(["x", "y"], "mm", [0.0, 0.0], 1.2,
alternate_direction=True)
gen = CompoundGenerator([line, spiral], [], [])
gen.prepare()

for point in gen.iterator():
for axis, value in point.positions.items():
Expand All @@ -57,21 +59,20 @@ A spiral scan at each point of a line scan with alternating direction
{'y': 0.695, 'x': -0.56, 'z': 20.0}
{'y': 0.992, 'x': 0.361, 'z': 20.0}

Three nested line scans with an excluder operating on the innermost and
outermost axes
Three nested line scans with an excluder operating on the two innermost axes

.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, \
Excluder
from scanpointgenerator.circular_roi import CircularROI
Excluder, CircularROI

line1 = LineGenerator("x", "mm", 0.0, 2.0, 3)
line2 = LineGenerator("y", "mm", 0.0, 1.0, 2)
line3 = LineGenerator("z", "mm", 0.0, 1.0, 2)
circle = Excluder(CircularROI([1.0, 1.0], 1.0), ["x", "z"])
circle = Excluder(CircularROI([1.0, 1.0], 1.0), ["x", "y"])
gen = CompoundGenerator([line3, line2, line1], [circle], [])
gen.prepare()

for point in gen.iterator():
print(point.positions)
Expand All @@ -86,4 +87,3 @@ outermost axes
{'y': 1.0, 'x': 0.0, 'z': 1.0}
{'y': 1.0, 'x': 1.0, 'z': 1.0}
{'y': 1.0, 'x': 2.0, 'z': 1.0}

12 changes: 7 additions & 5 deletions docs/excluders.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _excluders:

Excluders
=========

Expand All @@ -18,8 +20,8 @@ Here we use a CircularROI to filter the points of a snake scan
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, \
Excluder, plot_generator
from scanpointgenerator.circular_roi import CircularROI
Excluder, CircularROI
from scanpointgenerator.plotgenerator import plot_generator

x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate_direction=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
Expand All @@ -33,12 +35,12 @@ And with the excluder applied
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, \
Excluder, plot_generator
from scanpointgenerator.circular_roi import CircularROI
Excluder, CircularROI
from scanpointgenerator.plotgenerator import plot_generator

x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate_direction=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
circle = Excluder(CircularROI([2.0, 1.0], 2.0), ["x", "y"])
excluder = Excluder(circle, ['x', 'y'])
gen = CompoundGenerator([y, x], [circle], [])
plot_generator(gen, circle)
plot_generator(gen, circle)
1 change: 0 additions & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ Table of Contents
linegenerator
spiralgenerator
lissajousgenerator
arraygenerator

.. toctree::
:maxdepth: 1
Expand Down
6 changes: 4 additions & 2 deletions docs/linegenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ of each capture point.
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, plot_generator
from scanpointgenerator import LineGenerator
from scanpointgenerator.plotgenerator import plot_generator

gen = LineGenerator("x", "mm", 0.0, 1.0, 5)
plot_generator(gen)
Expand All @@ -27,7 +28,8 @@ LineGenerator is N dimensional; just pass in ND lists for name, start and stop.
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, plot_generator
from scanpointgenerator import LineGenerator
from scanpointgenerator.plotgenerator import plot_generator

gen = LineGenerator(["x", "y"], "mm", [1.0, 2.0], [5.0, 10.0], 5)
plot_generator(gen)
8 changes: 5 additions & 3 deletions docs/lissajousgenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ will be scanned over a 3x4 lobe Lissajous curve with filling a 1x1mm rectangle.
.. plot::
:include-source:

from scanpointgenerator import LissajousGenerator, plot_generator
from scanpointgenerator import LissajousGenerator
from scanpointgenerator.plotgenerator import plot_generator

box = dict(centre=[0.0, 0.0], width=1.0, height=1.0)
gen = LissajousGenerator(['x', 'y'], "mm", box=box, num_lobes=3, num_points=50)
Expand All @@ -27,8 +28,9 @@ visible. The following plot is for 10x11 lobes with the default number of points
.. plot::
:include-source:

from scanpointgenerator import LissajousGenerator, plot_generator
from scanpointgenerator import LissajousGenerator
from scanpointgenerator.plotgenerator import plot_generator

box = dict(centre=[0.0, 0.0], width=1.0, height=1.0)
gen = LissajousGenerator(['x', 'y'], "mm", box=box, num_lobes=20)
plot_generator(gen, show_indexes=False)
plot_generator(gen, show_indexes=False)
26 changes: 22 additions & 4 deletions docs/mutators.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.. _mutators:

Mutators
========

Expand All @@ -18,7 +20,8 @@ apply it to a snake scan
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, plot_generator
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import plot_generator

xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate_direction=True)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
Expand All @@ -30,10 +33,25 @@ And with the random offset
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, RandomOffsetMutator, plot_generator
from scanpointgenerator import LineGenerator, CompoundGenerator, RandomOffsetMutator
from scanpointgenerator.plotgenerator import plot_generator

xs = LineGenerator("x", "mm", 0.0, 0.5, 5, alternate_direction=True)
ys = LineGenerator("y", "mm", 0.0, 0.5, 4)
random_offset = RandomOffsetMutator(seed=1, axes = ["x", "y"], max_offset=dict(x=0.05, y=0.05))
random_offset = RandomOffsetMutator(seed=12345, axes = ["x", "y"], max_offset=dict(x=0.05, y=0.05))
gen = CompoundGenerator([ys, xs], [], [random_offset])
plot_generator(gen)
plot_generator(gen)


Example with a spiral

.. plot::
:include-source:

from scanpointgenerator import SpiralGenerator, CompoundGenerator, RandomOffsetMutator
from scanpointgenerator.plotgenerator import plot_generator

spiral = SpiralGenerator(["x", "y"], ["mm", "mm"], [0., 0.], 5.0, 1.25)
random_offset = RandomOffsetMutator(seed=12345, axes = ["x", "y"], max_offset=dict(x=0.2, y=0.2))
gen = CompoundGenerator([spiral], [], [random_offset])
plot_generator(gen)
8 changes: 4 additions & 4 deletions docs/serialisation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ As an example of serialising, here is a simple snake scan.
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, \
plot_generator
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import plot_generator

x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate_direction=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
Expand All @@ -137,8 +137,8 @@ It is the same after being serialised and deserialised.
.. plot::
:include-source:

from scanpointgenerator import LineGenerator, CompoundGenerator, \
plot_generator
from scanpointgenerator import LineGenerator, CompoundGenerator
from scanpointgenerator.plotgenerator import plot_generator

x = LineGenerator("x", "mm", 0.0, 4.0, 5, alternate_direction=True)
y = LineGenerator("y", "mm", 0.0, 3.0, 4)
Expand Down
8 changes: 5 additions & 3 deletions docs/spiralgenerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ will be scanned in a spiral filling a circle of radius 5mm.
.. plot::
:include-source:

from scanpointgenerator import SpiralGenerator, plot_generator
from scanpointgenerator import SpiralGenerator
from scanpointgenerator.plotgenerator import plot_generator

gen = SpiralGenerator(["x", "y"], "mm", [0.0, 0.0], 5.0)
plot_generator(gen)
Expand All @@ -25,7 +26,8 @@ In this example the spiral is scaled to be more sparse.
.. plot::
:include-source:

from scanpointgenerator import SpiralGenerator, plot_generator
from scanpointgenerator import SpiralGenerator
from scanpointgenerator.plotgenerator import plot_generator

gen = SpiralGenerator(["x", "y"], "mm", [0.0, 0.0], 5.0, scale=2.0)
plot_generator(gen)
plot_generator(gen)
Loading