lentil.hex_segments#

lentil.hex_segments(rings, seg_radius, seg_gap, rotate=False, antialias=True, flatten=False, pad=2, drop=(0,))[source]#

Draw a segmented aperture made up of hexagonal segments

Parameters:
  • rings (int) – Number of segment rings. Must be >= 1.

  • seg_radius (float) – Segment outscribing radius in pixels

  • seg_gap (float) – Spacing between adjacent segments in pixels

  • rotate (bool, optional) – Rotate segments so that flat sides are aligned with the Y direction instead of the default orientation which is aligned with the X direction.

  • antialias (bool, optional) – If True (default), the segment edges are antialiased.

  • flatten (bool, optional) – If True, the individual segment masks are flattened into a single global mask. Default is False.

  • pad (int, optional) – Number of additional pixels to zero-pad output by. Default is 2.

  • drop (list_like, optional) – Segments to exclude from output. 0 represents the central segment.

Return type:

ndarray

Examples

>>> import matplotlib.pyplot as plt
>>> import lentil
>>> mask = lentil.hex_segments(rings=2, seg_radius=64, seg_gap=2)
>>> fig, ax = plt.subplots(nrows=1, ncols=2, figsize=(5, 2))
>>> ax[0].imshow(np.sum(mask, axis=0))
>>> ax[0].set_title('Full aperture')
>>> ax[1].imshow(mask[0])
>>> ax[1].set_title('Segment 1')
../../_images/lentil-hex_segments-1.png

References

[1] Hexagonal Grids (https://www.redblobgames.com/grids/hexagons/)