How can I load GDS II into matlab?
現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
古いコメントを表示
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 日
- 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}
Courtney
2024 年 5 月 2 日
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
Courtney
2024 年 11 月 1 日
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 で Linear Matrix Inequalities についてさらに検索
タグ
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)
