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 distinguished later on.

  1. Import needed modules.

    from vortex.marker import Flags, ScanBoundary, VolumeBoundary
    from vortex.scan import RasterScanConfig, RadialScanConfig, FreeformScanConfig, FreeformScan
    
  2. Set up a RasterScanConfig purely to generate its segments. Assign unique flags to distinguish from the aiming segments.

    rsc = RasterScanConfig()
    rsc.bscans_per_volume = 30
    
    # set unique flags for raster segments
    rsc.flags = Flags(0x1)
    
    raster_segments = rsc.to_segments()
    
  3. Now set up a RadialScanConfig for its segments. Also assign unique flags to distinguish from the raster 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()
    
  4. 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
    
  5. FreeformScan can now generate a scan based on this pattern.

    ffsc = FreeformScanConfig()
    ffsc.pattern = pattern
    ffsc.loop = True
    
    scan = FreeformScan()
    scan.initialize(ffsc)
    
  6. (Optional) Configure formatters with flags to route the segments of each type to different processing.

(Source code, svg, pdf)

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