Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions gds_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ def gds_cross_section(gds_file, cut_segment, layer_map=None):
layer_map: optional filename for GDS map file. If present, the returned
dictionary's keys will be layer names instead of numbers.'''
cut_segment = geometry.LineString(cut_segment)
cell = gdsCAD.core.GdsImport(gds_file).values()[0]
cell = list(gdsCAD.core.GdsImport(gds_file).values())[0]
layers = {layer: polygons_to_cross_section(polygons, cut_segment)
for layer, polygons in cell_to_MultiPolygon(cell).items()}
for layer, polygons in list(cell_to_MultiPolygon(cell).items())}
if layer_map is None:
self.layers = layers
else:
layer_map = load_gds_map(layer_map)
layers = {layer_map[layer]: geometry
for layer, geometry in layers.items()}
for layer, geometry in list(layers.items())}
return layers

def load_gds_map(filename):
Expand Down
10 changes: 5 additions & 5 deletions geometry_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ def plot_geometry(geometry, axes=None, **kwargs):
if axes is None:
axes = pyplot.gca()
polygons = ensure_multipolygon(geometry)
for polygon in polygons:
for polygon in polygons.geoms:
xy = numpy.column_stack( polygon.exterior.xy)
axes.add_patch(matplotlib.patches.Polygon(xy, **kwargs))
axes.update_datalim(zip(polygon.bounds[::2], polygon.bounds[1::2]))
axes.update_datalim(list(zip(polygon.bounds[::2], polygon.bounds[1::2])))
# Only first polygon needs a legend entry
kwargs.pop('label', None)
axes.autoscale()
Expand All @@ -49,7 +49,7 @@ def plot_geometryref(geometryref, axes=None, **kwargs):

def multilinestring_to_segments(multilinestring):
return [[point[0] for point in segment.coords]
for segment in ensure_multilinestring(multilinestring)]
for segment in ensure_multilinestring(multilinestring).geoms]

class GeometryReference(object):
'''Pointer to shapely geometry'''
Expand All @@ -71,8 +71,8 @@ def polygons_to_cross_section(polygons, cut_segment):
cut_segment.intersection(side))
if intersection > cuts[0] and intersection < cuts[-1] \
and intersection not in cuts:
index = (ii for ii, element in enumerate(cuts)
if element > intersection).next()
index = next((ii for ii, element in enumerate(cuts)
if element > intersection))
cuts.insert(index, intersection)
present = [False] * (len(cuts) - 1)
for polygon in polygons:
Expand Down
10 changes: 5 additions & 5 deletions hole.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
original_coords = [ (0,0), (3,0), (3, 1.5-gap),
(2,1.5-gap), (2,1), (1,1), (1,2), (2.2,2), (2.2,1.5+gap),
(2.8,1.5+gap), (2.8,3), (0,3)]
original_segments = map(shapely.geometry.LineString, zip(original_coords[:-1],
original_coords[1:]))
original_segments = list(map(shapely.geometry.LineString, list(zip(original_coords[:-1],
original_coords[1:]))))
# Split segments at every intersection
all_coords = []
for ii, segmentA in enumerate(original_segments):
Expand All @@ -20,7 +20,7 @@
segmentA = shapely.geometry.LineString([coordB,
segmentA.coords[1]])
all_coords.append(segmentA.coords[1])
print all_coords
print(all_coords)

# Separate interior from exterior
processed = []
Expand All @@ -41,11 +41,11 @@
ii += 1
processed.append(current)

print processed
print(processed)
#plot_geometryref(GeometryReference(holey))
from itertools import cycle
colors = cycle('rgbcmyk')
for p in processed:
plt.plot(*zip(*p), linestyle='solid', marker='x', color=next(colors))
plt.plot(*list(zip(*p)), linestyle='solid', marker='x', color=next(colors))
#plt.plot(*zip(*exterior), linestyle='solid', marker='o', color='b')
plt.show()
Binary file modified mypmos-x.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 6 additions & 4 deletions planarprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ def grow(self, height, mask, base=None, consuming=None, outdiffusion=0.,
ret = GeometryReference(top.geometry.union(bottom.geometry))
self.solids.append(ret)
return ret
base_union = shapely.ops.cascaded_union([b.geometry for b in base])
consuming_union = shapely.ops.cascaded_union(
base_union = shapely.ops.unary_union([b.geometry for b in base])
consuming_union = shapely.ops.unary_union(
[c.geometry for c in consuming])
whole_interface = base_union.intersection(consuming_union)
buried = numpy.sign(height) != numpy.sign(y_offset)
Expand All @@ -62,6 +62,8 @@ def grow(self, height, mask, base=None, consuming=None, outdiffusion=0.,
self.air.geometry.bounds[3])))
if isinstance(interface, shapely.geometry.Point):
continue
if isinstance(interface, shapely.geometry.MultiLineString):
interface = interface.geoms;
for linestring in interface:
if not isinstance(linestring, shapely.geometry.LineString):
# Don't want Points and other strange bits of the
Expand Down Expand Up @@ -96,7 +98,7 @@ def grow(self, height, mask, base=None, consuming=None, outdiffusion=0.,
0, 2 * numpy.pi, outdiffusion_vertices)))

# Only consume from specified geometry
ret = shapely.ops.cascaded_union(polygons).intersection(
ret = shapely.ops.unary_union(polygons).intersection(
consuming_union)
for c in consuming:
c.geometry = c.geometry.difference(ret)
Expand Down Expand Up @@ -141,7 +143,7 @@ def implant(self, depth, mask, target=None, source=None, buried=0.,

def planarize(self):
'''Etch down to the lowest point of the wafer surface'''
base_union = shapely.ops.cascaded_union([s.geometry
base_union = shapely.ops.unary_union([s.geometry
for s in self.solids])
whole_interface = base_union.intersection(self.air.geometry)
min_y = whole_interface.bounds[1]
Expand Down
4 changes: 2 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@

# Presentation
custom_style = {s: {} for s in wafer.solids}
for solid, color in {
for solid, color in list({
fox: '.4', gox: 'r', poly: 'g', mld: 'k',
ild1: '.3', contact: '.5', via1: '.5',
metal1: '.7', metal2: '.8'}.items():
metal1: '.7', metal2: '.8'}.items()):
custom_style[solid].update(dict(facecolor=color, edgecolor='k'))

for solid in wafer.solids:
Expand Down
2 changes: 1 addition & 1 deletion test_nwell.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

# N-Well
nw = layers['N-Well']
print nw
print(nw)
wafer.implant(.7, nw, outdiffusion=0., label='N-Well')
present(wafer)
pyplot.legend()
Expand Down