From 6d016ad567e971dbe65b8bdc04f211aaebc63358 Mon Sep 17 00:00:00 2001 From: Joaquin Matres <4514346+joamatab@users.noreply.github.com> Date: Fri, 19 Jul 2024 10:06:13 -0400 Subject: [PATCH 1/3] fixed plot_model xlabel --- gplugins/sax/plot_model.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gplugins/sax/plot_model.py b/gplugins/sax/plot_model.py index d7e4d1cd..950a20f3 100755 --- a/gplugins/sax/plot_model.py +++ b/gplugins/sax/plot_model.py @@ -65,9 +65,9 @@ def plot_model( y = np.abs(sdict[(port1, port2)]) y = 20 * np.log10(y) if logscale else y ylabel = "|S (dB)|" if logscale else "|S|" - ax.plot(wavelengths * 1e9, y, label=port2) + ax.plot(wavelengths, y, label=port2) ax.set_title(port1) - ax.set_xlabel("wavelength (nm)") + ax.set_xlabel("wavelength (um)") ax.set_ylabel(ylabel) plt.legend() return ax From c09ea204ada8f6c97e620d48a20b8884a19b24c5 Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Tue, 23 Jul 2024 13:10:35 +0000 Subject: [PATCH 2/3] Support `Instance`s in path extraction from GDS --- .../path_length_analysis_from_gds.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/gplugins/path_length_analysis/path_length_analysis_from_gds.py b/gplugins/path_length_analysis/path_length_analysis_from_gds.py index 50ef3e1d..744f817d 100644 --- a/gplugins/path_length_analysis/path_length_analysis_from_gds.py +++ b/gplugins/path_length_analysis/path_length_analysis_from_gds.py @@ -3,6 +3,7 @@ from functools import partial import gdsfactory as gf +import kfactory as kf import matplotlib.pyplot as plt import numpy as np from scipy.signal import savgol_filter @@ -11,17 +12,17 @@ def extract_paths( - component: gf.Component, + component: gf.typings.Component | kf.Instance, layer: gf.typings.LayerSpec = (1, 0), plot: bool = False, filter_function: Callable = None, under_sampling: int = 1, ) -> list[gf.Path]: - """Extracts the centerlines of a component from a GDS file. + """Extracts the centerlines of a component or instance from a GDS file. Args: - component: GDS component. - layer: GDS layer to extract the centerline from. + component: gdsfactory component or instance to extract from. + layer: layer to extract the centerline from. plot: Plot the centerline. filter_function: optional Function to filter the centerline. under_sampling: under sampling factor. @@ -31,7 +32,7 @@ def extract_paths( """ layer = gf.get_layer(layer) - polygons_by_layer = component.get_polygons_points(merge=True) + polygons_by_layer = gf.functions.get_polygons_points(component, merge=True) if layer not in polygons_by_layer: raise ValueError(f"Layer {layer} not found in component") From 44ee5940dcb8211208674812e9f41acb3be8a44e Mon Sep 17 00:00:00 2001 From: Niko Savola Date: Tue, 23 Jul 2024 13:12:12 +0000 Subject: [PATCH 3/3] Fix extracting paths from 4 point polygons This fixes for example path from simple straights --- .../path_length_analysis/path_length_analysis_from_gds.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/gplugins/path_length_analysis/path_length_analysis_from_gds.py b/gplugins/path_length_analysis/path_length_analysis_from_gds.py index 744f817d..2a1b57fe 100644 --- a/gplugins/path_length_analysis/path_length_analysis_from_gds.py +++ b/gplugins/path_length_analysis/path_length_analysis_from_gds.py @@ -59,9 +59,10 @@ def extract_paths( outer_points = outer_points[:min_length] inner_points = inner_points[:min_length] - # Remove the first and last points - outer_points = outer_points[1:-1] - inner_points = inner_points[1:-1] + # Remove the first and last points if these are not the only points + if len(outer_points) > 2: + outer_points = outer_points[1:-1] + inner_points = inner_points[1:-1] # Apply under-sampling outer_points = np.array(outer_points[::under_sampling])