Device analysis

Now we will run an FSR analysis on the device data we uploaded in the previous notebook.

As before, make sure you have the following environment variables set or added to a .env file:

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 tqdm.auto import tqdm

import gdsfactoryhub as gfh
project_id = f"rings-{getpass.getuser()}"
client = gfh.create_client_from_env(project_id=project_id)
api = client.api()
query = client.query()

Device analysis

You can either trigger analysis automatically by defining it in the design manifest, using the UI or using the Python DoData library.

from gdsfactoryhub.functions.device_data import fsr

fsr.run?

You can easily get a device pkey to try your device analysis:

device_data_pkey = query.device_data().execute().data[0]["pk"]
fsr.run(
    device_data_pkey,
    xname="wavelength",
    yname="output_power",
    peaks_prominence=0.01,
);
result = api.validate_function(
    function_id="fsr",
    target_model="device_data",
    test_target_model_pk=device_data_pkey,
    file=gfh.get_module_path(fsr),
    test_kwargs={
        "xname": "wavelength",
        "yname": "output_power",
        "peaks_prominence": 0.01,
    },
)
result.summary_plot()
with gfh.suppress_api_error():  # don't error out when function already exists in DoData.
    result = api.upload_function(
        function_id="fsr",
        target_model="device_data",
        file=gfh.get_module_path(fsr),
    )

Trigger all analyses for all device data

task_ids = []
dd_pks = [d["pk"] for d in query.device_data().execute().data]
for dd_pk in tqdm(dd_pks):
    with gfh.suppress_api_error():
        task_id = api.start_analysis(  # start_analysis triggers the analysis task, but does not wait for it to finish.
            analysis_id=f"device_fsr_{dd_pk}",
            function_id="fsr",
            target_model="device_data",
            target_model_pk=dd_pk,
            kwargs={
                "xname": "wavelength",
                "yname": "output_power",
                "peaks_prominence": 0.01,
            },
        )
        task_ids.append(task_id)
# this cell waits for the last triggered analysis to finish.
# please only continue with the die analysis notebook after this cell ran.
result = api.wait_for_result(task_ids[-1])
result.summary_plot()
On This Page