I/O

This module offers tools to import, export, and preprocess device layouts in multiple formats for nanofabrication prediction tasks.


load_device_img

load_device_img(path, img_length_nm=None)

Load, process and scale device image from file for prediction.

This function reads an image file, scales it according to the provided image length in nanometers, and performs preprocessing tasks such as binarization, preparing it for prediction.

Parameters

  • Name
    path
    Type
    str
    Description

    Path to the device image file.

  • Name
    img_length_nm
    Type
    int, optional
    Description

    Desired length of the device image in nanometers for scaling. If not provided, the length of the original image is used.

Returns

  • Name
    device
    Type
    np.ndarray
    Description

    A 2D numpy array representing the preprocessed and scaled device, ready for prediction.


load_device_gds

load_device_gds(path, cell_name, coords=None)

Load and process a device layout from a GDSII file.

This function reads a device layout from a GDSII file, performs necessary preprocessing tasks such as scaling and padding, and prepares it for prediction. Only the first layer (silicon) is loaded.

Parameters

  • Name
    path
    Type
    str
    Description

    Path to the GDSII layout file.

  • Name
    cell_name
    Type
    str
    Description

    Name of the GDSII cell to be loaded.

  • Name
    coords
    Type
    List[List[int]], optional
    Description

    A list of coordinates [[xmin, ymin], [xmax, ymax]] in nm, defining the region of the cell to be loaded. If None, the entire cell is loaded.

Returns

  • Name
    device
    Type
    np.ndarray
    Description

    A 2D numpy array representing the preprocessed device layout, ready for prediction.


device_to_cell

device_to_cell(device, cell_name, library, resolution=1.0, layer=(1, 0), approximation_mode=2)

Converts a device layout to a gdstk cell for GDSII export.

This function creates a cell that represents a device layout. The created cell is ready to be exported as a GDSII file.

Parameters

  • Name
    device
    Type
    np.ndarray
    Description

    A 2D numpy array representing the device layout.

  • Name
    cell_name
    Type
    str
    Description

    Name for the new cell.

  • Name
    library
    Type
    gdstk.Library
    Description

    Library to which the cell will be added.

  • Name
    resolution
    Type
    float, optional
    Description

    The resolution of the device in pixels per nm. Default is 1.0.

  • Name
    layer
    Type
    Tuple[int, int], optional
    Description

    A tuple specifying the layer to be exported. Default is (1, 0).

  • Name
    approximation_mode
    Type
    int, optional
    Description

    The approximation method to be used for finding contours. Possible values are 1, 2, 3, and 4. Larger values mean more approximation. Default is 2.

Returns

  • Name
    cell
    Type
    gdstk.Cell
    Description

    The newly created cell containing the device layout.