diff --git a/klayout_dot_config/grain.xml b/klayout_dot_config/grain.xml index e19adfc8..8e8645c2 100644 --- a/klayout_dot_config/grain.xml +++ b/klayout_dot_config/grain.xml @@ -1,7 +1,7 @@ siepic_tools - 0.5.16 + 0.5.17 0.27 SiEPIC Tools Tools for designing Silicon Photonic Integrated Circuits, including waveguides, component simulations, functional verification, DRC verification, Functional verification, netlist extraction, circuit simulations. Layout can be implemented graphically or by programming in Python using the SiEPIC functions and KLayout Python API. Framework and examples for creating layouts using scripts. Includes a generic PDK (GSiP). Other PDKs are installed separately, and depend on SiEPIC-Tools. diff --git a/klayout_dot_config/python/SiEPIC/__init__.py b/klayout_dot_config/python/SiEPIC/__init__.py index ac7f953c..9dc719ea 100644 --- a/klayout_dot_config/python/SiEPIC/__init__.py +++ b/klayout_dot_config/python/SiEPIC/__init__.py @@ -2,7 +2,7 @@ SiEPIC-Tools package for KLayout ''' -__version__ = "0.5.16" +__version__ = "0.5.17" print("KLayout SiEPIC-Tools version %s" %__version__) diff --git a/klayout_dot_config/python/SiEPIC/extend.py b/klayout_dot_config/python/SiEPIC/extend.py index 7c2cfa93..89e141de 100644 --- a/klayout_dot_config/python/SiEPIC/extend.py +++ b/klayout_dot_config/python/SiEPIC/extend.py @@ -1753,69 +1753,102 @@ def pinPoint(self, pin_name, verbose=False): return matched_pins[0].center -def show(self): - '''Show the cell in KLayout using klive''' +def show(self, file_path = None, lyrdb_filename=None): + ''' + Show the cell in KLayout using klive + + args + file_path: os.path folder location to save + ''' - # Save the cell in a temporary file - from ._globals import TEMP_FOLDER import os - file_out = os.path.join(TEMP_FOLDER, self.name+'.gds') + + if not file_path: + # Save the cell in a temporary file + from ._globals import TEMP_FOLDER + file_path = TEMP_FOLDER + + file_out = os.path.join(file_path, self.name+'.gds') self.write(file_out) # Display in KLayout from SiEPIC._globals import Python_Env if Python_Env == 'Script': from SiEPIC.utils import klive - klive.show(file_out, technology=self.layout().technology().name, keep_position=True) + klive.show(file_out, lyrdb_filename=lyrdb_filename, technology=self.layout().technology().name, keep_position=True) + def plot(self, width = 800, show_labels = True, show_ruler = True, retina = True): - ''' - Generate an image of the layout cell, and display. Useful for Jupyter notebooks - - Args: - self: pya.Cell - width: number of pixels - show_labels: KLayout display config to show text = True, https://www.klayout.de/doc-qt5/code/class_LayoutView.html#method101 - show_ruler: KLayout display config to show ruler = True - retina: IPython.display.Image configuration for retina display, True - ''' - - from io import BytesIO - from IPython.display import Image, display - - # Create a LayoutView, and populate it with the current cell & layout - cell = self - layout_view = pya.LayoutView() - cell_view_index = layout_view.create_layout(True) - layout_view.active_cellview_index = cell_view_index - cell_view = layout_view.cellview(cell_view_index) - layout = cell_view.layout() - layout.assign(cell.layout()) - cell_view.cell = layout.cell(cell.name) - - # Load layer properties from the technology - lyp_path=layout.technology().eff_layer_properties_file() - if not lyp_path: - raise Exception ('SiEPIC.extend.plot: technology not specified.') - layout_view.load_layer_props(lyp_path) - - # Configure the layout view settings - # print(layout_view.get_config_names()) - layout_view.set_config("text-font",3) - layout_view.set_config("background-color", "#ffffff") - layout_view.set_config("text-visible", "true" if show_labels else "false") - layout_view.set_config("grid-show-ruler", "true" if show_ruler else "false") - - # Zoom out and show all layout details - layout_view.max_hier() - layout_view.zoom_fit() - - # Display as a PNG - width = width * (2 if retina else 1) - pixel_buffer = layout_view.get_pixels(width, cell.bbox().height()/cell.bbox().width()*width) - png_data = pixel_buffer.to_png_data() - im = Image(png_data, retina=retina) - display(im) + ''' + Generate an image of the layout cell, and display. Useful for Jupyter notebooks + + Args: + self: pya.Cell + width: number of pixels + show_labels: KLayout display config to show text = True, https://www.klayout.de/doc-qt5/code/class_LayoutView.html#method101 + show_ruler: KLayout display config to show ruler = True + retina: IPython.display.Image configuration for retina display, True + ''' + + from io import BytesIO + from IPython.display import Image, display + + # Create a LayoutView, and populate it with the current cell & layout + cell = self + layout_view = pya.LayoutView() + cell_view_index = layout_view.create_layout(True) + layout_view.active_cellview_index = cell_view_index + cell_view = layout_view.cellview(cell_view_index) + layout = cell_view.layout() + layout.assign(cell.layout()) + cell_view.cell = layout.cell(cell.name) + + # Load layer properties from the technology + lyp_path=layout.technology().eff_layer_properties_file() + if not lyp_path: + raise Exception ('SiEPIC.extend.plot: technology not specified.') + layout_view.load_layer_props(lyp_path) + + # Configure the layout view settings + # print(layout_view.get_config_names()) + layout_view.set_config("text-font",3) + layout_view.set_config("background-color", "#ffffff") + layout_view.set_config("text-visible", "true" if show_labels else "false") + layout_view.set_config("grid-show-ruler", "true" if show_ruler else "false") + + # Zoom out and show all layout details + layout_view.max_hier() + layout_view.zoom_fit() + + # Display as a PNG + width = width * (2 if retina else 1) + pixel_buffer = layout_view.get_pixels(width, cell.bbox().height()/cell.bbox().width()*width) + png_data = pixel_buffer.to_png_data() + im = Image(png_data, retina=retina) + display(im) + return im + + +def image(self, file_out = None, file_format = 'PNG', width = 800, show_labels = True, show_ruler = True, retina = True): + ''' + Generate an image of the layout cell, and save + + Args: + self: pya.Cell + file_out: os.path to save the image + file_format: 'PNG' + width: number of pixels + show_labels: KLayout display config to show text = True, https://www.klayout.de/doc-qt5/code/class_LayoutView.html#method101 + show_ruler: KLayout display config to show ruler = True + retina: IPython.display.Image configuration for retina display, True + ''' + + # Create an image of the layout + im = self.plot(width=width, show_labels=show_labels, show_ruler=show_ruler, retina=retina) + # save + with open(file_out, "wb") as f: + f.write(im.data) + ################################################################################# @@ -1831,6 +1864,7 @@ def plot(self, width = 800, show_labels = True, show_ruler = True, retina = True pya.Cell.pinPoint = pinPoint pya.Cell.show = show pya.Cell.plot = plot +pya.Cell.image = image ################################################################################# diff --git a/klayout_dot_config/python/pyproject.toml b/klayout_dot_config/python/pyproject.toml index e24bd321..a91d7fc1 100644 --- a/klayout_dot_config/python/pyproject.toml +++ b/klayout_dot_config/python/pyproject.toml @@ -1,6 +1,6 @@ [project] name = "SiEPIC" -version = "0.5.16" +version = "0.5.17" authors = [ { name="Lukas Chrostowski", email="lukasc@ece.ubc.ca" }, ] diff --git a/klayout_dot_config/tech/GSiP/pymacros/tests/EBeam_LukasChrostowski_MZI2_FaML.gds b/klayout_dot_config/tech/GSiP/pymacros/tests/EBeam_LukasChrostowski_MZI2_FaML.gds new file mode 100644 index 00000000..a6944c1a Binary files /dev/null and b/klayout_dot_config/tech/GSiP/pymacros/tests/EBeam_LukasChrostowski_MZI2_FaML.gds differ diff --git a/klayout_dot_config/tech/GSiP/pymacros/tests/test_FaML.py b/klayout_dot_config/tech/GSiP/pymacros/tests/test_FaML.py index ee34005c..b140ea71 100644 --- a/klayout_dot_config/tech/GSiP/pymacros/tests/test_FaML.py +++ b/klayout_dot_config/tech/GSiP/pymacros/tests/test_FaML.py @@ -101,11 +101,18 @@ def test_FaML_two(show_klive=False): num_errors = layout_check(cell = cell, verbose=False, GUI=True, file_rdb=file_lyrdb) print('Number of errors: %s' % num_errors) + + cell.image(os.path.join(path,'test_FaML_two.png')) + # Display the layout in KLayout, using KLayout Package "klive", which needs to be installed in the KLayout Application + cell.show(file_path = path, lyrdb_filename=file_lyrdb) + + ''' if show_klive: if Python_Env == 'Script': from SiEPIC.utils import klive klive.show(file_out, lyrdb_filename=file_lyrdb, technology=tech_name) + ''' os.remove(file_out) if num_errors > 0: