Interleave Different ScansΒΆ

Complex scans, such as an aiming scan interleaved with a raster scan, are easily created using FreeformScan. Any combination of scan pattern generations or scan config objects can be used to generate the segments that FreeformScan uses. This example illustrates how to configure an aiming scan (i.e., a RadialScan with two perpendicular segments) and insert it throughout a larger raster scan. Each scan type is assigned different flags so the two can be segments from each can be distinguished later on.

  1. Imports needed modules.

from vortex.marker import Flags, ScanBoundary, VolumeBoundary
from vortex.scan import RasterScanConfig, RadialScanConfig, FreeformScanConfig, FreeformScan
  1. Set up a RasterScanConfig purely to generate its segments.

rsc = RasterScanConfig()
rsc.bscans_per_volume = 30

# set unique flags for raster segments
rsc.flags = Flags(0x1)

raster_segments = rsc.to_segments()
  1. Now set up a RadialScanConfig for its segments.

asc = RadialScanConfig()

asc.set_aiming()
# add an offset just to illustrate
asc.offset = (4, 0)

# set unique flags for aiming segments
asc.flags = Flags(0x2)

aiming_segments = asc.to_segments()
  1. Combine the two scans by inserting aiming segments at 10 evenly-spaced intervals between the raster segments.

pattern = []
# segment indices within the raster scan to insert the aiming scan
idx = np.linspace(0, len(raster_segments), 10, dtype=int)

# loop over each pair of indices
for (i, (a, b)) in enumerate(zip(idx[:-1], idx[1:])):

    # this if statement is only needed until an outstanding bug is fixed
    if i > 0:
        markers = raster_segments[a].markers
        markers.insert(0, VolumeBoundary(0, 0, False))
        markers.insert(0, ScanBoundary(0, 0))

    # append the next chunk of raster segments
    pattern += raster_segments[a:b]
    # append the aiming segments
    pattern += aiming_segments
  1. FreeformScan can now generate a scan based on this pattern.

ffsc = FreeformScanConfig()
ffsc.pattern = pattern
ffsc.loop = True

scan = FreeformScan()
scan.initialize(ffsc)

(Source code, svg, pdf)

../../_images/interleave-1.svg