2023-01-24 12:45:44 -08:00
|
|
|
from pprint import pprint
|
|
|
|
from pathlib import Path
|
|
|
|
|
2020-07-22 02:45:16 -07:00
|
|
|
import numpy
|
|
|
|
from numpy import pi
|
|
|
|
|
|
|
|
import masque
|
2023-01-24 12:45:44 -08:00
|
|
|
from masque import Pattern, Ref, Arc, WrapLibrary
|
2020-07-22 02:45:16 -07:00
|
|
|
from masque.repetition import Grid
|
2023-01-24 12:45:44 -08:00
|
|
|
from masque.file import gdsii, dxf, oasis
|
2020-07-22 02:45:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2023-01-24 12:45:44 -08:00
|
|
|
lib = WrapLibrary()
|
|
|
|
|
|
|
|
cell_name = 'ellip_grating'
|
|
|
|
pat = masque.Pattern()
|
2020-07-22 02:45:16 -07:00
|
|
|
for rmin in numpy.arange(10, 15, 0.5):
|
2023-01-24 12:45:44 -08:00
|
|
|
pat.shapes.append(Arc(
|
2020-07-22 02:45:16 -07:00
|
|
|
radii=(rmin, rmin),
|
|
|
|
width=0.1,
|
2023-01-24 12:45:44 -08:00
|
|
|
angles=(0 * -pi/4, pi/4),
|
2020-09-10 20:06:58 -07:00
|
|
|
annotations={'1': ['blah']},
|
2023-01-24 12:45:44 -08:00
|
|
|
))
|
2020-07-22 02:45:16 -07:00
|
|
|
|
|
|
|
pat.scale_by(1000)
|
|
|
|
# pat.visualize()
|
2023-01-24 12:45:44 -08:00
|
|
|
lib[cell_name] = pat
|
|
|
|
print(f'\nAdded {cell_name}:')
|
|
|
|
pprint(pat.shapes)
|
|
|
|
|
|
|
|
new_name = lib.get_name(cell_name)
|
|
|
|
lib[new_name] = pat.copy()
|
|
|
|
print(f'\nAdded a copy of {cell_name} as {new_name}')
|
|
|
|
|
|
|
|
pat3 = Pattern()
|
|
|
|
pat3.refs = [
|
|
|
|
Ref(cell_name, offset=(1e5, 3e5), annotations={'4': ['Hello I am the base Ref']}),
|
|
|
|
Ref(cell_name, offset=(2e5, 3e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, offset=(3e5, 3e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, offset=(4e5, 3e5), rotation=pi),
|
|
|
|
Ref(cell_name, offset=(5e5, 3e5), rotation=3*pi/2),
|
|
|
|
Ref(cell_name, mirrored=(True, False), offset=(1e5, 4e5)),
|
|
|
|
Ref(cell_name, mirrored=(True, False), offset=(2e5, 4e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, mirrored=(True, False), offset=(3e5, 4e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, mirrored=(True, False), offset=(4e5, 4e5), rotation=pi),
|
|
|
|
Ref(cell_name, mirrored=(True, False), offset=(5e5, 4e5), rotation=3*pi/2),
|
|
|
|
Ref(cell_name, mirrored=(False, True), offset=(1e5, 5e5)),
|
|
|
|
Ref(cell_name, mirrored=(False, True), offset=(2e5, 5e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, mirrored=(False, True), offset=(3e5, 5e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, mirrored=(False, True), offset=(4e5, 5e5), rotation=pi),
|
|
|
|
Ref(cell_name, mirrored=(False, True), offset=(5e5, 5e5), rotation=3*pi/2),
|
|
|
|
Ref(cell_name, mirrored=(True, True), offset=(1e5, 6e5)),
|
|
|
|
Ref(cell_name, mirrored=(True, True), offset=(2e5, 6e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, mirrored=(True, True), offset=(3e5, 6e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, mirrored=(True, True), offset=(4e5, 6e5), rotation=pi),
|
|
|
|
Ref(cell_name, mirrored=(True, True), offset=(5e5, 6e5), rotation=3*pi/2),
|
2020-07-22 02:45:16 -07:00
|
|
|
]
|
|
|
|
|
2023-01-24 12:45:44 -08:00
|
|
|
lib['sref_test'] = pat3
|
|
|
|
print('\nAdded sref_test:')
|
2020-07-22 02:45:16 -07:00
|
|
|
pprint(pat3)
|
2023-01-24 12:45:44 -08:00
|
|
|
pprint(pat3.refs)
|
2020-07-22 02:45:16 -07:00
|
|
|
|
2023-01-24 12:45:44 -08:00
|
|
|
rep = Grid(
|
|
|
|
a_vector=[1e4, 0],
|
|
|
|
b_vector=[0, 1.5e4],
|
|
|
|
a_count=3,
|
|
|
|
b_count=2,
|
|
|
|
)
|
|
|
|
pat4 = Pattern()
|
|
|
|
pat4.refs = [
|
|
|
|
Ref(cell_name, repetition=rep, offset=(1e5, 3e5)),
|
|
|
|
Ref(cell_name, repetition=rep, offset=(2e5, 3e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, repetition=rep, offset=(3e5, 3e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, offset=(4e5, 3e5), rotation=pi),
|
|
|
|
Ref(cell_name, repetition=rep, offset=(5e5, 3e5), rotation=3*pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, False), offset=(1e5, 4e5)),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, False), offset=(2e5, 4e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, False), offset=(3e5, 4e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, False), offset=(4e5, 4e5), rotation=pi),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, False), offset=(5e5, 4e5), rotation=3*pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(False, True), offset=(1e5, 5e5)),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(False, True), offset=(2e5, 5e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(False, True), offset=(3e5, 5e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(False, True), offset=(4e5, 5e5), rotation=pi),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(False, True), offset=(5e5, 5e5), rotation=3*pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, True), offset=(1e5, 6e5)),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, True), offset=(2e5, 6e5), rotation=pi/3),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, True), offset=(3e5, 6e5), rotation=pi/2),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, True), offset=(4e5, 6e5), rotation=pi),
|
|
|
|
Ref(cell_name, repetition=rep, mirrored=(True, True), offset=(5e5, 6e5), rotation=3*pi/2),
|
2020-07-22 02:45:16 -07:00
|
|
|
]
|
|
|
|
|
2023-01-24 12:45:44 -08:00
|
|
|
lib['aref_test'] = pat4
|
|
|
|
print('\nAdded aref_test')
|
|
|
|
|
|
|
|
folder = Path('./layouts/')
|
|
|
|
print(f'...writing files to {folder}...')
|
|
|
|
|
|
|
|
gds1 = folder / 'rep.gds.gz'
|
|
|
|
gds2 = folder / 'rerep.gds.gz'
|
|
|
|
print(f'Initial write to {gds1}')
|
|
|
|
gdsii.writefile(lib, gds1, 1e-9, 1e-3)
|
2020-07-22 02:45:16 -07:00
|
|
|
|
2023-01-24 12:45:44 -08:00
|
|
|
print(f'Read back and rewrite to {gds2}')
|
|
|
|
readback_lib, _info = gdsii.readfile(gds1)
|
|
|
|
gdsii.writefile(readback_lib, gds2, 1e-9, 1e-3)
|
2020-07-22 02:45:16 -07:00
|
|
|
|
2023-01-24 12:45:44 -08:00
|
|
|
dxf1 = folder / 'rep.dxf.gz'
|
|
|
|
dxf2 = folder / 'rerep.dxf.gz'
|
|
|
|
print(f'Write aref_test to {dxf1}')
|
|
|
|
dxf.writefile(lib, 'aref_test', dxf1)
|
|
|
|
|
|
|
|
print(f'Read back and rewrite to {dxf2}')
|
|
|
|
dxf_lib, _info = dxf.readfile(dxf1)
|
|
|
|
print(WrapLibrary(dxf_lib))
|
|
|
|
dxf.writefile(dxf_lib, 'Model', dxf2)
|
2020-07-22 02:45:16 -07:00
|
|
|
|
|
|
|
layer_map = {'base': (0,0), 'mylabel': (1,2)}
|
2023-01-24 12:45:44 -08:00
|
|
|
oas1 = folder / 'rep.oas'
|
|
|
|
oas2 = folder / 'rerep.oas'
|
|
|
|
print(f'Write lib to {oas1}')
|
|
|
|
oasis.writefile(lib, oas1, 1000, layer_map=layer_map)
|
|
|
|
|
|
|
|
print(f'Read back and rewrite to {oas2}')
|
|
|
|
oas_lib, oas_info = oasis.readfile(oas1)
|
|
|
|
oasis.writefile(oas_lib, oas2, 1000, layer_map=layer_map)
|
|
|
|
|
|
|
|
print('OASIS info:')
|
|
|
|
pprint(oas_info)
|
2020-07-22 02:45:16 -07:00
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|