gdstk.contour

gdstk.contour(data, level=0, length_scale=1, precision=0.01, layer=0, datatype=0) list

Extract polygonal contours from 2-d array data at given level.

Parameters:
  • data (array-like[M][N]) – 2-dimensional array with shape (M, N).

  • level – Polygons are created representing the regions where data is at least level.

  • length_scale – Distance between neighboring elements in data.

  • precision – Desired precision for rounding vertex coordinates.

  • layer – layer number assigned to the resulting polygons.

  • datatype – data type number assigned to the resulting polygons.

Returns:

List of gdstk.Polygon.

Examples

>>> y, x = numpy.mgrid[0.5:1.5:128j, -1:1:255j]
>>> data = (numpy.sin(4 * numpy.pi * x * y)
...         - 0.8 * numpy.sin(2 * numpy.pi * y))
>>> contours = gdstk.contour(data, 0, 1 / 127, 0.01 / 127)
>>> rect = gdstk.rectangle((0, 0), (2, 1), datatype=1)
../_images/contour.svg

Notes

The length scale for the polygons is one element of data, i.e., the full region represented by data represents a rectangular area of lenght_scale * (N - 1) × length_scale * (M - 1). Argument precision is understood in this length scale.