How can I load GDS II into matlab?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
0 개 추천
I want to load GDS II layout format into matlab in the form of a matrix, how can I do that?
채택된 답변
José-Luis
2014년 6월 2일
0 개 추천
- The hard way: find out how the GDSII binary is structured and read it directly into Matlab.
- The compromise way: Use a GDSII to ascii converter (Google will find you one in less than 30s) and then read that into Matlab. importdata(), textscan(), are then your friends.
- The easy way: Look in the file exchange to see if anyone has done that before
댓글 수: 7
Reem
2014년 6월 3일
편집: Walter Roberson
2024년 5월 10일
Has anyone tried the GDSII Toolbox from:
thanks, Reem
Yue Huang
2019년 12월 17일
Hi,
I tried it and it works decently well generating gds from MATLAB. I'm trying to find out if it can do the reverse - something like converting gds patterns into MATLAB matrices or images but it doesn't seem so easy.
Thanks,
Jonathan
YANG SHANG
2020년 2월 20일
Did you succeed? I'm eager to know! Thx a lot!!!!
Andrew Davies
2024년 4월 2일
편집: Andrew Davies
2024년 4월 2일
You can use GDSII Toolbox for this. You get get the Toolbox at https://sites.google.com/site/ulfgri/numerical/gdsii-toolbox.
When you read GDSII Toolbox manual it's easy to see how to make a GDS file from a set of polygon points but it's not obvious how to read the GDS file and get the polygon points back into matlab, but it can be done. With a little help from Ulf Griesmann the creater of GDSII Toolbox I was able to figure it out.
Below is a modifed verion of the Example_basic.m file in the GDSII Toolbox manual that should help others read the GDS files. This modifed version has a second section that recovers the orignal polygon points.
%
% makes a basic gds file and then reads the contents of gds file
%
clear all
%% Makes a GDS file with two polygons
% create a structure to hold elements
gs = gds_structure('BASIC');
% create two polygons
xy1 = 1000 * [0,0; 0,1; 1,1; 1,0; 0,0]; % 1mm x 1mm
xy2 = bsxfun(@plus, xy1, [1000, 1000]);
% create boundary elements and add to the structure (on different layers)
gs(end+1) = gds_element('boundary', 'xy',xy1, 'layer',1);
gs(end+1) = gds_element('boundary', 'xy',xy2, 'layer',2);
% create a library to hold the structure
glib = gds_library('TWO_BLOCKS', 'uunit',1e-6, 'dbunit',1e-9, gs);
% finally write the library to a file
write_gds_library(glib, '!basic.gds');
%% Recovers the two polygons from the GDS file
% A GDS library (file) can be thought of as an array of structures, each of which is an array of elements.
% Read GDS file
L = read_gds_library('basic.gds');
treeview(L) % shows there is only one structure
S = L(1); % setting the structure equal to S which has 2 elements
% Recover the first polygon
S1 = S(1);
xy1_recovered =S1.xy;
xy1_recovered = xy1_recovered{1}
% Recover the second polygon
S2 = S(2);
xy2_recovered =S2.xy;
xy2_recovered = xy2_recovered{1}
%Another method to recover the polygons
vector_1 = L.BASIC(1).xy;
xy1_recovered = vector_1{1}
vector_1 = L.BASIC(2).xy;
xy2_recovered = vector_1{1}
Andrew, this is super helpful, thanks! Do you know if there is a way to extract the number of elements in the gds structure in order to loop through an unknown number of elements?
Andrew Davies
2024년 5월 9일
편집: Walter Roberson
2024년 11월 1일
Yes, you can loop through the elements. See example below. The key command is numel(GDS_structure) which gives you the number of elements.
% Read GDS file
GDS_Library = read_gds_library(filename); % file must be in the same folder as this matlab script
%treeview(GDS_Library) % shows the structures
GDS_box = bbox(GDS_Library); % Calculates the rectangular bounding box of a gds_structure object.
Point_units = get(GDS_Library,'uunit'); % (m) defualt is 10-6 m = 1 um
GDS_structure = GDS_Library(1); % setting the 1st structure equal to GDS_structure which can have multiple elements
% Number_of_elements = numel(GDS_Library);
Number_of_elements = numel(GDS_structure); % or size(GDS_structure(:),2) gives the number of elements in structure or Library
% Recover the polygon points for each element
for i= 1:Number_of_elements
GDS_elements = GDS_structure(i); % Get each element in the structure
xy_recovered = GDS_elements.xy; % or xy_recovered = get(GDS_elements, 'xy'), sometimes cell array sometimes numeric array
%xy_recovered = xy_recovered{1};
%xy_point{i} = xy_recovered; % This is a matlab cell structure. Normal matlab rules apply to it.
if iscell(xy_recovered)==1
xy_point{i}=cell2mat(xy_recovered); % This is a matlab cell structure
elseif isnumeric(xy_recovered) == 1
xy_point{i} = xy_recovered; % This is a matlab cell structure
else
whos xy_recovered
end
end
Hello I guess i never got notified of you response but I had found and made numel work at the time. Your solution to catch the cell vs numeric format is really helpful though, I was just catching and skipping otherwise, since mostly the errors were empty anyways.
I found this post again in trying to solve a new problem I'm running into. Im still importing preexisting gds, but now it's a set of tiered cells (many separate gds structures within the library). I can pull out the number of structures and then nest to get all the elements but it doesnt capture their global coordinates relative to the mask. So all the structures are placed at 0,0. Is there a way to pull the coordinate of each each structure relative to the whole mask? bbox didnt seem to help, they still mostly originated at 0,0.
val is a GDSII library:
Library name : Absorber.DB
Database unit : 5e-08 m
User unit : 1e-06 m
Structures : 21
1 ... Absorber_Overlay (16)
2 ... 6mm_die (21)
3 ... Alignment_marks_3 (192)
.... etc
gds = read_gds_library(path); %read in the gyro gds
%Point_units = get(gds,'uunit');
%Struct = gds(1); %extract the structure
%ElNum = numel(Struct);
ElNumTot = numel(gds); %det how many elements (shapes) w/in the set of structure
LCC_XY=[];
%cnt=0;
for kk = 1:length(gds)
Struct = gds(kk); %extract the structure
elTemp = numel(Struct);
bboxStruct = bbox(Struct); %
xStart=0;%bboxStruct(1)*1e3;
yStart=0;%bboxStruct(2)*1e3;
for ii=1:elTemp
LCC = Struct(ii);
xy_recovered = LCC.xy; %xy_recovered = get(GDS_elements, 'xy');
%xy_recovered = xy_recovered{1};
%xy_point{i} = xy_recovered; % This is a matlab cell structure. Normal matlab rules apply to it.
if iscell(xy_recovered)==1
LCC_XY{ii}=cell2mat(xy_recovered).*1e3; % This is a matlab cell structure
elseif isnumeric(xy_recovered) == 1
LCC_XY{ii} = xy_recovered.*1e3; % This is a matlab cell structure
else
whos xy_recovered
end
% try
% LCC_XY = xy_recovered{1}*1e3+[xStart,yStart];
LCC_out_discrete = round(LCC_XY{ii}/grid)*grid; % round to discrete points on the grid
%catch
%skip
% end
end
end
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 MATLAB에 대해 자세히 알아보기
태그
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
