Table Of Contents

Previous topic

Main API

This Page

Output functions

Classes and functions for the visualization of layouts cerated with the gdspy Python module.

LayoutViewer

class gdspy.LayoutViewer(cells=None, exclude_layers=[], width=800, height=600, colors=None, outlines=None)

Provide a GUI where the layout can be viewed.

The view can be scrolled vertically with the mouse wheel, and horizontally by holding the shift key and using the mouse wheel. Dragging the 2nd mouse button also scrolls the view, and if control is held down, it scrolls 10 times faster.

You can zoom in or out using control plus the mouse wheel, or drag a rectangle on the window with the 1st mouse button to zoom into that area.

A ruler is available by clicking the 1st mouse button anywhere on the view and moving the mouse around. The distance is shown in the status area.

Double-clicking on any polygon gives some information about it.

Layer colors can be changed by double-clicking on the layer list or clicking the 3rd mouse button on any polygon. On the color chooser, clicking cancel will make the selected layer transparent. To change the outline color, use shift + double click on the layer list, or shift + click with the 3rd button on any polygon.

The background color can be changed by clicking on the background with the 3rd mouse button.

Parameters :

cells : array-like

The array of cells to be included in the view. If None, all cells listed in Cell.cell_list are used.

exclude_layers : array-like

The array of layers to be excluded from the view.

width : integer

Horizontal size of the viewer window.

height : integer

Vertical size of the viewer window.

colors : array-like

Colors (RGB tuple) for each GDSII layer, with components from 0 to 255. Any colors set to None will set that layer to transparent.

outlines : array-like

Colors (RGB tuple) for each GDSII layer, with components from 0 to 255. Any colors set to None will set that layer to transparent.

Examples

All layers filled (in red, green, and blue) and with light outlines:

>>> LayoutViewer(colors=[(255, 0, 0), (0, 255, 0), (0, 0, 255)],
...              outlines=[(192, 192, 192)])

No filling, colored outlines:

>>> LayoutViewer(colors=[None] * 64)

Methods

Canvas

class viewer.Canvas(colors, outlines, resolution=1, bounding_box=None)

Rasterize the GDSII elements onto an image buffer that can be saved or edited latter.

Parameters :

colors : array

Colors (RGB tuple) for each GDSII layer.

outlines : array

Colors (RGB tuple) for each GDSII layer.

resolution : number

Geometry scaling in pixels per user units.

bounding_box : array-like[4]

Area of the geometry to be draw on the output file in the format (min_x, max_x, min_y, max_y). If None, the whole extent of each cell will be used.

Methods

gds_image()

gdspy.gds_image(cells=None, exclude_layers=[], image_name=None, image_format='png', colors=None, outlines=None, resolution=1, bounding_box=None, antialias=0)

Generates an image from each cell and saves them to files.

Parameters :

cells : gdspy.Cell or list

Cell or list of cells to be included in the plot. If None, all cells listed in Cell.cell_list are used.

exclude_layers : array-like

The array of layers to be excluded from the plot.

image_name : string

Name of the output image without extension. If None, the cell names will be used. If cells contains more than 1 element, the name of the output file will be the corresponding cell name with image_name as a prefix.

image_format : string

The supported image formats are bmp, gif, jpg, pcx, png, ppm, and tiff.

colors : array-like

Colors (RGB tuple) for each layer.

outlines : array-like

Outline colors (RGB tuple) for each layer.

resolution : number

Geometry scaling in pixels per user units.

bounding_box : array-like[4]

Area of the geometry to be draw on the output file in the format (min_x, max_x, min_y, max_y). If None, the whole extent of each cell will be used.

antialias : non-negative integer

Level of anti-aliasing to be used when drawing the image.

Examples

>>> colors = [(255,0,0), (0,255,0), (0,0,255)]
>>> gds_image(image_name='/output_folder/layout', colors=colors)

gds_print()

gdspy.gds_print(output, cells=None, name='library', unit=1.0e-06, precision=1.0e-09)

Output a list of cells as a GDSII stream library.

The dimensions actually written on the GDSII file will be the dimensions of the objects created times the ratio unit/precision. For example, if a circle with radius 1.5 is created and we set unit=1.0e-06 (1 um) and precision=1.0e-09 (1 nm), the radius of the circle will be 1.5 um and the GDSII file will contain the dimension 1500 nm.

Parameters :

output : file

The file where the GDSII stream will be written. It must be opened for writing operations in binary format.

cells : array-like

The list of cells to be included in the library. If None, all cells listed in Cell.cell_list are used.

name : string

Name of the GDSII library (file).

unit : number

Unit size for the objects in the library (in meters).

precision : number

Precision for the dimensions of the objects in the library (in meters).

Examples

>>> out = open('out-file.gds', 'wb')
>>> gdspy.gds_print(out, unit=1.0e-6, precision=1.0e-9)
>>> out.close()