How to use the gdspy.RobustPath function in gdspy

To help you get started, we’ve selected a few gdspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github heitzmann / gdspy / tests / robustpath.py View on Github external
rp.arc(2, 0.4 * numpy.pi, -0.4 * numpy.pi, [0.1, 0.2, 0.1], [0.2, 0, -0.2])
    rp.turn(1, -0.3 * numpy.pi)
    rp.turn(1, "rr", 0.15)
    rp.turn(0.5, "l", [0.05, 0.1, 0.05], [0.15, 0, -0.15])
    assert len(rp) == 10
    cell.add(rp)
    rp = gdspy.RobustPath((-5, 6), 0.8, layer=20, ends="round", tolerance=1e-4)
    rp.segment((1, 1), 0.1, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-5, 6), 0.8, layer=21, ends="extended", tolerance=1e-4)
    rp.segment((1, 1), 0.1, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-5, 6), 0.8, layer=22, ends=(0.1, 0.2), tolerance=1e-4)
    rp.segment((1, 1), 0.1, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-5, 6), 0.8, layer=23, ends="smooth", tolerance=1e-4)
    rp.segment((1, 1), 0.1, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-3, 6), 0.8, layer=10, ends="round", tolerance=1e-5)
    rp.segment((1, 0), 0.1, relative=True)
    rp.segment((0, 1), 0.8, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-3, 6), 0.8, layer=11, ends="extended", tolerance=1e-5)
    rp.segment((1, 0), 0.1, relative=True)
    rp.segment((0, 1), 0.8, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-3, 6), 0.8, layer=12, ends="smooth", tolerance=1e-5)
    rp.segment((1, 0), 0.1, relative=True)
    rp.segment((0, 1), 0.8, relative=True)
    cell.add(rp)
    rp = gdspy.RobustPath((-3, 8), 0.1, layer=13, ends="round", tolerance=1e-5)
    rp.segment((1, 0), 0.8, relative=True)
github heitzmann / gdspy / tests / robustpath.py View on Github external
rp.bezier([(-3, 0), (-2, -3), (0, -4), (0, -5)], offset=[-0.2, 0, 0.2])
    rp.bezier(
        [(4.5, 0), (1, -1), (1, 5), (3, 2), (5, 2)],
        width=[0.05, 0.1, 0.2],
        offset=[-0.2, 0, 0.4],
        relative=False,
    )
    cell.add(rp)
    rp = gdspy.RobustPath((2, -1), 0.1, layer=7, tolerance=1e-4, max_points=0)
    rp.smooth(
        [(1, 0), (1, -1), (0, -1)],
        angles=[numpy.pi / 3, None, -2 / 3.0 * numpy.pi, None],
        cycle=True,
    )
    cell.add(rp)
    rp = gdspy.RobustPath((2.5, -1.5), 0.1, layer=8)
    rp.smooth(
        [(3, -1.5), (4, -2), (5, -1), (6, -2), (7, -1.5), (7.5, -1.5)],
        relative=False,
        width=0.2,
    )
    cell.add(rp)
    assertsame(target["RobustPath2"], cell)
github heitzmann / gdspy / tests / robustpath.py View on Github external
def test_robustpath_gdsiipath():
    cells = []
    for gdsii_path in [True, False]:
        cells.append(gdspy.Cell(str(gdsii_path)))
        rp = gdspy.RobustPath(
            (0, 0),
            0.05,
            [-0.1, 0.1],
            ends=["extended", (0.1, 0.2)],
            layer=[0, 1],
            gdsii_path=gdsii_path,
        )
        rp.segment((1, 1))
        rp.parametric(lambda u: numpy.array((u, u - u ** 2)))
        cells[-1].add(rp)
    assertsame(*cells)
