-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve layer stack #2726
Merged
Merged
Improve layer stack #2726
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
00d343d
add layer_stack pprint
joamatab e6ebe66
remove mapping from gds to layer level
joamatab 85401e5
better defaults for straight heaters
joamatab 221fdba
fix settings
joamatab ba9a6bf
merge polygons in unetched_layers
joamatab 394252d
simpler to_3d and to_svg
joamatab 614af21
improve to_stl
joamatab File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -5,6 +5,8 @@ | |||||
|
||||||
import gdstk | ||||||
from pydantic import BaseModel, Field | ||||||
from rich.console import Console | ||||||
from rich.table import Table | ||||||
|
||||||
import gdsfactory as gf | ||||||
from gdsfactory.cell import cell | ||||||
|
@@ -94,6 +96,21 @@ | |||||
"""Returns a copy of the LayerStack.""" | ||||||
return LayerStack.model_validate_json(self.model_dump_json()) | ||||||
|
||||||
def pprint(self) -> None: | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code_refinement): Consider renaming 'pprint' to a more descriptive method name indicating its specific functionality.
Suggested change
|
||||||
console = Console() | ||||||
table = Table(show_header=True, header_style="bold") | ||||||
keys = ["layer", "thickness", "material", "sidewall_angle"] | ||||||
|
||||||
for key in ["name"] + keys: | ||||||
table.add_column(key) | ||||||
|
||||||
for layer_name, layer in self.layers.items(): | ||||||
port_dict = dict(layer) | ||||||
row = [layer_name] + [str(port_dict.get(key, "")) for key in keys] | ||||||
table.add_row(*row) | ||||||
|
||||||
console.print(table) | ||||||
|
||||||
def __init__(self, **data: Any) -> None: | ||||||
"""Add LayerLevels automatically for subclassed LayerStacks.""" | ||||||
super().__init__(**data) | ||||||
|
@@ -399,7 +416,21 @@ | |||||
for layer_name in unetched_layers | ||||||
if layer_stack.layers[layer_name].layer in component_layers | ||||||
] | ||||||
component_derived = component.extract(unetched_layer_numbers) | ||||||
layer_to_polygons = component.get_polygons(by_spec=True) | ||||||
|
||||||
# component_derived = component.extract(unetched_layer_numbers) | ||||||
component_derived = gf.Component() | ||||||
|
||||||
for layer in unetched_layer_numbers: | ||||||
polygons = layer_to_polygons[layer] | ||||||
unetched_polys = gdstk.boolean( | ||||||
operand1=polygons, | ||||||
operand2=[], | ||||||
operation="or", | ||||||
layer=layer[0], | ||||||
datatype=layer[1], | ||||||
) | ||||||
component_derived.add(unetched_polys) | ||||||
|
||||||
# Define unetched layers | ||||||
polygons_to_remove = [] | ||||||
|
@@ -432,7 +463,6 @@ | |||||
|
||||||
# Remove all etching layers | ||||||
layer = layer_stack.layers[unetched_layer_name].layer | ||||||
polygons = component.get_polygons(by_spec=layer) | ||||||
unetched_polys = gdstk.boolean( | ||||||
operand1=polygons, | ||||||
operand2=polygons_to_remove, | ||||||
|
@@ -453,11 +483,15 @@ | |||||
|
||||||
from gdsfactory.generic_tech import LAYER_STACK | ||||||
|
||||||
layer_stack = LAYER_STACK | ||||||
ls = LAYER_STACK | ||||||
# ls.pprint() | ||||||
|
||||||
c = gf.components.straight_heater_metal() | ||||||
c = gf.components.straight_heater_metal(length=30) | ||||||
c.show() | ||||||
|
||||||
s = c.to_3d() | ||||||
s.show() | ||||||
|
||||||
# import gdsfactory as gf | ||||||
# from gdsfactory.generic_tech import LAYER_STACK | ||||||
# component = c = gf.components.grating_coupler_elliptical_trenches() | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (edge_case_not_handled): Check if 'layer_to_polygon' dictionary always contains all layers as keys to avoid KeyError.