コード例 #1
0
def mask_merge(label_layer) -> None:
    """merge JSON/Markdown from build/devices into build/mask"""

    gdspath = CONFIG["mask_gds"]
    write_labels(gdspath=gdspath, label_layer=label_layer)

    merge_json()
    merge_markdown()
    merge_test_metadata(gdspath=gdspath)
コード例 #2
0
ファイル: test_mask.py プロジェクト: tvt173/gdsfactory
def test_mask(
    precision: float = 1e-9,
    labels_prefix: str = "opt",
    layer_label: Tuple[int, int] = layer_label,
) -> Component:
    """Returns mask."""
    workspace_folder = CONFIG["samples_path"] / "mask_pack"
    build_path = workspace_folder / "build"
    mask_path = build_path / "mask"

    shutil.rmtree(build_path, ignore_errors=True)
    mask_path.mkdir(parents=True, exist_ok=True)

    gdspath = mask_path / "sample_mask.gds"
    # markdown_path = gdspath.with_suffix(".md")
    # json_path = gdspath.with_suffix(".json")
    # test_metadata_path = gdspath.with_suffix(".tp.json")

    components = [
        spiral_te(length=length) for length in np.array([2, 4, 6]) * 1e4
    ]
    components += [
        coupler_te(length=length, gap=0.2) for length in [10, 20, 30, 40]
    ]
    c = gf.pack(components)
    m = c[0]
    m.name = "sample_mask"
    m.write_gds_with_metadata(gdspath)

    csvpath = write_labels(gdspath=gdspath,
                           prefix=labels_prefix,
                           label_layer=layer_label)
    assert gdspath.exists()
    assert csvpath.exists()
    return m
コード例 #3
0
def merge_metadata(
    gdspath: Path,
    labels_prefix: str = "opt",
    layer_label: Tuple[int, int] = gf.LAYER.TEXT,
) -> DictConfig:
    """Merges all mask metadata and returns test metadata
    This function works well only when you define the mask in YAML
    Exports a YAML file with only the cells information that have a valid test and measurement label

    For the cells that need to be measure we add test labels

    This is the automatic version of write_labels combined with merge_test_metadata

    .. code::

        CSV labels  -------
                          |--> merge_test_metadata dict
                          |
        YAML metatada  ----


    Args:
        gdspath: GDSpath
        labels_prefix
        layer_label: layer for the labels
    """
    mdpath = gdspath.with_suffix(".md")
    yaml_path = gdspath.with_suffix(".yml")
    test_metadata_path = gdspath.with_suffix(".tp.yml")

    build_directory = gdspath.parent.parent
    doe_directory = build_directory / "cache_doe"

    labels_path = write_labels(gdspath=gdspath,
                               prefix=labels_prefix,
                               layer_label=layer_label)

    # jsonpath = gdspath.with_suffix(".yml")
    # merge_json(doe_directory=doe_directory, jsonpath=jsonpath, **kwargs)

    mask_metadata = merge_yaml(doe_directory=doe_directory,
                               yaml_path=yaml_path)
    merge_markdown(reports_directory=doe_directory, mdpath=mdpath)
    tm = merge_test_metadata(
        labels_prefix=labels_prefix,
        mask_metadata=mask_metadata,
        labels_path=labels_path,
    )

    test_metadata_path.write_text(OmegaConf.to_yaml(tm))
    return tm
コード例 #4
0
def merge_metadata(
    gdspath: Path,
    labels_prefix: str = "opt",
    label_layer: Tuple[int, int] = gf.LAYER.LABEL,
    **kwargs
) -> None:
    """Merges all JSON metadata into a big JSON.

    Args:
        gdspath: GDSpath
        labels_prefix
        label_layer: layer for the labels
    """
    mdpath = gdspath.with_suffix(".md")
    jsonpath = gdspath.with_suffix(".json")

    build_directory = gdspath.parent.parent
    doe_directory = build_directory / "doe"

    write_labels(gdspath=gdspath, prefix=labels_prefix, label_layer=label_layer)

    merge_json(doe_directory=doe_directory, jsonpath=jsonpath, **kwargs)
    merge_markdown(reports_directory=doe_directory, mdpath=mdpath)
    merge_test_metadata(gdspath, labels_prefix=labels_prefix)
コード例 #5
0
def write_mask_labels(gdspath: str, label_layer) -> None:
    """Find test and measurement labels."""
    if gdspath is None:
        gdspath = CONFIG["mask_gds"]

    write_labels(gdspath=gdspath, label_layer=label_layer)