Skip to content

Commit

Permalink
allowing phidl device reader to take a cellname to handle multiple to…
Browse files Browse the repository at this point in the history
…p cells
  • Loading branch information
atait committed Jun 15, 2019
1 parent 826218e commit f874598
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions lygadgets/cell_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,18 +102,23 @@ def pyaCell_reader(pya_cell, filename, *args, **kwargs):
if issubclass(celltype, phidl.Device):
def phidlDevice_reader(phidl_device, filename, *args, port_layer=None, **kwargs):
# phidl_device is not really used. It is just there to determine type.
#### hacks, because sometimes pya saves an extra topcell called $$$CONTEXT_INFO$$$
from gdspy import GdsLibrary
gdsii_lib = GdsLibrary()
gdsii_lib.read_gds(filename)
top_level_cells = gdsii_lib.top_level()
if len(top_level_cells) == 1:
cellname = top_level_cells[0].name
if len(top_level_cells) == 2:
for tc in top_level_cells:
if tc.name != '$$$CONTEXT_INFO$$$':
cellname = tc.name
#### end hacks
if 'cellname' in kwargs:
cellname = kwargs.pop('cellname')
else:
#### hacks, because sometimes pya saves an extra topcell called $$$CONTEXT_INFO$$$
from gdspy import GdsLibrary
gdsii_lib = GdsLibrary()
gdsii_lib.read_gds(filename)
top_level_cells = gdsii_lib.top_level()
if len(top_level_cells) == 1:
cellname = top_level_cells[0].name
elif len(top_level_cells) == 2:
for tc in top_level_cells:
if tc.name != '$$$CONTEXT_INFO$$$':
cellname = tc.name
else:
raise ValueError('There are multiple top level cells: {}.\n Please specify with the cellname argument.'.format(top_level_cells))
#### end hacks

# main read function
tempdevice = phidl.geometry.import_gds(filename, *args, cellname=cellname, **kwargs)
Expand Down

0 comments on commit f874598

Please sign in to comment.