Upload Measurement Data and run Analysis

Now you will post your measurement data and analysis to the database via the API.

You will need to authenticate to the database with your username and password. To make this easy, you can create a file called .env in this folder and complete it with your organization's URL and authentication information as follows:

GDSFACTORY_HUB_API_URL="https://{org}.gdsfactoryhub.com"
GDSFACTORY_HUB_QUERY_URL="https://query.{org}.gdsfactoryhub.com"
GDSFACTORY_HUB_KEY="<your-gdsfactoryplus-api-key>"
import getpass
from pathlib import Path

import pandas as pd
from tqdm.auto import tqdm

import gdsfactoryhub as gfh

New project

You can create the project, upload the design manifest, and upload the wafer definitions through the Webapp as well as programmatically using this notebook

project_id = f"spirals-{getpass.getuser()}"
client = gfh.create_client_from_env(project_id=project_id)
api = client.api()
query = client.query()

Let's now create a project.

In normal circumstances, everyone will be sharing and contributing to a project. In this demo, however, we want to keep your project separate from other users for clarity, so we will append your username to the project name. This way you can also safely delete and recreate projects without creating issues for others. If you prefer though, you can change the project_id to anything you like. Just be sure to update it in the subsequent notebooks of this tutorial as well.

Lets delete the project if it already exists so that you can start fresh.

api.delete_project()

Upload Project

You can create a new project and extract all cells & devices below for the cutback_rib spirals.

The expressions are regex expressions. For intro and testing your regexes you can check out regex101

project = api.create_project(
    eda_layout_file=Path("test_chip.gds").resolve(),
    extraction_rules=[
        gfh.ExtractionRule(cell_name="rib_loss", include_patterns=["cutback_rib.*"]),
        gfh.ExtractionRule(cell_name="ridge_loss", include_patterns=["cutback_ridge.*"]),
    ],
)

Upload Design Manifest.

The design manifest is a CSV file that includes all the cell names, the cell settings, a list of analysis to trigger, and a list of settings for each analysis.

dm = pd.read_csv("design_manifest.csv")
dm
dm = dm.drop(columns=["analysis", "analysis_parameters"])
dm
dm.to_csv("design_manifest_without_analysis.csv", index=False)
api.upload_design_manifest(design_attributes_file="design_manifest_without_analysis.csv")
api.download_design_manifest(file_path="design_manifest_downloaded.csv");
pd.read_csv("design_manifest_downloaded.csv");

Upload Wafer Definitions

The wafer definition is a JSON file where you can define the wafer names and die names and location for each wafer.

api.upload_wafer_definitions(wafer_definitions_file="wafer_definitions.json")

Upload data

You can get all paths which have measurement data within the test path.

data_files = list(Path("wafers").resolve().glob("**/data.parquet"))
len(data_files)

Upload measurements

You can now upload measurement data.

This is a bare bones example, in a production setting, you can also add validation, logging, and error handling to ensure a smooth operation.

Every measurement you upload will trigger all the analysis that you defined in the design manifest.

for path in (pb := tqdm(data_files)):
    wafer_id = path.parts[-4]
    die_x, die_y = path.parts[-3].split("_")
    device_id = path.parts[-2]
    pb.set_postfix(wafer_id=wafer_id, die=f"({die_x},{die_y})", device_id=device_id)
    device_data = api.add_measurement(
        device_id=device_id,
        data_file=path,
        wafer_id=wafer_id,
        die_x=die_x,
        die_y=die_y,
        plot_spec=gfh.MatplotlibPlotSpec(
            x_name="wavelength",
            y_name="output_power",
            x_col="wavelength",
            y_col=["output_power"],
        ),
    )
On This Page