gdsfactory.grid

Contents

gdsfactory.grid#

gdsfactory.grid(components: Sequence[str | Callable[[...], Component] | dict[str, Any] | KCell | Component] = ('rectangle', 'triangle'), spacing: tuple[float, float] | float = (5.0, 5.0), shape: tuple[int, int] | None = None, align_x: Literal['origin', 'xmin', 'xmax', 'center'] = 'center', align_y: Literal['origin', 'ymin', 'ymax', 'center'] = 'center', rotation: int = 0, mirror: bool = False) Component[source]#

Returns Component with a 1D or 2D grid of components.

Parameters:
  • components – Iterable to be placed onto a grid. (can be 1D or 2D).

  • spacing – between adjacent elements on the grid, can be a tuple for different distances in height and width or a single float.

  • shape – x, y shape of the grid (see np.reshape). If no shape and the list is 1D, if np.reshape were run with (1, -1).

  • align_x – x alignment along (origin, xmin, xmax, center).

  • align_y – y alignment along (origin, ymin, ymax, center).

  • rotation – for each component in degrees.

  • mirror – horizontal mirror y axis (x, 1) (1, 0). most common mirror.

Returns:

Component containing components grid.

import gdsfactory as gf

components = [gf.components.triangle(x=i) for i in range(1, 10)]
c = gf.grid(
    components,
    shape=(1, len(components)),
    rotation=0,
    mirror=False,
    spacing=(100, 100),
)
c.plot()

(Source code, png, hires.png, pdf)

../_images/gdsfactory-grid-1.png