Provided by: gdspy-doc_1.3.1-3_all bug

NAME

       gdspy - gdspy Documentation

       For  installation  instructions  and  other  information,  please  check  out  the  GitHub
       repository or the README file included with the source.

EXAMPLES

   Tutorial
       The following code is a sample to quickly demonstrate some features of gdspy.

       Download sample file

          ######################################################################
          #                                                                    #
          #  Copyright 2009-2018 Lucas Heitzmann Gabrielli.                    #
          #  This file is part of gdspy, distributed under the terms of the    #
          #  Boost Software License - Version 1.0.  See the accompanying       #
          #  LICENSE file or <http://www.boost.org/LICENSE_1_0.txt>            #
          #                                                                    #
          ######################################################################

          import numpy
          import gdspy

          print('Using gdspy module version ' + gdspy.__version__)

          # ------------------------------------------------------------------ #
          #      POLYGONS
          # ------------------------------------------------------------------ #

          # First we need a cell to add the polygons to.
          poly_cell = gdspy.Cell('POLYGONS')

          # We define the polygon through its vertices.
          points = [(0, 0), (2, 2), (2, 6), (-6, 6), (-6, -6), (-4, -4), (-4, 4), (0, 4)]

          # Create the polygon on layer 1.
          poly1 = gdspy.Polygon(points, 1)

          # Add the new polygon to the cell.
          poly_cell.add(poly1)

          # Create another polygon from the same set of points, but rotate it
          # 180 degrees and add it to the cell.
          poly2 = gdspy.Polygon(points, 1).rotate(numpy.pi)
          poly_cell.add(poly2)

          # To create rectangles we don't need to give the 4 corners, only 2.
          # Note that we don't need to create a variable if we are not going to
          # use it, just add the rectangle directly to the cell.  Create a
          # rectangle in layer 2.
          poly_cell.add(gdspy.Rectangle((18, 1), (22, 2), 2))

          # There are no circles in the GDSII specification, so rounded shapes
          # are actually many-sided polygons.  Create a circle in layer 2,
          # centered at (27, 2), and with radius 2.
          poly_cell.add(gdspy.Round((27, 2), 2, layer=2))

          # The Round class is quite versatile: it provides circles, pie slices,
          # rings and ring sections, like this one in layer 2.
          poly_cell.add(
              gdspy.Round(
                  (23.5, 7),
                  15,
                  inner_radius=14,
                  initial_angle=-2.0 * numpy.pi / 3.0,
                  final_angle=-numpy.pi / 3.0,
                  layer=2))

          # ------------------------------------------------------------------ #
          #      PATHS
          # ------------------------------------------------------------------ #

          path_cell = gdspy.Cell('PATHS')

          # Start a path from the origin with width 1.
          path1 = gdspy.Path(1, (0, 0))

          # Add a straight segment to the path in layer 1, datatype 1, with length
          # 3, going in the '+x' direction. Since we'll use this layer/datatype
          # configuration again, we can setup a dict containing this info.
          spec = {'layer': 1, 'datatype': 1}
          path1.segment(3, '+x', **spec)

          # Add a curve to the path by specifying its radius as 2 and its initial
          # and final angles.
          path1.arc(2, -numpy.pi / 2.0, numpy.pi / 6.0, **spec)

          # Add another segment to the path in layer 1, with length 4 and
          # pointing in the direction defined by the last piece we added above.
          path1.segment(4, **spec)

          # Add a curve using the turn command.  We specify the radius 2 and
          # turning angle. The agnle can also be specified with 'l' and 'r' for
          # left and right turns of 90 degrees, or 'll' and 'rr' for 180 degrees.
          path1.turn(2, -2.0 * numpy.pi / 3.0, **spec)

          # Final piece of the path.  Add a straight segment and tapper the path
          # width from the original 1 to 0.5.
          path1.segment(3, final_width=0.5, **spec)
          path_cell.add(path1)

          # We can also create parallel paths simultaneously.  Start 2 paths with
          # width 0.5 each,nd pitch 1, originating where our last path ended.
          path2 = gdspy.Path(0.5, (path1.x, path1.y), number_of_paths=2, distance=1)

          # Add a straight segment to the paths gradually increasing their
          # distance to 1.5, in the direction in which the last path ended.
          spec['layer'] = 2
          path2.segment(3, path1.direction, final_distance=1.5, **spec)

          # Path commands can be concatenated.  Add a turn and a tapper segment
          # in one expression, followed by a final turn.
          path2.turn(2, -2.0 * numpy.pi / 3.0, **spec).segment(
              4, final_distance=1, **spec)
          path2.turn(4, numpy.pi / 6.0, **spec)
          path_cell.add(path2)

          # Create another single path 0.5 wide, starting where the path above
          # ended, and add to it a line segment in the 3rd layer in the '-y'
          # direction.
          path3 = gdspy.Path(0.5, (path2.x, path2.y))
          path3.segment(1, '-y', layer=3)

          # We can create paths based on parametric curves. First we need to
          # define the curve function, with 1 argument.  This argument will vary
          # from 0 to 1 and the return value should be the (x, y) coordinates of
          # the path.  This could be a lambda-expression if the function is
          # simple enough.  We will create a spiral path.  Note that the function
          # returns (0, 0) when t=0, so that our path is connected.
          def spiral(t):
              r = 4 - 3 * t
              theta = 5 * t * numpy.pi
              x = 4 - r * numpy.cos(theta)
              y = -r * numpy.sin(theta)
              return (x, y)

          # We can also create the derivative of the curve to pass to out path
          # path member, otherwise it will be numerically calculated.  In the
          # spiral case we don't want the exact derivative, but the derivative of
          # the spiral as if its radius was constant.  This will ensure that our
          # path is connected at the start (geometric problem of this kind of
          # spiral).
          def dspiral_dt(t):
              theta = 5 * t * numpy.pi
              dx_dt = numpy.sin(theta)
              dy_dt = -numpy.cos(theta)
              return (dx_dt, dy_dt)

          # Add the parametric spiral to the path in layer 3.  Note that we can
          # still tapper the width (linearly or with a taper function).  To make
          # the curve smoother, we increase the number of evaluations of the
          # function (fracture will be performed automatically to ensure polygons
          # with less than 200 points).
          path3.parametric(
              spiral,
              dspiral_dt,
              final_width=lambda t: 0.1 + abs(0.4 * (1 - 2 * t)**3),
              number_of_evaluations=600,
              layer=3)
          path_cell.add(path3)

          # Polygonal paths are defined by the points they pass through.  The
          # width of the path can be given as a number, representing the path
          # width along is whole extension, or as a list, where each element is
          # the width of the path at one point.  Our path will have width 0.5 in
          # all points, except the last, where it will tapper up to 1.5.  More
          # than 1 path can be defined in parallel as well (useful for buses).
          # The distance between the paths work the same way as the width: it's
          # either a constant number, or a list.  We create 5 parallel paths that
          # are larger and further apart on the last point. The paths are put in
          # layers 4 and 5. Since we have 5 paths, the list of layers will be
          # run more than once, so the 5 paths will actually be in layers 4, 5, 4,
          # 5, and 4.
          points = [(20, 12), (24, 8), (24, 4), (24, -2)]
          widths = [0.5] * (len(points) - 1) + [1.5]
          distances = [0.8] * (len(points) - 1) + [2.4]
          polypath = gdspy.PolyPath(
              points, widths, number_of_paths=5, distance=distances, layer=[4, 5])

          # We can round the corners of any Polygon or PolygonSet with the fillet
          # method. Here we use a radius of 0.2.
          # polypath.fillet(0.2)
          path_cell.add(polypath)

          # L1Paths use only segments in 'x' and 'y' directions, useful for some
          # lithography mask writers.  We specify a path composed of 16 segments
          # of length 4.  The turns after each segment can be either 90 degrees
          # CCW (positive) or CW (negative).  The absolute value of the turns
          # produces a scaling of the path width and distance between paths in
          # segments immediately after the turn.
          lengths = [4] * 8
          turns = [-1, -1, 1, 1, -1, -2, 1, 0.5]
          l1path = gdspy.L1Path(
              (-1, -11),
              '+y',
              0.5,
              lengths,
              turns,
              number_of_paths=3,
              distance=0.7,
              layer=6)
          path_cell.add(l1path)

          # ------------------------------------------------------------------ #
          #      POLYGON OPERATIONS
          # ------------------------------------------------------------------ #

          # Boolean operations can be executed with either gdspy polygons or
          # point lists).  The operations are union, intersection, subtraction,
          # symmetric subtracion (respectively 'or', 'and', 'not', 'xor').
          oper_cell = gdspy.Cell('OPERATIONS')

          # Here we subtract the previously created spiral from a rectangle with
          # the 'not' operation.
          oper_cell.add(
              gdspy.fast_boolean(
                  gdspy.Rectangle((10, -4), (17, 4)), path3, 'not', layer=1))

          # Polygon offset (inset and outset) can be used, for instance, to
          # define safety margins around shapes.

          spec = {'layer': 7}
          path4 = gdspy.Path(0.5, (21, -5)).segment(3, '+x', **spec)\
                  .turn(4, 'r', **spec).turn(4, 'rr', **spec)\
                  .segment(3, **spec)
          oper_cell.add(path4)

          # Merge all parts into a single polygon.
          merged = gdspy.fast_boolean(path4, None, 'or', max_points=0)

          # Offset the path shape by 0.5 and add it to the cell.
          oper_cell.add(gdspy.offset(merged, 1, layer=8))

          # ------------------------------------------------------------------ #
          #      SLICING POLYGONS
          # ------------------------------------------------------------------ #

          # If there is the need to cut a polygon or set of polygons, it's better
          # to use the slice function than set up a boolean operation, since it
          # runs much faster.  Slices are multiple cuts perpendicular to an axis.
          slice_cell = gdspy.Cell('SLICE')
          original = gdspy.Round((0, 0), 10, inner_radius=5)

          # Slice the original ring along x = -7 and x = 7.
          result = gdspy.slice(original, [-7, 7], 0, layer=1)

          # The result is a tuple of polygon sets, one for each slice.  To keep
          # add the region between our 2 cuts, we chose result[1].
          slice_cell.add(result[1])

          # If the cut needs to be at an angle we can rotate the geometry, slice
          # it, and rotate back.
          original = gdspy.PolyPath([(12, 0), (12, 8), (28, 8), (28, -8), (12, -8),
                                     (12, 0)], 1, 3, 2)
          original.rotate(numpy.pi / 3, center=(20, 0))
          result = gdspy.slice(original, 7, 1, layer=2)
          result[0].rotate(-numpy.pi / 3, center=(20, 0))
          slice_cell.add(result[0])

          # ------------------------------------------------------------------ #
          #      REFERENCES AND TEXT
          # ------------------------------------------------------------------ #

          # Cells can contain references to other cells.
          ref_cell = gdspy.Cell('REFS')
          ref_cell.add(gdspy.CellReference(poly_cell, (0, 30), x_reflection=True))
          ref_cell.add(gdspy.CellReference(poly_cell, (25, 0), rotation=180))

          # References can be whole arrays. Add an array of the operations cell
          # with 2 lines and 3 columns and 1st element at (25, 10).
          ref_cell.add(
              gdspy.CellArray('OPERATIONS', 3, 2, (35, 30), (25, 10), magnification=1.5))

          # Text are also sets of polygons. They have edges parallel to 'x' and
          # 'y' only.
          ref_cell.add(
              gdspy.Text(
                  'Created with gsdpy ' + gdspy.__version__, 7, (-7, -35), layer=6))

          # Labels are special text objects which don't define any actual
          # geometry, but can be used to annotate the drawing.  Rotation,
          # magnification and reflection of the text are not supported by the
          # included GUI, but they are included in the resulting GDSII file.
          ref_cell.add(
              gdspy.Label(
                  'Created with gdspy ' + gdspy.__version__, (-7, -36), 'nw', layer=6))

          # ------------------------------------------------------------------ #
          #      Translation
          # ------------------------------------------------------------------ #

          trans_cell = gdspy.Cell('TRANS')

          # Any geometric object can be translated by providing the distance to
          # translate in the x-direction and y-direction:  translate(dx, dy)
          rect1 = gdspy.Rectangle((80, 0), (81, 1), 1)
          rect1.translate(2, 0)
          trans_cell.add(rect1)

          # Translatable objects can also be copied & translated in the same way.
          rect2 = gdspy.Rectangle((80, 0), (81, 1), 2)
          rect3 = gdspy.copy(rect2, 0, 3)
          trans_cell.add(rect2)
          trans_cell.add(rect3)

          # Reference Cells are also translatable, and thus copyable.
          ref1 = gdspy.CellReference(poly_cell, (25, 0), rotation=180)
          ref2 = gdspy.copy(ref1, 30, 30)
          trans_cell.add(ref1)
          trans_cell.add(ref2)

          # Same goes for Labels & Text
          text1 = gdspy.Text(
              'Created with gdspy ' + gdspy.__version__, 7, (-7, -35), layer=6)
          text2 = gdspy.copy(text1, 0, -20)
          label1 = gdspy.Label(
              'Created with gdspy ' + gdspy.__version__, (-7, -36), 'nw', layer=6)
          label2 = gdspy.copy(label1, 0, -20)
          trans_cell.add(text1)
          trans_cell.add(text2)
          trans_cell.add(label1)
          trans_cell.add(label2)

          # ------------------------------------------------------------------ #
          #      OUTPUT
          # ------------------------------------------------------------------ #

          # Output the layout to a GDSII file (default to all created cells).
          # Set the units we used to micrometers and the precision to nanometers.
          gdspy.write_gds('tutorial.gds', unit=1.0e-6, precision=1.0e-9)

          # ------------------------------------------------------------------ #
          #      IMPORT
          # ------------------------------------------------------------------ #

          # Import the file we just created, and extract the cell 'POLYGONS'. To
          # avoid naming conflict, we will rename all cells.
          gdsii = gdspy.GdsLibrary()
          gdsii.read_gds(
              'tutorial.gds',
              rename={
                  'POLYGONS': 'IMPORT_POLY',
                  'PATHS': 'IMPORT_PATHS',
                  'OPERATIONS': 'IMPORT_OPER',
                  'SLICE': 'IMPORT_SLICE',
                  'REFS': 'IMPORT_REFS',
                  'TRANS': 'IMPORT_TRANS'
              },
              layers={
                  1: 7,
                  2: 8,
                  3: 9
              })

          # Now we extract the cells we want to actually include in our current
          # structure. Note that the referenced cells will be automatically
          # extracted as well.
          gdsii.extract('IMPORT_REFS')

          # ------------------------------------------------------------------ #
          #      VIEWER
          # ------------------------------------------------------------------ #

          # View the layout using a GUI.  Full description of the controls can
          # be found in the online help at http://gdspy.sourceforge.net/
          gdspy.LayoutViewer()

   Integrated Photonics
       This example demonstrates the use of gdspy primitives to create more complex structures.

       These structures are commonly used in the field of integrated photonics.

       Download sample file

          ######################################################################
          #                                                                    #
          #  Copyright 2009-2018 Lucas Heitzmann Gabrielli.                    #
          #  This file is part of gdspy, distributed under the terms of the    #
          #  Boost Software License - Version 1.0.  See the accompanying       #
          #  LICENSE file or <http://www.boost.org/LICENSE_1_0.txt>            #
          #                                                                    #
          ######################################################################

          import numpy
          import gdspy

          def waveguide(path,
                        points,
                        finish,
                        bend_radius,
                        number_of_points=0.01,
                        direction=None,
                        layer=0,
                        datatype=0):
              '''
              Easy waveguide creation tool with absolute positioning.

              path             : starting `gdspy.Path`
              points           : coordinates along which the waveguide will travel
              finish           : end point of the waveguide
              bend_radius      : radius of the turns in the waveguide
              number_of_points : same as in `path.turn`
              direction        : starting direction
              layer            : GDSII layer number
              datatype         : GDSII datatype number

              Return `path`.
              '''
              if direction is not None:
                  path.direction = direction
              axis = 0 if path.direction[1] == 'x' else 1
              points.append(finish[(axis + len(points)) % 2])
              n = len(points)
              if points[0] > (path.x, path.y)[axis]:
                  path.direction = ['+x', '+y'][axis]
              else:
                  path.direction = ['-x', '-y'][axis]
              for i in range(n):
                  path.segment(
                      abs(points[i] - (path.x, path.y)[axis]) - bend_radius,
                      layer=layer,
                      datatype=datatype)
                  axis = 1 - axis
                  if i < n - 1:
                      goto = points[i + 1]
                  else:
                      goto = finish[axis]
                  if (goto > (path.x, path.y)[axis]) ^ ((path.direction[0] == '+') ^
                                                        (path.direction[1] == 'x')):
                      bend = 'l'
                  else:
                      bend = 'r'
                  path.turn(
                      bend_radius,
                      bend,
                      number_of_points=number_of_points,
                      layer=layer,
                      datatype=datatype)
              return path.segment(
                  abs(finish[axis] - (path.x, path.y)[axis]),
                  layer=layer,
                  datatype=datatype)

          def taper(path,
                    length,
                    final_width,
                    final_distance,
                    direction=None,
                    layer=0,
                    datatype=0):
              '''
              Linear tapers for the lazy.

              path        : `gdspy.Path` to append the taper
              length      : total length
              final_width : final width of th taper
              direction   : taper direction
              layer       : GDSII layer number (int or list)
              datatype    : GDSII datatype number (int or list)

              Parameters `layer` and `datatype` must be of the same type. If they
              are lists, they must have the same length. Their length indicate the
              number of pieces that compose the taper.

              Return `path`.
              '''
              if layer.__class__ == datatype.__class__ == [].__class__:
                  assert len(layer) == len(datatype)
              elif isinstance(layer, int) and isinstance(datatype, int):
                  layer = [layer]
                  datatype = [datatype]
              else:
                  raise ValueError('Parameters layer and datatype must have the same '
                                   'type (either int or list) and length.')
              n = len(layer)
              w = numpy.linspace(2 * path.w, final_width, n + 1)[1:]
              d = numpy.linspace(path.distance, final_distance, n + 1)[1:]
              l = float(length) / n
              for i in range(n):
                  path.segment(
                      l, direction, w[i], d[i], layer=layer[i], datatype=datatype[i])
              return path

          def grating(period,
                      number_of_teeth,
                      fill_frac,
                      width,
                      position,
                      direction,
                      lda=1,
                      sin_theta=0,
                      focus_distance=-1,
                      focus_width=-1,
                      evaluations=99,
                      layer=0,
                      datatype=0):
              '''
              Straight or focusing grating.

              period          : grating period
              number_of_teeth : number of teeth in the grating
              fill_frac       : filling fraction of the teeth (w.r.t. the period)
              width           : width of the grating
              position        : grating position (feed point)
              direction       : one of {'+x', '-x', '+y', '-y'}
              lda             : free-space wavelength
              sin_theta       : sine of incidence angle
              focus_distance  : focus distance (negative for straight grating)
              focus_width     : if non-negative, the focusing area is included in
                                the result (usually for negative resists) and this
                                is the width of the waveguide connecting to the
                                grating
              evaluations     : number of evaluations of `path.parametric`
              layer           : GDSII layer number
              datatype        : GDSII datatype number

              Return `PolygonSet`
              '''
              if focus_distance < 0:
                  path = gdspy.L1Path(
                      (position[0] - 0.5 * width,
                       position[1] + 0.5 * (number_of_teeth - 1 + fill_frac) * period),
                      '+x',
                      period * fill_frac, [width], [],
                      number_of_teeth,
                      period,
                      layer=layer,
                      datatype=datatype)
              else:
                  neff = lda / float(period) + sin_theta
                  qmin = int(focus_distance / float(period) + 0.5)
                  path = gdspy.Path(period * fill_frac, position)
                  max_points = 199 if focus_width < 0 else 2 * evaluations
                  c3 = neff**2 - sin_theta**2
                  w = 0.5 * width
                  for q in range(qmin, qmin + number_of_teeth):
                      c1 = q * lda * sin_theta
                      c2 = (q * lda)**2
                      path.parametric(
                          lambda t: (width * t - w, (c1 + neff * numpy.sqrt(c2 - c3 * (
                              width * t - w)**2)) / c3),
                          number_of_evaluations=evaluations,
                          max_points=max_points,
                          layer=layer,
                          datatype=datatype)
                      path.x = position[0]
                      path.y = position[1]
                  if focus_width >= 0:
                      path.polygons[0] = numpy.vstack(
                          (path.polygons[0][:evaluations, :],
                           ([position] if focus_width == 0 else
                            [(position[0] + 0.5 * focus_width, position[1]),
                             (position[0] - 0.5 * focus_width, position[1])])))
                      path.fracture()
              if direction == '-x':
                  return path.rotate(0.5 * numpy.pi, position)
              elif direction == '+x':
                  return path.rotate(-0.5 * numpy.pi, position)
              elif direction == '-y':
                  return path.rotate(numpy.pi, position)
              else:
                  return path

          if __name__ == '__main__':
              # Examples

              c1 = gdspy.Cell('Example1')
              # Waveguide starts at (0, 0)...
              path = gdspy.Path(0.450, (0, 0))
              # ... then starts in the +y direction up to y=200, then through x=500,
              # and stops at (800, 400). All bends have radius 50.
              waveguide(path, [200, 500], (800, 400), 50, direction='+y')
              c1.add(path)

              # More useful example including a taper and a grating:
              c2 = gdspy.Cell('Example2')
              for i in range(3):
                  path = gdspy.Path(0.120, (50 * i, 0))
                  taper(
                      path,
                      75,
                      0.450,
                      0,
                      '+y',
                      layer=list(range(5, 1, -1)),
                      datatype=list(range(1, 5)))
                  waveguide(
                      path, [300 - 20 * i], (500 + 50 * i, 425), 50, layer=1, datatype=1)
                  c2.add(path)
                  c2.add(
                      grating(
                          0.626,
                          28,
                          0.5,
                          19, (path.x, path.y),
                          path.direction,
                          1.55,
                          numpy.sin(numpy.pi * 8 / 180),
                          21.5,
                          2 * path.w,
                          layer=1,
                          datatype=1))

              # Straight grating and positive resist example
              c3 = gdspy.Cell('Example3')
              spec = {'layer': 4, 'datatype': 3}
              lda = 1.55
              gr_width = 10
              gr_per = 0.626
              gr_teeth = 20
              wg_clad = 4
              wg_width = 0.45
              tp_len = 700
              c3.add(
                  grating(gr_per, gr_teeth, 0.5, gr_width, (gr_per * gr_teeth, 0), '-x',
                          lda, numpy.sin(numpy.pi * 8 / 180), **spec))
              path = gdspy.Path(
                  wg_clad, (0, 0), number_of_paths=2, distance=gr_width + wg_clad)
              path.segment(gr_per * gr_teeth, '+x', **spec)
              taper(path, tp_len, wg_clad, wg_width + wg_clad, **spec)
              waveguide(path, [800], (tp_len + gr_per * gr_teeth, 200), 50, 0.1, **spec)
              taper(path, tp_len, wg_clad, gr_width + wg_clad, **spec)
              c3.add(
                  grating(gr_per, gr_teeth, 0.5, gr_width, (path.x, path.y),
                          path.direction, lda, numpy.sin(numpy.pi * 8 / 180), **spec))
              path.segment(gr_per * gr_teeth, **spec)
              c3.add(path)

              gdspy.LayoutViewer()

