-
Notifications
You must be signed in to change notification settings - Fork 182
/
ODFExport.m
91 lines (67 loc) · 2.59 KB
/
ODFExport.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
%% ODF Export
%
%%
% MTEX support the following formats for storing and importing of ODFs:
%
% * .mat file - lossless, specific for MTEX, binary format
% * MTEX file - lossless, specific for MTEX, ASCII format
% * VPSC file - not lossless, ASCII format
% * .txt file - not lossless, ASCII format
%
%
%% Define an Model ODF
%
% We will demonstrate the the import and export of ODFs at the following
% sample ODF which is defined as the superposition of several model ODFs.
cs = crystalSymmetry('cubic');
mod1 = orientation.byAxisAngle(xvector,45*degree,cs);
mod2 = orientation.byAxisAngle(yvector,65*degree,cs);
model_odf = 0.5*uniformODF(cs) + ...
0.05*fibreODF(Miller(1,0,0,cs),xvector,'halfwidth',10*degree) + ...
0.05*fibreODF(Miller(0,1,0,cs),yvector,'halfwidth',10*degree) + ...
0.05*fibreODF(Miller(0,0,1,cs),zvector,'halfwidth',10*degree) + ...
0.05*unimodalODF(mod1,'halfwidth',15*degree) + ...
0.3*unimodalODF(mod2,'halfwidth',25*degree);
plot(model_odf,'sections',6,'silent')
%% Save as .mat file
%
% The most simplest way to store an ODF is to store the corresponding
% variable odf as any other MATLAB variable.
% the filename
fname = fullfile(mtexDataPath, 'ODF', 'odf.mat');
save(fname,'model_odf')
%%
%
% Importing a .mat file is done simply by
load(fname)
%% Export as an generic ASCII file
%
% By default and ODF is exported in an ASCII file which consists of a large
% table with four columns, where the first three column describe the Euler
% angles of a regular 5° grid in the orientation space and the fourth
% column contains the value of the ODF at this specific position.
% the filename
fname = fullfile(mtexDataPath, 'ODF', 'odf.txt');
% export the ODF
export(model_odf,fname,'Bunge')
%%
% Other Euler angle conventions or other resolutions can by specified by
% options to <SO3Fun.export.html export>. Even more control you have,
% if you specify the grid in the orientation space directly.
% define a equispaced grid in orientation space with resolution of 5 degree
S3G = equispacedSO3Grid(cs,'resolution',5*degree);
% export the ODF by values at these locations
export(model_odf,fname,S3G,'Bunge','generic')
%% Export an ODF to an MTEX ASCII File
% Using the options *MTEX* the ODF is exported to an ASCII file which contains
% descriptions of all components of the ODF in a human readable fassion.
% This format can be imported by MTEX without loss.
% the filename
fname = [mtexDataPath '/ODF/odf.mtex'];
% export the ODF
export(model_odf,fname,'Bunge','interface','mtex')
%% Export to VPSC format
%
% TODO!!!
fname = [mtexDataPath '/ODF/odfvpsc.txt'];
export(model_odf,fname,'VPSC')