Skip to article frontmatterSkip to article content

gdsfactory.grid

gdsfactory.grid(components: Sequence[str | Callable[[...], Component] | dict[str, Any] | DKCell] = ('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

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

Parameters
  • componentsIterable to be placed onto a grid. (can be 1D or 2D).

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

  • shapex, 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_xx alignment along (origin, xmin, xmax, center).

  • align_yy alignment along (origin, ymin, ymax, center).

  • rotationfor each component in degrees.

  • mirrorhorizontal 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()