-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotOrientationsPF.m
153 lines (147 loc) · 4.99 KB
/
plotOrientationsPF.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
function plotOrientationsPF(input, varargin)
% Function to load and plot grain orientations in pole figures
%
% Points in the pole figure can be colored accoring to the intensity of the pole figure
% or the ODF at the corresponding orientation
%
% Syntax
%
% plotOrientationsPF(inputfile,'cs',cs_ppv,'ss',ss, 'hkl', h)
% plotOrientationsPF(inputfile,'cs',cs_ppv,'ss',ss, 'hkl', h, 'minpf',0.0, 'maxpf',5.)
% plotOrientationsPF(inputfile,'cs',cs_ppv,'ss',ss, 'hkl', h, 'colormap', 'WhiteJet')
% plotOrientationsPF(inputfile,'cs',cs_ppv,'ss',ss, 'hkl', h, 'halfwidth', 10)
% plotOrientationsPF(inputfile,'cs',cs_ppv,'ss',ss, 'hkl', h, 'odfColor', true)
% plotOrientationsPF(inputfile,'cs',cs_ppv,'ss',ss, 'hkl', h, 'output', outputfile)
%
%
% Input
%
% input can either
% - the full path to the file with the list of euler angles, or, (see loadOrientations.m for file format)
% - a list of orientations if they are already known
%
% Required parameters
%
% cs: crystal system
% ss: sample system
% hkl: list of hkl for pole figures
%
% Optional parameters
%
% outputfile : full path to name of file in which to save the image
% odfColor: color points according to ODF intensity. Otherwise, points are colored according to PF intensity
% halfwidth: halfwidth for ODF calculation, in degrees, default is 15
% minpf: minimum for intensity plot (max should be set as well)
% maxpf: minimum for intensity plot (min should be set as well)
% hem: hemisphere (upper or lower, upper by default)
% markersize: 7 by default
% colormap: name of colormap, between single quotes, default is 'plasma', you can use 'WhiteJet', for instance
%
% See also loadOrientations
%
% This is part of the TIMEleSS tools
% http://timeless.texture.rocks/
%
% Copyright (C) S. Merkel, Universite de Lille, France
%
% This program is free software; you can redistribute it and/or
% modify it under the terms of the GNU General Public License
% as published by the Free Software Foundation; either version 2
% of the License, or (at your option) any later version.
% default parameters and parser
p = inputParser;
addParameter(p,'cs',false);
addParameter(p,'ss',false);
addParameter(p,'hkl',false);
addParameter(p,'outputfile',false);
addParameter(p,'odfColor',false,@islogical);
addParameter(p,'halfwidth',15., @isfloat);
addParameter(p,'minpf',false, @isfloat);
addParameter(p,'maxpf',false, @isfloat);
addParameter(p,'hem','upper', @isstring);
addParameter(p,'markersize',7, @isfloat);
addParameter(p,'colormap', 'plasma', @ischar);
parse(p,varargin{:});
odfColor = p.Results.odfColor;
outputfile = p.Results.outputfile;
cs = p.Results.cs;
ss = p.Results.ss;
h = p.Results.hkl;
minpf = p.Results.minpf;
maxpf = p.Results.maxpf;
halfwidth = p.Results.halfwidth;
hem = p.Results.hem;
markersize = p.Results.markersize;
colormap = p.Results.colormap;
if (islogical(cs))
fprintf('\nError: no crystal symmetry provided\n')
return
end
if (islogical(ss))
fprintf('\nError: no crystal sample provided\n')
return
end
if (islogical(h))
fprintf('\nError: no list of hkl provided\n')
return
end
% If input parameter is a char,
% load file and create the corresponding list of orientations
if (ischar(input))
ori0 = loadOrientations(input, cs, ss);
n = size(ori0);
% Else, if input is a list of orientations, just copy them
elseif (isa(input,'orientation'))
ori0 = input;
n = size(ori0);
fprintf('\nStarting from %d orientations\n', n)
end
% Fit an ODF to the data
odf = calcODF(ori0,'halfwidth',halfwidth*degree);
fprintf('\nCalculated an ODF based on grain orientations\n')
if (not(odfColor))
% Plot orientations, colors according to pole figure
% Working on each pole figure individually
nhkl = size(h,2);
f=newMtexFigure('figSize','large','layout',[1,nhkl]);
for i =1:nhkl
thishkl = h(i);
fprintf('\nWorking on %d%d%d pole figure\nCalculating pf value at each orientation\n', h(i).h, h(i).k, h(i).l);
clear colors
v = ori0*thishkl;
pf = calcPoleFigure(odf,thishkl,v);
colors = pf.intensities;
fprintf('\nPlotting the pole figure\n');
if i == 1
plotPDF(ori0,colors,thishkl,'antipodal','MarkerSize',markersize,'all',hem);
else
mtexFig = gcm;
plotPDF(ori0,colors,thishkl,'antipodal','MarkerSize',markersize,'all',hem,'parent',mtexFig.nextAxis);
end
end
f.drawNow;
if (islogical(minpf) || islogical(maxpf))
CLim(gcm,'equal');
else
CLim(gcm,[minpf,maxpf]);
end
mtexColorMap(char(colormap));
mtexColorbar;
else
% Plot orientations, colored based on ODF
fprintf('\nPlotting grain orientations, color based on ODF value for each grain\n')
plotPDF(ori0,eval(odf,ori0),h,'antipodal','MarkerSize',markersize,'all',hem);
if (islogical(minpf) || islogical(maxpf))
CLim(gcm,'equal');
else
CLim(gcm,[minpf,maxpf]);
end
mtexColorMap(char(colormap));
mtexColorbar;
end
if (not (outputfile==false))
% Save plot to the output file
saveas(gcf,outputfile);
fprintf('\nSaved plot of grain orientations in \n\t%s\n', outputfile)
end
end