def check_width(gdspath,
                layer: Tuple[int, int] = (1, 0),
                min_width: float = 0.150,
                dbu: float = 1e3):
    """Reads layer from top cell and returns a number of edges violating min width

    Args:
        gdspath: path to GDS or Component
        layer: tuple (int, int)
        min_width: in um
        dbu: database units (1000 um/nm)
    """
    from pp.component import Component
    from pp.write_component import write_gds

    if isinstance(gdspath, Component):
        gdspath.flatten()
        gdspath = write_gds(gdspath)
    layout = pya.Layout()
    layout.read(str(gdspath))
    cell = layout.top_cell()
    region = pya.Region(cell.begin_shapes_rec(layout.layer(layer[0],
                                                           layer[1])))
    # print(region)
    # print(min_width*1e3)
    return len(region.width_check(min_width * dbu))
Beispiel #2
0
def save_doe(doe_name, components, doe_root_path=None, precision=1e-9):
    """
    Save all components from this DOE in a tmp cache folder
    """
    if doe_root_path is None:
        doe_root_path = CONFIG["cache_doe_directory"]
    doe_dir = os.path.join(doe_root_path, doe_name)
    if not os.path.exists(doe_dir):
        os.makedirs(doe_dir)

    # Store list of component names - order matters
    component_names = [c.name for c in components]
    content_file = os.path.join(doe_dir, "content.txt")
    with open(content_file, "w") as fw:
        fw.write(CONTENT_SEP.join(component_names))

    for c in components:
        gdspath = os.path.join(doe_dir, c.name + ".gds")
        write_gds(c, gdspath=gdspath, precision=precision)
        write_component_report(c, json_path=gdspath[:-4] + ".json")
Beispiel #3
0
def save_doe(doe_name,
             components,
             doe_root_path=CONFIG["cache_doe_directory"],
             precision=1e-9):
    """
    Save all components from this DOE in a tmp cache folder
    """
    doe_dir = pathlib.Path(doe_root_path) / doe_name
    doe_dir.mkdir(parents=True, exist_ok=True)

    # Store list of component names - order matters
    component_names = [c.name for c in components]
    content_file = doe_dir / "content.txt"
    with open(content_file, "w") as fw:
        fw.write(CONTENT_SEP.join(component_names))

    for c in components:
        gdspath = doe_dir / f"{c.name}.gds"
        write_gds(c, gdspath=gdspath, precision=precision)
        write_component_report(c, json_path=gdspath.with_suffix(".json"))
def check_inclusion(
    gdspath,
    layer_in=(1, 0),
    layer_out=(2, 0),
    min_inclusion=0.150,
    dbu=1e3,
    ignore_angle_deg=80,
    whole_edges=False,
    metrics=None,
    min_projection=None,
    max_projection=None,
):
    """reads layer from top cell and returns a the area that violates min inclusion
    if 0 no area violates exclusion

    Args:
        gdspath: path to GDS
        layer_in: tuple
        layer_out: tuple
        min_inclusion: in um
        dbu: database units (1000 um/nm)
        ignore_angle_deg: The angle above which no check is performed
        other: The other region against which to check
        whole_edges: If true, deliver the whole edges
        metrics: Specify the metrics type
        min_projection The lower threshold of the projected length of one edge onto another
        max_projection The upper limit of the projected length of one edge onto another
    """
    from pp.component import Component
    from pp.write_component import write_gds

    if isinstance(gdspath, Component):
        gdspath.flatten()
        gdspath = write_gds(gdspath)
    layout = pya.Layout()
    layout.read(str(gdspath))
    cell = layout.top_cell()
    a = pya.Region(
        cell.begin_shapes_rec(layout.layer(layer_in[0], layer_in[1])))
    b = pya.Region(
        cell.begin_shapes_rec(layout.layer(layer_out[0], layer_out[1])))

    d = b.inside_check(
        a,
        min_inclusion * dbu,
        whole_edges,
        metrics,
        ignore_angle_deg,
        min_projection,
        max_projection,
    )
    return d.polygons().area()
Beispiel #5
0
def remove_empty_cells_from_gds_file(gdspath):
    gds = import_gds(gdspath)
    remove_empty_cells(gds)
    write_gds(gds, gdspath[:-4] + "_cleaned.gds")
def check_space(
    gdspath,
    layer: Tuple[int, int] = (1, 0),
    min_space: float = 0.150,
    dbu: float = 1e3,
    ignore_angle_deg: int = 80,
    whole_edges: bool = False,
    metrics=None,
    min_projection=None,
    max_projection=None,
) -> int:
    """Reads layer from top cell and returns a the area that violates min space.

    If "whole_edges" is true, the resulting EdgePairs collection will receive the whole edges which contribute in the space check.

    "metrics" can be one of the constants Euclidian, Square or Projection. See there for a description of these constants.
    Use nil for this value to select the default (Euclidian metrics).

    "ignore_angle" specifies the angle limit of two edges. If two edges form an angle equal or above the given value, they will not contribute in
    the check. Setting this value to 90 (the default) will exclude edges with an angle of 90 degree or more from the check.
    Use nil for this value to select the default.

    "min_projection" and "max_projection" allow selecting edges by their projected value upon each other. It is sufficient if the projection of on
    e edge on the other matches the specified condition. The projected length must be larger or equal to "min_projection" and less than "max_proje
    ction". If you don't want to specify one limit, pass nil to the respective value.

    Args:
        gdspath: path to GDS or Component
        layer: tuple
        min_space: in um
        dbu: database units (1000 um/nm)
        ignore_angle_deg: The angle above which no check is performed
        other: The other region against which to check
        whole_edges: If true, deliver the whole edges
        metrics: Specify the metrics type
        min_projection The lower threshold of the projected length of one edge onto another
        max_projection The upper limit of the projected length of one edge onto another

    """
    from pp.component import Component
    from pp.write_component import write_gds

    if isinstance(gdspath, Component):
        gdspath.flatten()
        gdspath = write_gds(gdspath)
    layout = pya.Layout()
    layout.read(str(gdspath))
    cell = layout.top_cell()
    region = pya.Region(cell.begin_shapes_rec(layout.layer(layer[0],
                                                           layer[1])))

    d = region.space_check(
        min_space * dbu,
        whole_edges,
        metrics,
        ignore_angle_deg,
        min_projection,
        max_projection,
    )
    # print(d.polygons().area())
    return d.polygons().area()