github heitzmann / gdspy / tools / maketestgds.py View on Github external
rp.segment((1, 0), 0.1, relative=True)
rp.segment((0, 1), 0.8, relative=True)
cell.add(rp)
rp = gdspy.RobustPath((-3, 6), 0.8, layer=12, ends="smooth", tolerance=1e-5)
rp.segment((1, 0), 0.1, relative=True)
rp.segment((0, 1), 0.8, relative=True)
cell.add(rp)
rp = gdspy.RobustPath((-3, 8), 0.1, layer=13, ends="round", tolerance=1e-5)
rp.segment((1, 0), 0.8, relative=True)
rp.segment((0, 1), 0.1, relative=True)
cell.add(rp)
rp = gdspy.RobustPath((-3, 8), 0.1, layer=14, ends=(0.2, 0.2), tolerance=1e-5)
rp.segment((1, 0), 0.8, relative=True)
rp.segment((0, 1), 0.1, relative=True)
cell.add(rp)
rp = gdspy.RobustPath((-3, 8), 0.1, layer=15, ends="smooth", tolerance=1e-5)
rp.segment((1, 0), 0.8, relative=True)
rp.segment((0, 1), 0.1, relative=True)
cell.add(rp)
rp = gdspy.RobustPath((5, 2), [0.05, 0.1, 0.2], [-0.2, 0, 0.4], layer=[4, 5, 6])
rp.parametric(lambda u: numpy.array((5.5 + 3 * u, 2 + 3 * u ** 2)), relative=False)
rp.segment((0, 1), relative=True)
rp.parametric(
    lambda u: numpy.array(
        (2 * numpy.cos(0.5 * numpy.pi * u) - 2, 3 * numpy.sin(0.5 * numpy.pi * u))
    ),
    width=[0.2, 0.1, 0.05],
    offset=[-0.3, 0, 0.3],
)
rp.parametric(lambda u: numpy.array((-2 * u, 0)), width=0.1, offset=0.2)
rp.bezier([(-3, 0), (-2, -3), (0, -4), (0, -5)], offset=[-0.2, 0, 0.2])
rp.bezier(
github heitzmann / gdspy / tools / maketestgds.py View on Github external
[(1, 0), (1, -1), (0, -1)],
    angles=[numpy.pi / 3, None, -2 / 3.0 * numpy.pi, None],
    cycle=True,
)
cell.add(rp)
rp = gdspy.RobustPath((2.5, -1.5), 0.1, layer=8)
rp.smooth(
    [(3, -1.5), (4, -2), (5, -1), (6, -2), (7, -1.5), (7.5, -1.5)],
    relative=False,
    width=0.2,
)
cell.add(rp)

cell = lib.new_cell("RobustPath3")

rp = gdspy.RobustPath((0, 0), 0.1)
rp.parametric(
    lambda u: numpy.array((3 * numpy.sin(numpy.pi * u), -3 * numpy.cos(numpy.pi * u))),
    relative=False,
)
rp.parametric(
    lambda u: numpy.array(
        (3.5 - 3 * numpy.cos(numpy.pi * u), -0.5 + 3 * numpy.sin(numpy.pi * u))
    ),
    lambda u: numpy.array((numpy.sin(numpy.pi * u), numpy.cos(numpy.pi * u))),
    relative=True,
)
cell.add(rp)

cell = lib.new_cell("RobustPath4")

rp = gdspy.FlexPath([(0, 0)], [2, 1, 1], 5)
github heitzmann / gdspy / tests / robustpath.py View on Github external
cell = gdspy.Cell("test")
    rp = gdspy.RobustPath((0, 0), 0.1, layer=[1], gdsii_path=True)
    rp.segment((1, 1))
    cell.add(rp)
    rp = gdspy.RobustPath(
        (1, 0),
        0.1,
        [-0.1, 0.1],
        tolerance=1e-5,
        ends=["round", "extended"],
        layer=[2, 3],
        max_points=6,
    )
    rp.segment((2, 1))
    cell.add(rp)
    rp = gdspy.RobustPath(
        (2, 0), [0.1, 0.2], 0.2, ends=(0.2, 0.1), layer=4, datatype=[1, 1]
    )
    rp.segment((3, 1))
    cell.add(rp)
    rp = gdspy.RobustPath(
        (3, 0),
        [0.1, 0.2, 0.1],
        [-0.2, 0, 0.2],
        ends=[(0.2, 0.1), "smooth", "flush"],
        datatype=5,
    )
    rp.segment((4, 1))
    cell.add(rp)
    assertsame(target["RobustPath1"], cell)
