gdsfactory.read.from_np

Contents

gdsfactory.read.from_np#

gdsfactory.read.from_np(ndarray: ndarray, nm_per_pixel: int = 20, layer: tuple[int, int] = (1, 0), threshold: float = 0.99, invert: bool = True, border_pad_num_pixels: int = 2, border_pad_pixel_value: float | None = None) Component[source]#

Returns Component from a np.ndarray.

Extracts contours skimage.measure.find_contours using threshold.

Parameters:
  • ndarray – 2D ndarray representing the device layout.

  • nm_per_pixel – scale_factor.

  • layer – layer tuple to output gds.

  • threshold – value along which to find contours in the array.

  • invert – invert the mask.

  • border_pad_num_pixels – number of pixels to pad image border with. A value of 2 is usually sufficient to capture contours along the image border.

  • border_pad_pixel_value – set value of padding pixels (optional). This is passed to np.pad through the ‘constant_values’ argument.