def find_origin(self, cell): """finds the displacement of the origin""" origins = [] for instance in cell.each_inst(): if instance.cell.name.endswith("t_c"): origins.append(instance.trans.disp) if origins: return pya.Point(ap.mean([o.x for o in origins]), ap.mean([o.y for o in origins])) else: bbox = cell.bbox() return pya.Point(-bbox.left, -bbox.bottom)
def test_numpy(): t = np.arange(3) ex = kdb.Point(1, 0) # Point should consume a numpy array and produce a np.array of points point_array = t * ex assert isinstance(point_array, np.ndarray) assert np.all([0 * ex, 1 * ex, 2 * ex] == point_array)
def produce_impl(self): squares = [2, 5, 10, 20] width = self.w * 1000 length = max(squares) * self.w * 1000 fox_bloat = 40000 ito_bloat = 10000 pad = pya.Box(pya.Point(0, 0), pya.Point(80000, 80000)) self.cell.shapes(self.nno_layer).insert(pad) pads = [pad] for s in squares: length = s * self.w * 1000 newpad = pad.moved(length + 80000, 0) pads.append(newpad) fox_extent_box = pya.Box(0, 0, 160000 + max(squares) * self.w * 1000, 80000).enlarge(pya.Point( fox_bloat, fox_bloat)) fox_box = pya.Polygon(fox_extent_box) fox_box_cutout = pya.Region( pya.Box(pya.Point(80000, 40000 - width / 2), pya.Point(80000 + length, 40000 + width / 2))) for p in pads: fox_box_cutout.insert(p) self.cell.shapes(self.nno_layer).insert(p) fox_box = pya.Region(fox_box) - fox_box_cutout self.cell.shapes(self.fox_layer).insert(fox_box) ito_extent_box = fox_extent_box.dup() ito_extent_box.enlarge(pya.Point(ito_bloat, ito_bloat)) ito_iso = pya.Polygon(ito_extent_box) ito_iso.insert_hole(fox_extent_box) self.cell.shapes(self.ito_layer).insert(ito_iso) self.cell.shapes(self.hfoetch_layer).insert(ito_extent_box)
def align(self, dimension=ap.BOTH): """ Aligns the grating couplers """ if not self.cells: return for cell in self.cells: cell.origin = self.find_origin(cell) max_origin = pya.Point( max(cell.origin.x for cell in self.cells), max(cell.origin.y for cell in self.cells), ) for cell in self.cells: delta = max_origin - cell.origin layer = cell.layout().layer(ap.DEVREC_LAYER, 0) delta.x = delta.x if dimension in (ap.BOTH, ap.WIDTH) else 0 delta.y = delta.y if dimension in (ap.BOTH, ap.HEIGHT) else 0 box = cell.bbox().enlarge(delta.x, delta.y) cell.shapes(layer).insert(box)