GEOMETRY CONSTRUCTION

       gdspy is a Python module that allows the creation of GDSII stream files.

       Many features of the GDSII format are implemented, such as cell references and arrays, but
       the support for fonts is quite limited.  Text is only available through polygonal objects.

   Classes
   Polygon
       class gdspy.Polygon(points, layer=0, datatype=0, verbose=True)
              Bases: gdspy.PolygonSet

              Polygonal geometric object.

              Parameters

                     · points (array-like[N][2]) -- Coordinates of the vertices of the polygon.

                     · layer (integer) -- The GDSII layer number for this element.

                     · datatype  (integer)  -- The GDSII datatype for this element (between 0 and
                       255).

                     · verbose (bool) -- If False, warnings about the number of vertices  of  the
                       polygon will be suppressed.
              Notes

              The  last  point  should  not  be  equal  to  the first (polygons are automatically
              closed).

              The GDSII specification supports only  a  maximum  of  199  vertices  per  polygon.
              Examples.sp
              >>> triangle_pts = [(0, 40), (15, 40), (10, 50)]
              >>> triangle = gdspy.Polygon(triangle_pts)
              >>> myCell.add(triangle)

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec  (bool)  --  If  True,  the return value is a dictionary with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round the corners of these polygons and fractures them  into  polygons  with
                     less vertices if necessary.

                     Parameters

                            · radius  (number,  list)  --  Radius of the corners.  If number: All
                              corners filleted by that amount.  If list: Specify fillet radii  on
                              a  per-corner  basis  (list  length  must be equal to the number of
                              points in the polygon)

                            · points_per_2pi (integer) -- Number of vertices used to  approximate
                              a  full  circle.   The  number  of  vertices  in each corner of the
                              polygon will be the fraction of this number  corresponding  to  the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice  these polygons in the horizontal and vertical directions so that each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out -- Bounding box of this polygon  in  the  form  [[x_min,  y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley  (number  or  None) -- Scaling factor along the second axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier (number)  --  A  number  that  multiplies  all  dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

   Rectangle
       class gdspy.Rectangle(point1, point2, layer=0, datatype=0)
              Bases: gdspy.PolygonSet

              Rectangular geometric object.

              Parameters

                     · point1 (array-like[2]) -- Coordinates of a corner of the rectangle.

                     · point2 (array-like[2]) -- .INDENT 2.0

                     Coordinates of the corner of the rectangle opposite to
                       point1.

              · layer (integer) -- The GDSII layer number for this element.

              · datatype (integer) -- The GDSII datatype for this element (between 0 and 255).
       Examples.sp
       >>> rectangle = gdspy.Rectangle((0, 0), (10, 20))
       >>> myCell.add(rectangle)

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec  (bool)  --  If  True,  the return value is a dictionary with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round the corners of these polygons and fractures them  into  polygons  with
                     less vertices if necessary.

                     Parameters

                            · radius  (number,  list)  --  Radius of the corners.  If number: All
                              corners filleted by that amount.  If list: Specify fillet radii  on
                              a  per-corner  basis  (list  length  must be equal to the number of
                              points in the polygon)

                            · points_per_2pi (integer) -- Number of vertices used to  approximate
                              a  full  circle.   The  number  of  vertices  in each corner of the
                              polygon will be the fraction of this number  corresponding  to  the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice  these polygons in the horizontal and vertical directions so that each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out -- Bounding box of this polygon  in  the  form  [[x_min,  y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley  (number  or  None) -- Scaling factor along the second axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier (number)  --  A  number  that  multiplies  all  dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

   Round
       class   gdspy.Round(center,   radius,   inner_radius=0,   initial_angle=0,  final_angle=0,
       number_of_points=0.01, max_points=199, layer=0, datatype=0)
              Bases: gdspy.PolygonSet

              Circular geometric object.  Represent a circle, a circular section,  a  ring  or  a
              ring section.

              Parameters

                     · center (array-like[2]) -- Coordinates of the center of the circle/ring.

                     · radius (number) -- Radius of the circle/outer radius of the ring.

                     · inner_radius (number) -- Inner radius of the ring.

                     · initial_angle  (number)  -- Initial angle of the circular/ring section (in
                       radians).

                     · final_angle (number) -- Final  angle  of  the  circular/ring  section  (in
                       radians).

                     · number_of_points (integer or float) --

                       If   integer:   number   of  vertices  that  form  the  object  (polygonal
                       approximation).  If float: approximate curvature resolution.
                          The actual number of points is automatically calculated.

                     · max_points (integer) -- .INDENT 2.0

                     if number_of_points > max_points, the element will be
                       fractured in smaller polygons with at most max_points each.

              · layer (integer) -- The GDSII layer number for this element.

              · datatype (integer) -- The GDSII datatype for this element (between 0 and 255).
       Notes

       The GDSII specification supports only a maximum of 199 vertices per polygon.  Examples.sp
       >>> circle = gdspy.Round((30, 5), 8)
       >>> ring = gdspy.Round((50, 5), 8, inner_radius=5)
       >>> pie_slice = gdspy.Round((30, 25), 8, initial_angle=0,
       ...                             final_angle=-5.0*numpy.pi/6.0)
       >>> arc = gdspy.Round((50, 25), 8, inner_radius=5,
       ...                       initial_angle=-5.0*numpy.pi/6.0,
       ...                       final_angle=0)

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec (bool) -- If True, the return  value  is  a  dictionary  with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round  the  corners  of these polygons and fractures them into polygons with
                     less vertices if necessary.

                     Parameters

                            · radius (number, list) -- Radius of the  corners.   If  number:  All
                              corners  filleted by that amount.  If list: Specify fillet radii on
                              a per-corner basis (list length must be  equal  to  the  number  of
                              points in the polygon)

                            · points_per_2pi  (integer) -- Number of vertices used to approximate
                              a full circle.  The number  of  vertices  in  each  corner  of  the
                              polygon  will  be  the fraction of this number corresponding to the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice these polygons in the horizontal and vertical directions so that  each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out  --  Bounding  box  of  this polygon in the form [[x_min, y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley (number or None) -- Scaling factor along  the  second  axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

   PolygonSet
       class gdspy.PolygonSet(polygons, layer=0, datatype=0, verbose=True)
              Bases: object

              Set of polygonal objects.

              Parameters

                     · polygons (list of array-like[N][2]) -- List containing the coordinates  of
                       the vertices of each polygon.

                     · layer (integer) -- The GDSII layer number for this element.

                     · datatype  (integer)  -- The GDSII datatype for this element (between 0 and
                       255).

                     · verbose (bool) -- If False, warnings about the number of vertices  of  the
                       polygon will be suppressed.

              Variables

                     · polygons  (list  of  numpy  array[N][2]) -- Coordinates of the vertices of
                       each polygon.

                     · layers (list of integer) -- The GDSII layer number for each element.

                     · datatypes (list of  integer)  --  The  GDSII  datatype  for  each  element
                       (between 0 and 255).
              Notes

              The  last  point  should  not  be  equal  to  the first (polygons are automatically
              closed).

              The GDSII specification supports only a maximum of 199 vertices per polygon.

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec (bool) -- If True, the return  value  is  a  dictionary  with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round  the  corners  of these polygons and fractures them into polygons with
                     less vertices if necessary.

                     Parameters

                            · radius (number, list) -- Radius of the  corners.   If  number:  All
                              corners  filleted by that amount.  If list: Specify fillet radii on
                              a per-corner basis (list length must be  equal  to  the  number  of
                              points in the polygon)

                            · points_per_2pi  (integer) -- Number of vertices used to approximate
                              a full circle.  The number  of  vertices  in  each  corner  of  the
                              polygon  will  be  the fraction of this number corresponding to the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice these polygons in the horizontal and vertical directions so that  each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out  --  Bounding  box  of  this polygon in the form [[x_min, y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley (number or None) -- Scaling factor along  the  second  axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

   Path
       class gdspy.Path(width, initial_point=(0, 0), number_of_paths=1, distance=0)
              Bases: gdspy.PolygonSet

              Series of geometric objects that form a path or a collection of parallel paths.

              Parameters

                     · width (number) -- The width of each path.

                     · initial_point (array-like[2]) -- Starting position of the path.

                     · number_of_paths (positive integer) -- Number of parallel paths  to  create
                       simultaneously.

                     · distance (number) -- Distance between the centers of adjacent paths.

              Variables

                     · x (number) -- Current position of the path in the x direction.

                     · y (number) -- Current position of the path in the y direction.

                     · w (number) -- Half-width of each path.

                     · n (integer) -- Number of parallel paths.

                     · direction  ({'+x',  '-x', '+y', '-y'} or number) -- Direction or angle (in
                       radians) the path points to.

                     · distance (number) -- Distance between the centers of adjacent paths.

                     · length (number) -- Length of the central path axis.  If only one  path  is
                       created, this is the real length of the path.

              arc(radius,   initial_angle,  final_angle,  number_of_points=0.01,  max_points=199,
              final_width=None, final_distance=None, layer=0, datatype=0)
                     Add a curved section to the path.

                     Parameters

                            · radius (number) -- Central radius of the section.

                            · initial_angle (number) -- Initial angle of the curve (in radians).

                            · final_angle (number) -- Final angle of the curve (in radians).

                            · number_of_points (integer  or  float)  --  If  integer:  number  of
                              vertices that form the object (polygonal approximation).  If float:
                              approximate curvature resolution.  The actual number of  points  is
                              automatically calculated.

                            · max_points  (integer)  --  if  number_of_points  >  max_points, the
                              element  will  be  fractured  in  smaller  polygons  with  at  most
                              max_points each.

                            · final_width (number) -- If set, the paths of this segment will have
                              their widths linearly changed from their current value to this one.

                            · final_distance (number) -- If set, the distance  between  paths  is
                              linearly  change  from  its  current  value  to this one along this
                              segment.

                            · layer (integer, list) -- The GDSII layer numbers for  the  elements
                              of each path.  If the number of layers in the list is less than the
                              number of paths, the list is repeated.

                            · datatype (integer, list) -- The GDSII datatype for the elements  of
                              each  path  (between 0 and 255).  If the number of datatypes in the
                              list is less than the number of paths, the list is repeated.

                     Returns
                            out -- This object.

                     Return type
                            Path
                     Notes

                     The GDSII specification supports only a maximum of 199 vertices per polygon.

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec (bool) -- If True, the return  value  is  a  dictionary  with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              direction

              distance

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round  the  corners  of these polygons and fractures them into polygons with
                     less vertices if necessary.

                     Parameters

                            · radius (number, list) -- Radius of the  corners.   If  number:  All
                              corners  filleted by that amount.  If list: Specify fillet radii on
                              a per-corner basis (list length must be  equal  to  the  number  of
                              points in the polygon)

                            · points_per_2pi  (integer) -- Number of vertices used to approximate
                              a full circle.  The number  of  vertices  in  each  corner  of  the
                              polygon  will  be  the fraction of this number corresponding to the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice these polygons in the horizontal and vertical directions so that  each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out  --  Bounding  box  of  this polygon in the form [[x_min, y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              length

              n

              parametric(curve_function,     curve_derivative=None,     number_of_evaluations=99,
              max_points=199, final_width=None, final_distance=None, layer=0, datatype=0)
                     Add a parametric curve to the path.

                     Parameters

                            · curve_function (function) -- Function that defines the curve.  Must
                              be a function of one argument  (that  varies  from  0  to  1)  that
                              returns a 2-element list, tuple or array (x, y).

                            · curve_derivative  (function) -- If set, it should be the derivative
                              of the curve function.  Must be a function of  one  argument  (that
                              varies  from  0 to 1) that returns a 2-element list, tuple or array
                              (x,y).  If None, the derivative will be calculated numerically.

                            · number_of_evaluations (integer) -- Number of points where the curve
                              function will be evaluated.  The final segment will have twice this
                              number of points.

                            · max_points (integer) -- If 2 * number_of_evaluations >  max_points,
                              the  element  will  be  fractured  in smaller polygons with at most
                              max_points each.

                            · final_width (number or function) -- If set to a number,  the  paths
                              of  this segment will have their widths linearly changed from their
                              current value to this one.  If set to a  function,  it  must  be  a
                              function  of one argument (that varies from 0 to 1) and returns the
                              width of the path.

                            · final_distance (number or function) -- If set  to  ta  number,  the
                              distance between paths is linearly change from its current value to
                              this one.  If set to a function, it  must  be  a  function  of  one
                              argument  (that  varies  from  0 to 1) and returns the width of the
                              path.

                            · layer (integer, list) -- The GDSII layer numbers for  the  elements
                              of each path.  If the number of layers in the list is less than the
                              number of paths, the list is repeated.

                            · datatype (integer, list) -- The GDSII datatype for the elements  of
                              each  path  (between 0 and 255).  If the number of datatypes in the
                              list is less than the number of paths, the list is repeated.

                     Returns
                            out -- This object.

                     Return type
                            Path
                     Notes

                     The norm of the vector returned by curve_derivative is not important.   Only
                     the direction is used.

                     The GDSII specification supports only a maximum of 199 vertices per polygon.
                     Examples.sp
                     >>> def my_parametric_curve(t):
                     ...         return (2**t, t**2)
                     >>> def my_parametric_curve_derivative(t):
                     ...         return (0.69315 * 2**t, 2 * t)
                     >>> my_path.parametric(my_parametric_curve,
                     ...                    my_parametric_curve_derivative)

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            Path

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley (number or None) -- Scaling factor along  the  second  axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              segment(length,      direction=None,     final_width=None,     final_distance=None,
              axis_offset=0, layer=0, datatype=0)
                     Add a straight section to the path.

                     Parameters

                            · length (number) -- Length of the section to add.

                            · direction ({'+x', '-x', '+y', '-y'}  or  number)  --  Direction  or
                              angle (in radians) of rotation of the segment.

                            · final_width (number) -- If set, the paths of this segment will have
                              their widths linearly changed from their current value to this one.

                            · final_distance (number) -- If set, the distance  between  paths  is
                              linearly  change  from  its  current  value  to this one along this
                              segment.

                            · axis_offset (number) -- If set, the paths will be offset from their
                              direction by this amount.

                            · layer  (integer,  list) -- The GDSII layer numbers for the elements
                              of each path.  If the number of layers in the list is less than the
                              number of paths, the list is repeated.

                            · datatype  (integer, list) -- The GDSII datatype for the elements of
                              each path (between 0 and 255).  If the number of datatypes  in  the
                              list is less than the number of paths, the list is repeated.

                     Returns
                            out -- This object.

                     Return type
                            Path

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              turn(radius,  angle,   number_of_points=0.01,   max_points=199,   final_width=None,
              final_distance=None, layer=0, datatype=0)
                     Add a curved section to the path.

                     Parameters

                            · radius (number) -- Central radius of the section.

                            · angle  ({'r',  'l', 'rr', 'll'} or number) -- Angle (in radians) of
                              rotation of the path.  The values 'r' and 'l'  represent  90-degree
                              turns  cw and ccw, respectively; the values 'rr' and 'll' represent
                              analogous 180-degree turns.

                            · number_of_points (integer  or  float)  --  If  integer:  number  of
                              vertices that form the object (polygonal approximation).  If float:
                              approximate curvature resolution.  The actual number of  points  is
                              automatically calculated.

                            · max_points  (integer)  --  if  number_of_points  >  max_points, the
                              element  will  be  fractured  in  smaller  polygons  with  at  most
                              max_points each.

                            · final_width (number) -- If set, the paths of this segment will have
                              their widths linearly changed from their current value to this one.

                            · final_distance (number) -- If set, the distance  between  paths  is
                              linearly  change  from  its  current  value  to this one along this
                              segment.

                            · layer (integer, list) -- The GDSII layer numbers for  the  elements
                              of each path.  If the number of layers in the list is less than the
                              number of paths, the list is repeated.

                            · datatype (integer, list) -- The GDSII datatype for the elements  of
                              each  path  (between 0 and 255).  If the number of datatypes in the
                              list is less than the number of paths, the list is repeated.

                     Returns
                            out -- This object.

                     Return type
                            Path
                     Notes

                     The GDSII specification supports only a maximum of 199 vertices per polygon.

              w

              x

              y

   PolyPath
       class gdspy.PolyPath(points,  width,  number_of_paths=1,  distance=0,  corners=0,  ends=0,
       max_points=199, layer=0, datatype=0)
              Bases: gdspy.PolygonSet

              Series  of geometric objects that form a polygonal path or a collection of parallel
              polygonal paths.

              Parameters

                     · points (array-like[N][2]) -- Endpoints of each path segment.

                     · width (number or array-like[N]) -- Width of the  path.   If  an  array  is
                       given, width at each endpoint.

                     · number_of_paths  (positive  integer) -- Number of parallel paths to create
                       simultaneously.

                     · distance (number or array-like[N]) --  Distance  between  the  centers  of
                       adjacent paths.  If an array is given, distance at each endpoint.

                     · corners  (positive  integer)  --  Type of joins: 0 - miter join, 1 - bevel
                       join

                     · ends (positive integer) -- Type of path  ends:  0  -  no  extension,  1  -
                       rounded, 2 - extended by half width

                     · max_points  (integer)  --  The paths will be fractured in polygons with at
                       most max_points.

                     · layer (integer, list) -- The GDSII layer numbers for the elements of  each
                       path.   If  the  number  of  layers in the list is less than the number of
                       paths, the list is repeated.

                     · datatype (integer, list) -- The GDSII datatype for the  elements  of  each
                       path  (between 0 and 255).  If the number of datatypes in the list is less
                       than the number of paths, the list is repeated.

              Returns
                     out -- This object.

              Return type
                     PolyPath
              Notes

              The bevel join will give  strange results if the number of paths is greater than 1.

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec (bool) -- If True, the return  value  is  a  dictionary  with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round  the  corners  of these polygons and fractures them into polygons with
                     less vertices if necessary.

                     Parameters

                            · radius (number, list) -- Radius of the  corners.   If  number:  All
                              corners  filleted by that amount.  If list: Specify fillet radii on
                              a per-corner basis (list length must be  equal  to  the  number  of
                              points in the polygon)

                            · points_per_2pi  (integer) -- Number of vertices used to approximate
                              a full circle.  The number  of  vertices  in  each  corner  of  the
                              polygon  will  be  the fraction of this number corresponding to the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice these polygons in the horizontal and vertical directions so that  each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out  --  Bounding  box  of  this polygon in the form [[x_min, y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley (number or None) -- Scaling factor along  the  second  axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

   L1Path
       class  gdspy.L1Path(initial_point,  direction,  width,  length,  turn,  number_of_paths=1,
       distance=0, max_points=199, layer=0, datatype=0)
              Bases: gdspy.PolygonSet

              Series of geometric objects that form a path or a collection of parallel paths with
              Manhattan geometry.

              Parameters

                     · initial_point (array-like[2]) -- Starting position of the path.

                     · direction ({'+x', '+y', '-x', '-y'}) -- Starting direction of the path.

                     · width (number) -- The initial width of each path.

                     · length (array-like) -- Lengths of each section to add.

                     · turn (array-like) -- Direction to turn  before  each  section.   The  sign
                       indicate  the  turn  direction  (ccw  is  positive),  and the modulus is a
                       multiplicative factor for the path width after each  turn.   Must  have  1
                       element less then length.

                     · number_of_paths  (positive  integer) -- Number of parallel paths to create
                       simultaneously.

                     · distance (number) -- Distance between the centers of adjacent paths.

                     · layer (integer, list) -- The GDSII layer numbers for the elements of  each
                       path.   If  the  number  of  layers in the list is less than the number of
                       paths, the list is repeated.

                     · datatype (integer, list) -- The GDSII datatype for the  elements  of  each
                       path  (between 0 and 255).  If the number of datatypes in the list is less
                       than the number of paths, the list is repeated.

              Returns
                     out -- This object.

              Return type
                     L1Path

              Variables

                     · x (number) -- Final position of the path in the x direction.

                     · y (number) -- Final position of the path in the y direction.

                     · direction ({'+x', '-x', '+y', '-y'} or number) -- Direction or  angle  (in
                       radians) the path points to.  The numerical angle is returned only after a
                       rotation of the object.
              Examples.sp
              >>> length = [10, 30, 15, 15, 15, 15, 10]
              >>> turn = [1, -1, -1, 3, -1, 1]
              >>> l1path = gdspy.L1Path((0, 0), '+x', 2, length, turn)
              >>> myCell.add(l1path)

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec (bool) -- If True, the return  value  is  a  dictionary  with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              direction

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round  the  corners  of these polygons and fractures them into polygons with
                     less vertices if necessary.

                     Parameters

                            · radius (number, list) -- Radius of the  corners.   If  number:  All
                              corners  filleted by that amount.  If list: Specify fillet radii on
                              a per-corner basis (list length must be  equal  to  the  number  of
                              points in the polygon)

                            · points_per_2pi  (integer) -- Number of vertices used to approximate
                              a full circle.  The number  of  vertices  in  each  corner  of  the
                              polygon  will  be  the fraction of this number corresponding to the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice these polygons in the horizontal and vertical directions so that  each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out  --  Bounding  box  of  this polygon in the form [[x_min, y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            L1Path

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley (number or None) -- Scaling factor along  the  second  axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              x

              y

   Text
       class  gdspy.Text(text,  size,  position=(0,  0),   horizontal=True,   angle=0,   layer=0,
       datatype=0)
              Bases: gdspy.PolygonSet

              Polygonal text object.

              Each letter is formed by a series of polygons.

              Parameters

                     · text (string) -- The text to be converted in geometric objects.

                     · size (number) -- Base size of each character.

                     · position (array-like[2]) -- Text position (lower left corner).

                     · horizontal (bool) -- .INDENT 2.0

                     If True, the text is written from left to right; if
                       False, from top to bottom.

              · angle (number) -- The angle of rotation of the text.

              · layer (integer) -- The GDSII layer number for these elements.

              · datatype (integer) -- The GDSII datatype for this element (between 0 and 255).
       Examples.sp
       >>> text = gdspy.Text('Sample text', 20, (-10, -100))
       >>> myCell.add(text)

              area(by_spec=False)
                     Calculate the total area of the path(s).

                     Parameters
                            by_spec  (bool)  --  If  True,  the return value is a dictionary with
                            {(layer, datatype): area}.

                     Returns
                            out -- Area of this object.

                     Return type
                            number, dictionary

              datatypes

              fillet(radius, points_per_2pi=128, max_points=199, precision=0.001)
                     Round the corners of these polygons and fractures them  into  polygons  with
                     less vertices if necessary.

                     Parameters

                            · radius  (number,  list)  --  Radius of the corners.  If number: All
                              corners filleted by that amount.  If list: Specify fillet radii  on
                              a  per-corner  basis  (list  length  must be equal to the number of
                              points in the polygon)

                            · points_per_2pi (integer) -- Number of vertices used to  approximate
                              a  full  circle.   The  number  of  vertices  in each corner of the
                              polygon will be the fraction of this number  corresponding  to  the
                              angle encompassed by that corner with respect to 2 pi.

                            · max_points  (integer) -- Maximal number of points in each resulting
                              polygon (must be greater than 4).

                            · precision  (float)  --  Desired  precision  for  rounding   vertice
                              coordinates in case of fracturing.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              fracture(max_points=199, precision=0.001)
                     Slice  these polygons in the horizontal and vertical directions so that each
                     resulting piece has at most max_points.  This operation occurs in place.

                     Parameters

                            · max_points (integer) -- Maximal number of points in each  resulting
                              polygon (must be greater than 4).

                            · precision   (float)  --  Desired  precision  for  rounding  vertice
                              coordinates.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              get_bounding_box()
                     Returns the bounding box of the polygons.

                     Returns
                            out -- Bounding box of this polygon  in  the  form  [[x_min,  y_min],
                            [x_max, y_max]], or None if the polygon is empty.

                     Return type
                            Numpy array[2,2] or None

              layers

              polygons

              rotate(angle, center=(0, 0))
                     Rotate this object.

                     Parameters

                            · angle (number) -- The angle of rotation (in radians).

                            · center (array-like[2]) -- Center point for the rotation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              scale(scalex, scaley=None, center=(0, 0))
                     Scale this object.

                     Parameters

                            · scalex (number) -- Scaling factor along the first axis.

                            · scaley  (number  or  None) -- Scaling factor along the second axis.
                              If None, same as scalex.

                            · center (array-like[2]) -- Center point for the scaling operation.

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

              to_gds(multiplier)
                     Convert this object to a series of GDSII elements.

                     Parameters
                            multiplier (number)  --  A  number  that  multiplies  all  dimensions
                            written in the GDSII elements.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the polygons from one place to another

                     Parameters

                            · dx (number) -- distance to move in the x-direction

                            · dy (number) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            PolygonSet

   Label
       class   gdspy.Label(text,   position,   anchor='o',   rotation=None,   magnification=None,
       x_reflection=False, layer=0, texttype=0)
              Bases: object

              Text that can be used to label parts of the geometry or display messages.  The text
              does  not  create additional geometry, it's meant for display and labeling purposes
              only.

              Parameters

                     · text (string) -- The text of this label.

                     · position (array-like[2]) -- Text anchor position.

                     · anchor ('n', 's', 'e', 'w', 'o', 'ne', 'nw'...) -- Position of the  anchor
                       relative to the text.

                     · rotation (number) -- Angle of rotation of the label (in degrees).

                     · magnification (number) -- Magnification factor for the label.

                     · x_reflection  (bool)  -- If True, the label is reflected parallel to the x
                       direction before being rotated (not supported by LayoutViewer).

                     · layer (integer) -- The GDSII layer number for these elements.

                     · texttype (integer) -- The GDSII text type for the  label  (between  0  and
                       63).

              Variables

                     · text (string) -- The text of this label.

                     · position (array-like[2]) -- Text anchor position.

                     · anchor (int) -- Position of the anchor relative to the text.

                     · rotation (number) -- Angle of rotation of the label (in degrees).

                     · magnification (number) -- Magnification factor for the label.

                     · x_reflection  (bool)  -- If True, the label is reflected parallel to the x
                       direction before being rotated (not supported by LayoutViewer).

                     · layer (integer) -- The GDSII layer number for these elements.

                     · texttype (integer) -- The GDSII text type for the  label  (between  0  and
                       63).
              Examples.sp
              >>> label = gdspy.Label('Sample label', (10, 0), 'sw')
              >>> myCell.add(label)

              anchor

              layer

              magnification

              position

              rotation

              text

              texttype

              to_gds(multiplier)
                     Convert this label to a GDSII structure.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII structure.

                     Returns
                            out -- The GDSII binary string that represents this label.

                     Return type
                            string

              translate(dx, dy)
                     Move the text from one place to another

                     Parameters

                            · dx (float) -- distance to move in the x-direction

                            · dy (float) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            Label
                     Examples.sp
                     >>> text = gdspy.Label((0, 0), (10, 20))
                     >>> text = text.translate(2, 0)
                     >>> myCell.add(text)

              x_reflection

   Functions
   fast_boolean
       gdspy.fast_boolean(operandA,   operandB,   operation,   precision=0.001,   max_points=199,
       layer=0, datatype=0)
              Execute any boolean operation between 2 polygons or polygon sets.

              Parameters

                     · operandA  (polygon or array-like) -- First operand.  Must be a PolygonSet,
                       CellReference, CellArray, or an array.  The array may contain any  of  the
                       previous objects or an array-like[N][2] of vertices of a polygon.

                     · operandB (polygon, array-like or None) -- Second operand.  Must be None, a
                       PolygonSet, CellReference, CellArray, or an array.  The array may  contain
                       any  of  the  previous  objects  or  an  array-like[N][2] of vertices of a
                       polygon.

                     · operation ({'or',  'and',  'xor',  'not'})  --  Boolean  operation  to  be
                       executed.  The 'not' operation returns the difference operandA - operandB.

                     · precision (float) -- Desired precision for rounding vertice coordinates.

                     · max_points (integer) -- If greater than 4, fracture the resulting polygons
                       to  ensure  they  have  at  most  max_points  vertices.   This  is  not  a
                       tessellating  function, so this number should be as high as possible.  For
                       example, it should be set to 199 for polygons being drawn in GDSII files.

                     · layer (integer) -- The GDSII layer number for the resulting element.

                     · datatype (integer)  --  The  GDSII  datatype  for  the  resulting  element
                       (between 0 and 255).

              Returns
                     out -- Result of the boolean operation.

              Return type
                     PolygonSet or None

   offset
       gdspy.offset(polygons,     distance,     join='miter',    tolerance=2,    precision=0.001,
       join_first=False, max_points=199, layer=0, datatype=0)
              Shrink or expand a polygon or polygon set.

              Parameters

                     · polygons (polygon or array-like) -- Polygons to  be  offset.   Must  be  a
                       PolygonSet,  CellReference, CellArray, or an array.  The array may contain
                       any of the previous objects  or  an  array-like[N][2]  of  vertices  of  a
                       polygon.

                     · distance  (number)  --  Offset  distance.  Positive to expand, negative to
                       shrink.

                     · join ({'miter', 'bevel', 'round'}) -- Type of  join  used  to  create  the
                       offset polygon.

                     · tolerance (number) -- For miter joints, this number must be at least 2 and
                       it represents the maximun distance in  multiples  of  offset  between  new
                       vertices  and  their  original position before beveling to avoid spikes at
                       acute joints.  For round joints, it indicates the curvature resolution  in
                       number of points per full circle.

                     · precision (float) -- Desired precision for rounding vertice coordinates.

                     · join_first  (bool) -- Join all paths before offseting to avoid unnecessary
                       joins in adjacent polygon sides.

                     · max_points (integer) -- If greater than 4, fracture the resulting polygons
                       to  ensure  they  have  at  most  max_points  vertices.   This  is  not  a
                       tessellating function, so this number should be as high as possible.   For
                       example, it should be set to 199 for polygons being drawn in GDSII files.

                     · layer (integer) -- The GDSII layer number for the resulting element.

                     · datatype  (integer)  --  The  GDSII  datatype  for  the  resulting element
                       (between 0 and 255).

              Returns
                     out -- Return the offset shape as a set of polygons.

              Return type
                     PolygonSet or None

   slice
       gdspy.slice(objects, position, axis, precision=0.001, layer=0, datatype=0)
              Slice polygons and polygon sets at given positions along an axis.

              Parameters

                     · objects (PolygonSet, or list) -- Operand of the slice operation.  If  this
                       is a list, each element must be a PolygonSet, CellReference, CellArray, or
                       an array-like[N][2] of vertices of a polygon.

                     · position (number or list of numbers) -- Positions to perform  the  slicing
                       operation along the specified axis.

                     · axis (0 or 1) -- Axis along which the polygon will be sliced.

                     · precision (float) -- Desired precision for rounding vertice coordinates.

                     · layer  (integer, list) -- The GDSII layer numbers for the elements between
                       each division.  If the number of layers in  the  list  is  less  than  the
                       number of divided regions, the list is repeated.

                     · datatype  (integer)  --  The  GDSII  datatype  for  the  resulting element
                       (between 0 and 255).

              Returns
                     out -- Result of the slicing operation, with N = len(positions) +  1.   Each
                     PolygonSet  comprises  all polygons between 2 adjacent slicing positions, in
                     crescent order.

              Return type
                     list[N] of PolygonSet
              Examples.sp
              >>> ring = gdspy.Round((0, 0), 10, inner_radius = 5)
              >>> result = gdspy.slice(ring, [-7, 7], 0)
              >>> cell.add(result[1])

   inside
       gdspy.inside(points, polygons, short_circuit='any', precision=0.001)
              Test whether each of the points is within the given set of polygons.

              Parameters

                     · points (array-like[N][2] or list of array-like[N][2])  --  Coordinates  of
                       the points to be tested or groups of points to be tested together.

                     · polygons  (polygon  or array-like) -- Polygons to be tested against.  Must
                       be a PolygonSet, CellReference, CellArray, or an  array.   The  array  may
                       contain  any of the previous objects or an array-like[N][2] of vertices of
                       a polygon.

                     · short_circuit ({'any', 'all'}) -- If points is a  list  of  point  groups,
                       testing  within each group will be short-circuited if any of the points in
                       the group is inside ('any') or outside ('all') the polygons.  If points is
                       simply a list of points, this parameter has no effect.

                     · precision (float) -- Desired precision for rounding vertice coordinates.

              Returns
                     out -- Tuple of booleans indicating if each of the points or point groups is
                     inside the set of polygons.

              Return type
                     tuple

   copy
       gdspy.copy(obj, dx, dy)
              Creates a copy of obj and translates the new object to a new location.

              Parameters

                     · obj (obj) -- any translatable geometery object.

                     · dx (float) -- distance to move in the x-direction

                     · dy (float) -- distance to move in the y-direction

              Returns
                     out -- Translated copy of original obj

              Return type
                     obj
              Examples.sp
              >>> rectangle = gdspy.Rectangle((0, 0), (10, 20))
              >>> rectangle2 = gdspy.copy(rectangle, 2,0)
              >>> myCell.add(rectangle)
              >>> myCell.add(rectangle2)

GDSII LIBRARY

       gdspy is a Python module that allows the creation of GDSII stream files.

       Many features of the GDSII format are implemented, such as cell references and arrays, but
       the support for fonts is quite limited.  Text is only available through polygonal objects.

   Classes
   Cell
       class gdspy.Cell(name, exclude_from_current=False)
              Bases: object

              Collection of elements, both geometric objects and references to other cells.

              Parameters

                     · name (string) -- The name of the cell.

                     · exclude_from_current (bool) -- If True, the cell will not be automatically
                       included in the current library.

              Variables

                     · name (string) -- The name of this cell.

                     · elements (list) --  List  of  cell  elements  (PolygonSet,  CellReference,
                       CellArray).

                     · labels (list) -- List of Label.

              add(element)
                     Add a new element or list of elements to this cell.

                     Parameters
                            element  (object,  list)  --  The  element  or list of elements to be
                            inserted in this cell.

                     Returns
                            out -- This cell.

                     Return type
                            Cell

              area(by_spec=False)
                     Calculate the total area of  the  elements  on  this  cell,  including  cell
                     references and arrays.

                     Parameters
                            by_spec  (bool) -- If True, the return value is a dictionary with the
                            areas of each individual pair (layer, datatype).

                     Returns
                            out -- Area of this cell.

                     Return type
                            number, dictionary

              copy(name, exclude_from_current=False, deep_copy=False)
                     Creates a copy of this cell.

                     Parameters

                            · name (string) -- The name of the cell.

                            · exclude_from_current (bool) --  If  True,  the  cell  will  not  be
                              included in the global list of cells maintained by gdspy.

                            · deep_copy  (bool)  --  If  False,  the  new  cell will contain only
                              references to the  existing  elements.   If  True,  copies  of  all
                              elements are also created.

                     Returns
                            out -- The new copy of this cell.

                     Return type
                            Cell

              elements

              flatten(single_layer=None, single_datatype=None, single_texttype=None)
                     Flatten  all  CellReference  and  CellArray  elements in this cell into real
                     polygons and labels, instead of references.

                     Parameters

                            · single_layer (integer or None) -- If not None, all polygons will be
                              transferred to the layer indicated by this number.

                            · single_datatype (integer or None) -- If not None, all polygons will
                              be transferred to the datatype indicated by this number.

                            · single_datatype -- If not None, all labels will be  transferred  to
                              the texttype indicated by this number.

                     Returns
                            out -- This cell.

                     Return type
                            Cell

              get_bounding_box()
                     Returns the bounding box for this cell.

                     Returns
                            out -- Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or
                            None if the cell is empty.

                     Return type
                            Numpy array[2,2] or None

              get_datatypes()
                     Returns a set of datatypes in this cell.

                     Returns
                            out -- Set of the datatypes used in this cell.

                     Return type
                            set

              get_dependencies(recursive=False)
                     Returns a list of the cells included in this cell as references.

                     Parameters
                            recursive (bool) -- If True returns cascading dependencies.

                     Returns
                            out -- List of the cells referenced by this cell.

                     Return type
                            set of Cell

              get_labels(depth=None)
                     Returns a list with a copy of the labels in this cell.

                     Parameters
                            depth (integer or None)  --  If  not  None,  defines  from  how  many
                            reference levels to retrieve labels from.

                     Returns
                            out -- List containing the labels in this cell and its references.

                     Return type
                            list of Label

              get_layers()
                     Returns a set of layers in this cell.

                     Returns
                            out -- Set of the layers used in this cell.

                     Return type
                            set

              get_polygons(by_spec=False, depth=None)
                     Returns a list of polygons in this cell.

                     Parameters

                            · by_spec  (bool)  --  If True, the return value is a dictionary with
                              the polygons of each individual pair (layer, datatype).

                            · depth (integer or None) -- If  not  None,  defines  from  how  many
                              reference levels to retrieve polygons.  References below this level
                              will result in a bounding box.  If by_spec is True the key will  be
                              the name of this cell.

                     Returns
                            out  --  List  containing  the  coordinates  of  the vertices of each
                            polygon, or dictionary with the  list  of  polygons  (if  by_spec  is
                            True).

                     Return type
                            list of array-like[N][2] or dictionary

              labels

              name

              remove_labels(test)
                     Remove labels from this cell.

                     The  function or callable test is called for each label in the cell.  If its
                     return value evaluates to True, the corresponding label is removed from  the
                     cell.

                     Parameters
                            test  (callable)  -- Test function to query whether a label should be
                            removed.  The function is called with the label as the only argument.

                     Returns
                            out -- This cell.

                     Return type
                            Cell
                     Examples

                     Remove labels in layer 1:

                     >>> cell.remove_labels(lambda lbl: lbl.layer == 1)

              remove_polygons(test)
                     Remove polygons from this cell.

                     The function or callable test is called for each polygon in  the  cell.   If
                     its  return  value  evaluates  to True, the corresponding polygon is removed
                     from the cell.

                     Parameters
                            test (callable) -- Test function to query whether a polygon should be
                            removed.   The  function  is  called  with arguments: (points, layer,
                            datatype)

                     Returns
                            out -- This cell.

                     Return type
                            Cell
                     Examples

                     Remove polygons in layer 1:

                     >>> cell.remove_polygons(lambda pts, layer, datatype:
                     ...                      layer == 1)

                     Remove polygons with negative x coordinates:

                     >>> cell.remove_polygons(lambda pts, layer, datatype:
                     ...                      any(pts[:, 0] < 0))

              to_gds(multiplier, timestamp=None)
                     Convert this cell to a GDSII structure.

                     Parameters

                            · multiplier (number) -- A  number  that  multiplies  all  dimensions
                              written in the GDSII structure.

                            · timestamp  (datetime object) -- Sets the GDSII timestamp.  If None,
                              the current time is used.

                     Returns
                            out -- The GDSII binary string that represents this cell.

                     Return type
                            string

   CellReference
       class  gdspy.CellReference(ref_cell,  origin=(0,  0),  rotation=None,  magnification=None,
       x_reflection=False, ignore_missing=False)
              Bases: object

              Simple reference to an existing cell.

              Parameters

                     · ref_cell (Cell or string) -- The referenced cell or its name.

                     · origin (array-like[2]) -- Position where the reference is inserted.

                     · rotation (number) -- Angle of rotation of the reference (in degrees).

                     · magnification (number) -- Magnification factor for the reference.

                     · x_reflection  (bool) -- If True the reference is reflected parallel to the
                       x direction before being rotated.

                     · ignore_missing (bool) -- If False a warning is issued when the  referenced
                       cell is not found.

              area(by_spec=False)
                     Calculate  the  total  area  of  the  referenced cell with the magnification
                     factor included.

                     Parameters
                            by_spec (bool) -- If True, the return value is a dictionary with  the
                            areas of each individual pair (layer, datatype).

                     Returns
                            out -- Area of this cell.

                     Return type
                            number, dictionary

              get_bounding_box()
                     Returns the bounding box for this reference.

                     Returns
                            out -- Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or
                            None if the cell is empty.

                     Return type
                            Numpy array[2,2] or None

              get_labels(depth=None)
                     Returns a list of labels created by this reference.

                     Parameters
                            depth (integer or None)  --  If  not  None,  defines  from  how  many
                            reference levels to retrieve labels from.

                     Returns
                            out -- List containing the labels in this cell and its references.

                     Return type
                            list of Label

              get_polygons(by_spec=False, depth=None)
                     Returns a list of polygons created by this reference.

                     Parameters

                            · by_spec  (bool)  --  If True, the return value is a dictionary with
                              the polygons of each individual pair (layer, datatype).

                            · depth (integer or None) -- If  not  None,  defines  from  how  many
                              reference levels to retrieve polygons.  References below this level
                              will result in a bounding box.  If by_spec is True the key will  be
                              the name of the referenced cell.

                     Returns
                            out  --  List  containing  the  coordinates  of  the vertices of each
                            polygon, or dictionary with the  list  of  polygons  (if  by_spec  is
                            True).

                     Return type
                            list of array-like[N][2] or dictionary

              magnification

              origin

              ref_cell

              rotation

              to_gds(multiplier)
                     Convert this object to a GDSII element.

                     Parameters
                            multiplier  (number)  --  A  number  that  multiplies  all dimensions
                            written in the GDSII element.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the reference from one place to another

                     Parameters

                            · dx (float) -- distance to move in the x-direction

                            · dy (float) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            CellReference

              x_reflection

   CellArray
       class gdspy.CellArray(ref_cell, columns,  rows,  spacing,  origin=(0,  0),  rotation=None,
       magnification=None, x_reflection=False, ignore_missing=False)
              Bases: object

              Multiple references to an existing cell in an array format.

              Parameters

                     · ref_cell (Cell or string) -- The referenced cell or its name.

                     · columns (positive integer) -- Number of columns in the array.

                     · rows (positive integer) -- Number of columns in the array.

                     · spacing (array-like[2]) -- distances between adjacent columns and adjacent
                       rows.

                     · origin (array-like[2]) -- Position where the cell is inserted.

                     · rotation (number) -- Angle of rotation of the reference (in degrees).

                     · magnification (number) -- Magnification factor for the reference.

                     · x_reflection (bool) -- If True, the reference is reflected parallel to the
                       x direction before being rotated.

                     · ignore_missing  (bool) -- If False a warning is issued when the referenced
                       cell is not found.

              area(by_spec=False)
                     Calculate the total area of the cell array  with  the  magnification  factor
                     included.

                     Parameters
                            by_spec  (bool) -- If True, the return value is a dictionary with the
                            areas of each individual pair (layer, datatype).

                     Returns
                            out -- Area of this cell.

                     Return type
                            number, dictionary

              columns

              get_bounding_box()
                     Returns the bounding box for this reference.

                     Returns
                            out -- Bounding box of this cell [[x_min, y_min], [x_max, y_max]], or
                            None if the cell is empty.

                     Return type
                            Numpy array[2,2] or None

              get_labels(depth=None)
                     Returns a list of labels created by this reference.

                     Parameters
                            depth  (integer  or  None)  --  If  not  None,  defines from how many
                            reference levels to retrieve labels from.

                     Returns
                            out -- List containing the labels in this cell and its references.

                     Return type
                            list of Label

              get_polygons(by_spec=False, depth=None)
                     Returns a list of polygons created by this reference.

                     Parameters

                            · by_spec (bool) -- If True, the return value is  a  dictionary  with
                              the polygons of each individual pair (layer, datatype).

                            · depth  (integer  or  None)  --  If  not None, defines from how many
                              reference levels to retrieve polygons.  References below this level
                              will  result in a bounding box.  If by_spec is True the key will be
                              name of the referenced cell.

                     Returns
                            out -- List containing  the  coordinates  of  the  vertices  of  each
                            polygon,  or  dictionary  with  the  list  of polygons (if by_spec is
                            True).

                     Return type
                            list of array-like[N][2] or dictionary

              magnification

              origin

              ref_cell

              rotation

              rows

              spacing

              to_gds(multiplier)
                     Convert this object to a GDSII element.

                     Parameters
                            multiplier (number)  --  A  number  that  multiplies  all  dimensions
                            written in the GDSII element.

                     Returns
                            out -- The GDSII binary string that represents this object.

                     Return type
                            string

              translate(dx, dy)
                     Move the reference from one place to another

                     Parameters

                            · dx (float) -- distance to move in the x-direction

                            · dy (float) -- distance to move in the y-direction

                     Returns
                            out -- This object.

                     Return type
                            CellArray

              x_reflection

   GdsLibrary
       class gdspy.GdsLibrary(name='library', infile=None, unit=1e-06, precision=1e-09, **kwargs)
              Bases: object

              GDSII library (file).

              Represent a GDSII library containing a dictionary of cells.

              Parameters

                     · name  (string) -- Name of the GDSII library.  Ignored if a name is defined
                       in infile.

                     · infile (file or string) -- GDSII stream file (or path) to be imported.  It
                       must be opened for reading in binary format.

                     · kwargs (keyword arguments) -- Arguments passed to read_gds.

              Variables

                     · name (string) -- Name of the GDSII library.

                     · cell_dict  (dictionary) -- Dictionary of cells in this library, indexed by
                       name.

                     · 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).

              add(cell, overwrite_duplicate=False)
                     Add one or more cells to the library.

                     Parameters

                            · cell (Cell of list of Cell) -- Cells to be included in the library.

                            · overwrite_duplicate  (bool)  --  If  True an existing cell with the
                              same name in the library will be overwritten.

                     Returns
                            out -- This object.

                     Return type
                            GdsLibrary

              extract(cell)
                     Extract a cell from the this GDSII file and include it in the current global
                     library, including referenced dependencies.

                     Parameters
                            cell  (Cell  or  string)  -- Cell or name of the cell to be extracted
                            from the imported  file.   Referenced  cells  will  be  automatically
                            extracted as well.

                     Returns
                            out -- The extracted cell.

                     Return type
                            Cell

              read_gds(infile, units='skip', rename={}, layers={}, datatypes={}, texttypes={})
                     Read a GDSII file into this library.

                     Parameters

                            · infile  (file  or  string)  --  GDSII  stream  file (or path) to be
                              imported.  It must be opened for reading in binary format.

                            · units ({'convert', 'import', 'skip'}) -- Controls how to scale  and
                              use  the  units  in  the  imported  file.   'convert': the imported
                              geometry is scaled to this library units. 'import':  the  unit  and
                              precision  in  this library are replaced by those from the imported
                              file.  'skip': the imported geometry is not scaled  and  units  are
                              not  replaced;  the  geometry  is imported in the user units of the
                              file.

                            · rename (dictionary) --  Dictionary  used  to  rename  the  imported
                              cells.  Keys and values must be strings.

                            · layers (dictionary) -- Dictionary used to convert the layers in the
                              imported cells.  Keys and values must be integers.

                            · datatypes (dictionary) -- Dictionary used to convert the  datatypes
                              in the imported cells.  Keys and values must be integers.

                            · texttypes (dictionary) -- Dictionary used to convert the text types
                              in the imported cells.  Keys and values must be integers.

                     Returns
                            out -- This object.

                     Return type
                            GdsLibrary
                     Notes

                     Not all features from the GDSII specification are  currently  supported.   A
                     warning  will  be  produced  if  any  unsupported  features are found in the
                     imported file.

              top_level()
                     Output the top level cells from the GDSII data.

                     Top level cells are those that are not referenced by any other cells.

                     Returns
                            out -- List of top level cells.

                     Return type
                            list

              write_gds(outfile, cells=None, timestamp=None)
                     Write the GDSII library to a file.

                     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-6  (1  um)  and
                     precision=1.0e-9  (1  nm),  the  radius of the circle will be 1.5 um and the
                     GDSII file will contain the dimension 1500 nm.

                     Parameters

                            · outfile (file or string) -- The file  (or  path)  where  the  GDSII
                              stream  will  be written.  It must be opened for writing operations
                              in binary format.

                            · cells (array-like) -- The  list  of  cells  or  cell  names  to  be
                              included in the library.  If None, all cells are used.

                            · timestamp  (datetime object) -- Sets the GDSII timestamp.  If None,
                              the current time is used.
                     Notes

                     Only the specified cells are written.  The user is responsible for  ensuring
                     all cell dependencies are satisfied.

   GdsWriter
       class     gdspy.GdsWriter(outfile,     name='library',     unit=1e-06,    precision=1e-09,
       timestamp=None)
              Bases: object

              GDSII strem library writer.

              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-6 (1 um) and  precision=1.0e-9  (1  nm),
              the  radius  of  the  circle  will  be  1.5  um and the GDSII file will contain the
              dimension 1500 nm.

              Parameters

                     · outfile (file or string) -- The file (or path) where the GDSII stream will
                       be written.  It must be opened for writing operations in binary format.

                     · 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).

                     · timestamp (datetime object) -- Sets the GDSII  timestamp.   If  None,  the
                       current time is used.
              Notes

              This  class can be used for incremental output of the geometry in case the complete
              layout is too large to be kept in memory all at once.  Examples.sp
              >>> writer = gdspy.GdsWriter('out-file.gds', unit=1.0e-6,
              ...                          precision=1.0e-9)
              >>> for i in range(10):
              ...     cell = gdspy.Cell('C{}'.format(i), True)
              ...     # Add the contents of this cell...
              ...     writer.write_cell(cell)
              ...     # Clear the memory: erase Cell objects and any other objects
              ...     # that won't be needed.
              ...     del cell
              >>> writer.close()

              close()
                     Finalize the GDSII stream library.

              write_cell(cell)
                     Write the specified cell to the file.

                     Parameters
                            cell (Cell) -- Cell to be written.
                     Notes

                     Only the specified cell is written.  Dependencies must be manually included.

                     Returns
                            out -- This object.

                     Return type
                            GdsWriter

   LayoutViewer
   Functions
   write_gds
       gdspy.write_gds(outfile, cells=None, name='library', unit=1e-06, precision=1e-09)
              Write the current GDSII library to a file.

              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-6 (1 um) and  precision=1.0e-9  (1  nm),
              the  radius  of  the  circle  will  be  1.5  um and the GDSII file will contain the
              dimension 1500 nm.

              Parameters

                     · outfile (file or string) -- The file (or path) where the GDSII stream will
                       be written.  It must be opened for writing operations in binary format.

                     · cells  (array-like)  --  The list of cells or cell names to be included in
                       the library.  If None, all cells are used.

                     · name (string) -- Name of the GDSII library.

                     · 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).

   gdsii_hash
       gdspy.gdsii_hash(filename, engine=None)
              Calculate the a hash value for a GDSII file.

              The hash is generated based only on the contents of the cells in the GDSII library,
              ignoring any timestamp records present in the file structure.

              Parameters

                     · filename (string) -- Full path to the GDSII file.

                     · engine (hashlib-like engine) --  The  engine  that  executes  the  hashing
                       algorithm.  It must provide the methods update and hexdigest as defined in
                       the hashlib module.  If None, the default hashlib.sha1() is used.

              Returns
                     out -- The hash corresponding to the library contents in hex format.

              Return type
                     string

   Attributes
       gdspy.current_library = <gdspy.GdsLibrary object>
              Current GdsLibrary instance for automatic creation of GDSII files.

              This variable can be freely  overwritten  by  the  user  with  a  new  instance  of
              GdsLibrary.

SUPPORT

       Help support the development of gdspy by donating:

       Click here

AUTHOR

       Lucas H. Gabrielli

COPYRIGHT

       2009-2018, Lucas H. Gabrielli