8 to 9#
In GDSFactory8, ports and instance units were not consistent with each other. Port units were in DBU while instance units were in um.
GDSFactory9 makes ports and instance units consistent with each other. Port units are in um while instance units are in um.
We have had to make some small changes to the API of the following classes:
Component
Port
ComponentReference
ComponentReferences
Main changes#
Note the migration changes:
port.danglehas been renamed toport.orientationport.anglerepresents the angle 90 degrees multiples.port.orientationrepresents the angle in degrees.
CHECK_INSTANCEShas been renamed toCheckInstancesMost often used in the
@celldecorator.
Port(..., layer: tuple[int, int])has been replaced withPort(..., layer: int)layernow represents the layer index in the KLayout layer stack.To update your code you can do
Port(..., layer=gf.kcl.layout.layer(*layer))We also recommend just using Component.add_port, which lets you specify the layer as tuple.
Most of the
dprefix attributes and functions can now be used without thedprefix.ComponentReference.parenthas been removed, you should useComponentReference.cellinstead.ComponentReference.infohas been removed, you should useComponentReference.cell.infoinstead.
import gdsfactory as gf
c = gf.components.straight(length=10)
c.pprint_ports()
┏━━━━━━┳━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━┓ ┃ name ┃ width ┃ orientation ┃ layer ┃ center ┃ port_type ┃ ┡━━━━━━╇━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━┩ │ o1 │ 0.5 │ 180.0 │ WG (1/0) │ (0.0, 0.0) │ optical │ │ o2 │ 0.5 │ 0.0 │ WG (1/0) │ (10.0, 0.0) │ optical │ └──────┴───────┴─────────────┴──────────┴─────────────┴───────────┘
print('port orientation in degrees', c.ports['o2'].orientation)
print('port x in um', c.ports['o2'].x)
print('port dx in um (decimal)', c.ports['o2'].dx)
print('port ix in integer (database units)', c.ports['o2'].ix)
port orientation in degrees 0.0
port x in um 10.0
port dx in um (decimal) 10.0
port ix in integer (database units) 10000
c = gf.Component()
ref = c << gf.c.straight()
ref.xmin = 10
print('reference x in um', ref.x)
print('reference dx in um (decimal)', ref.dx)
print('reference ix in integer (database units)', ref.ix)
reference x in um 15.0
reference dx in um (decimal) 15.0
reference ix in integer (database units) 15000
c