github heitzmann / gdspy / tools / maketestgds.py View on Github external
rp.bezier([(-3, 0), (-2, -3), (0, -4), (0, -5)], offset=[-0.2, 0, 0.2])
rp.bezier(
    [(4.5, 0), (1, -1), (1, 5), (3, 2), (5, 2)],
    width=[0.05, 0.1, 0.2],
    offset=[-0.2, 0, 0.4],
    relative=False,
)
cell.add(rp)
rp = gdspy.RobustPath((2, -1), 0.1, layer=7, tolerance=1e-4, max_points=0)
rp.smooth(
    [(1, 0), (1, -1), (0, -1)],
    angles=[numpy.pi / 3, None, -2 / 3.0 * numpy.pi, None],
    cycle=True,
)
cell.add(rp)
rp = gdspy.RobustPath((2.5, -1.5), 0.1, layer=8)
rp.smooth(
    [(3, -1.5), (4, -2), (5, -1), (6, -2), (7, -1.5), (7.5, -1.5)],
    relative=False,
    width=0.2,
)
cell.add(rp)

cell = lib.new_cell("RobustPath3")

rp = gdspy.RobustPath((0, 0), 0.1)
rp.parametric(
    lambda u: numpy.array((3 * numpy.sin(numpy.pi * u), -3 * numpy.cos(numpy.pi * u))),
    relative=False,
)
rp.parametric(
    lambda u: numpy.array(
github heitzmann / gdspy / tests / robustpath.py View on Github external
def test_robustpath1(target):
    cell = gdspy.Cell("test")
    rp = gdspy.RobustPath((0, 0), 0.1, layer=[1], gdsii_path=True)
    rp.segment((1, 1))
    cell.add(rp)
    rp = gdspy.RobustPath(
        (1, 0),
        0.1,
        [-0.1, 0.1],
        tolerance=1e-5,
        ends=["round", "extended"],
        layer=[2, 3],
        max_points=6,
    )
    rp.segment((2, 1))
    cell.add(rp)
    rp = gdspy.RobustPath(
        (2, 0), [0.1, 0.2], 0.2, ends=(0.2, 0.1), layer=4, datatype=[1, 1]
    )
github heitzmann / gdspy / tools / maketestgds.py View on Github external
(1, 0),
    0.1,
    [-0.1, 0.1],
    tolerance=1e-5,
    ends=["round", "extended"],
    layer=[2, 3],
    max_points=6,
)
rp.segment((2, 1))
cell.add(rp)
rp = gdspy.RobustPath(
    (2, 0), [0.1, 0.2], 0.2, ends=(0.2, 0.1), layer=4, datatype=[1, 1]
)
rp.segment((3, 1))
cell.add(rp)
rp = gdspy.RobustPath(
    (3, 0),
    [0.1, 0.2, 0.1],
    [-0.2, 0, 0.2],
    ends=[(0.2, 0.1), "smooth", "flush"],
    datatype=5,
)
rp.segment((4, 1))
cell.add(rp)

cell = lib.new_cell("RobustPath2")

rp = gdspy.RobustPath((0, 0), [0.1, 0.2, 0.1], 0.15, layer=[1, 2, 3])
rp.segment((1, 0))
rp.segment((1, 1), 0.1, 0.05)
rp.segment((1, 1), [0.2, 0.1, 0.1], -0.05, True)
rp.segment((-1, 1), 0.2, [-0.2, 0, 0.3], True)
github heitzmann / gdspy / docs / makeimages.py View on Github external
draw(gdspy.Cell("flexible_paths_1").add(sp3))

    # Flexible Paths 2
    # Path created with automatic bends of radius 5
    points = [(0, 0), (0, 10), (20, 0), (18, 15), (8, 15)]
    sp4 = gdspy.FlexPath(
        points, 0.5, corners="circular bend", bend_radius=5, gdsii_path=True
    )

    # Same path, generated with natural corners, for comparison
    sp5 = gdspy.FlexPath(points, 0.5, layer=1, gdsii_path=True)
    draw(gdspy.Cell("flexible_paths_2").add([sp4, sp5]))

    # Robust Paths
    # Create 4 parallel paths in different layers
    lp = gdspy.RobustPath(
        (50, 0),
        [2, 0.5, 1, 1],
        [0, 0, -1, 1],
        ends=["extended", "round", "flush", "flush"],
        layer=[0, 2, 1, 1],
    )
    lp.segment((45, 0))
    lp.segment(
        (5, 0),
        width=[lambda u: 2 + 16 * u * (1 - u), 0.5, 1, 1],
        offset=[
            0,
            lambda u: 8 * u * (1 - u) * numpy.cos(12 * numpy.pi * u),
            lambda u: -1 - 8 * u * (1 - u),
            lambda u: 1 + 8 * u * (1 - u),
        ],