HelgeGehring / gdshelpers

GDSHelpers is an open-source package for automatized pattern generation for nano-structuring.
https://www.uni-muenster.de/Physik.PI/Pernice/
GNU Lesser General Public License v3.0
110 stars 33 forks source link

First example Script error #6

Closed quaeritis closed 5 years ago

quaeritis commented 5 years ago

Hi @HelgeGehring,

The first example script is flawed:

  1. numpy is missing
  2. Something is wrong with gdshelpers.parts.logo:
    ~/.local/lib/python3.7/site-packages/gdshelpers/parts/logo.py in get_shapely_object(self)
    180             # WWU width = 368.93 = 369     *M2 == w
    181             # box width unscaled = w = 336
    --> 182             m2 = w / 369.  # scale width of WWU to width of logo
    183             m = self.height / (h + 10 + 114)  # scaling factor height
    184 

the code works with numpy and without logo:

import numpy as np
from gdshelpers.geometry.chip import Cell
from gdshelpers.parts.waveguide import Waveguide
from gdshelpers.parts.coupler import GratingCoupler
from gdshelpers.parts.resonator import RingResonator
from gdshelpers.parts.splitter import Splitter
#from gdshelpers.parts.logo import KITLogo, WWULogo
from gdshelpers.parts.optical_codes import QRCode
from gdshelpers.parts.text import Text
from gdshelpers.parts.marker import CrossMarker

# Generate a coupler with parameters from the coupler database
coupler1 = GratingCoupler.make_traditional_coupler_from_database([0, 0], 1, 'sn330', 1550)
coupler2 = GratingCoupler.make_traditional_coupler_from_database([150, 0], 1, 'sn330', 1550)

coupler1_desc = coupler1.get_description_text(side='left')
coupler2_desc = coupler2.get_description_text(side='right')

# And add a simple waveguide to it
wg1 = Waveguide.make_at_port(coupler1.port)
wg1.add_straight_segment(10)
wg1.add_bend(-np.pi/2, 10, final_width=1.5)

res = RingResonator.make_at_port(wg1.current_port, gap=0.1, radius=20,
                                 race_length=10, res_wg_width=0.5)

wg2 = Waveguide.make_at_port(res.port)
wg2.add_straight_segment(30)
splitter = Splitter.make_at_root_port(wg2.current_port, total_length=20, sep=10, wg_width_branches=1.0)

wg3 = Waveguide.make_at_port(splitter.right_branch_port)
wg3.add_route_single_circle_to_port(coupler2.port)

# Add a marker just for fun
marker = CrossMarker.make_traditional_paddle_markers(res.center_coordinates)

# The fancy stuff
#kit_logo = KITLogo([25, 0], 10)
#wwu_logo = WWULogo([100, 30], 30, 2)
qr_code = QRCode([25, -40], 'https://www.uni-muenster.de/Physik.PI/Pernice', 1.0)
dev_label = Text([100, 0], 10, 'A0', alignment='center-top')

# Create a Cell to hold the objects
cell = Cell('EXAMPLE')

# Convert parts to gdsCAD polygons
cell.add_to_layer(1, coupler1, wg1, res, wg2, splitter, wg3, coupler2)
#cell.add_to_layer(2, wwu_logo, kit_logo, qr_code, dev_label)
cell.add_to_layer(2, marker)
cell.add_to_layer(3, coupler1_desc, coupler2_desc)
cell.show()

best, quearitis

HelgeGehring commented 5 years ago

Thanks for the issue! I think this error was introduced in c7fb013c3bcdb274ceb5cf11be267b7b5af7a755, but already fixed in b21f817767610b9d747b1d32f91f062283aecb3f. Therefore, the bug should be still in v1.0.3. I've just released the version v1.0.4, where this issue should be fixed. Could you update your gdshelpers version and check if it's now working for you? I've also just added the import of numpy to the documentation. Thanks! Helge

quaeritis commented 5 years ago

it works.

Sorry I had to update my gdshelpers version before and to see if the problem still exists.

Thanks for the quick answer.