Python编写自定义结构的GDS文件

1.        安装gdspy库

gdspy · PyPIicon-default.png?t=N7T8https://pypi.org/project/gdspy/注意:

## Installation

### Dependencies:

Python版本只支持2.7, 3.6, 3.7, and 3.8。我试了3.9不成功。

  2.        在光刻前需要把自己设计的结构转换为GDS文件,这里我设计的是矩形,你也可以设置任何结构。官方文档说明API Reference — gdspy 1.6.13 documentationicon-default.png?t=N7T8https://gdspy.readthedocs.io/en/stable/reference.html#rectangle

import gdspy
import scipy.io as io
import numpy as np
dataFile1 = r'结构数据文件'
data_dic1 = io.loadmat(dataFile1)

pr_outputs = (data_dic1['结构变量名'])*1e6
X_mask = (data_dic1['X方向坐标'])*1e6
Y_mask = (data_dic1['Y方向坐标'])*1e6

# The GDSII file is called a library, which contains multiple cells.
lib = gdspy.GdsLibrary()

# Geometry must be placed in cells.
cell = lib.new_cell('FIRST')
ld_fulletch = {"layer": 1, "datatype": 3}
# Create the geometry (a single rectangle) and add it to the cell.
a = 0
for i in range(len(X_mask)):
    for j in range(len(Y_mask)):
        rect = gdspy.Rectangle((X_mask[j][i]-pr_outputs[a][0]/2, Y_mask[j][i]-        
        pr_outputs[a][1]/2), (X_mask[j][i]+pr_outputs[a][0]/2, Y_mask[j][i]+pr_outputs[a][1]/2), **ld_fulletch)
#设置每个结构的旋转角度
               #rect.rotate(pr_outputs[a][2], (X_mask[j][i]+pr_outputs[a][0]/2, Y_mask[j][i]+pr_outputs[a][1]/2))
        cell.add(rect)
        a += 1
# Save the library in a file called 'first.gds'.
lib.write_gds('first.gds')

# Optionally, save an image of the cell as SVG.
cell.write_svg('first.svg')

# Display all cells using the internal viewer.
gdspy.LayoutViewer()

3.        效果如下图所示

 

4.        用常见的Klayout或者L-Edit软件打开进行查看修改

  • 28
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值