-
Notifications
You must be signed in to change notification settings - Fork 25
/
guiFracPaQ2Dangle.m
143 lines (121 loc) · 5.08 KB
/
guiFracPaQ2Dangle.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
function guiFracPaQ2Dangle(traces, northCorrection, nHistoBins, nRoseBins, ...
flag_histoangle, flag_roseangle, flag_revY, flag_revX, flag_cracktensor, ...
flag_roselengthweighted, flag_rosemean, flag_rosecolour, sColour)
% guiFracPaQ2Dangle.m
% calculates and plots statistics of trace segment angles
%
% David Healy
% July 2014
%% Copyright
% Permission is hereby granted, free of charge, to any person obtaining a
% copy of this software and associated documentation files (the
% "Software"), to deal in the Software without restriction, including
% without limitation the rights to use, copy, modify, merge, publish,
% distribute, sublicense, and/or sell copies of the Software, and to permit
% persons to whom the Software is furnished to do so, subject to the
% following conditions:
%
% The above copyright notice and this permission notice shall be included
% in all copies or substantial portions of the Software.
%
% THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
% OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
% NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
% DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
% OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
% USE OR OTHER DEALINGS IN THE SOFTWARE.
global sTag ;
numTraces = length(traces) ;
traceAngles = [ traces.segmentAngle ]' ;
traceLengths = [ traces.segmentLength ]' ;
v = ver('MATLAB') ;
iRelease = regexp(v.Release, 'R.....') ;
nReleaseYear = str2num(v.Release(iRelease+1:iRelease+4)) ;
% double the trace angle data over 360 degrees
traceAngles2 = doubleAngles(traceAngles, northCorrection) ;
% double the length data too, for length weighting of rose plot
traceLengths2 = [ traceLengths ; traceLengths ] ;
% change angles if axis flipped
if flag_revX
traceAngles2 = reverseAxis(traceAngles2) ;
end ;
if flag_revY
traceAngles2 = reverseAxis(traceAngles2) ;
end ;
% write the trace angles to a text file for EZ-ROSE plotting
sorted_traceAngles2 = sort(traceAngles2) ;
fn = ['FracPaQ2DEZROSE', sTag, '.txt'] ;
fidRose = fopen(fn, 'wt') ;
for i = 1:max(size(traceAngles2))
fprintf(fidRose, '%6.2f\n', sorted_traceAngles2(i)) ;
end ;
fclose(fidRose) ;
if flag_roseangle
f = figure ;
% might implement linear scaling later, if demand exists; equal area is better though
flag_equalarea = 1 ;
if ~flag_roselengthweighted
traceLengths2 = 0 ;
end ;
if flag_equalarea
if flag_rosecolour
roseEqualAreaColour(traceAngles2, nRoseBins, 0, traceLengths2, flag_rosemean, sColour) ;
else
roseEqualArea(traceAngles2, nRoseBins, 0, traceLengths2, flag_rosemean, sColour) ;
end ;
if flag_roselengthweighted
title({['Segment angles (equal area, length weighted), n=', num2str(length(traceLengths))];''}) ;
else
title({['Segment angles (equal area), n=', num2str(length(traceLengths))];''}) ;
end ;
% save to file
guiPrint(f, 'FracPaQ2D_roseangleEqArea') ;
else
roseLinear(traceAngles2, nRoseBins, 0, traceLengths2, flag_rosemean, sColour) ;
if flag_roselengthweighted
title({['Segment angles (linear, length weighted), n=', num2str(length(traceLengths))];''}) ;
else
title({['Segment angles (linear), n=', num2str(length(traceLengths))];''}) ;
end ;
% save to file
guiPrint(f, 'FracPaQ2D_roseangleLinear') ;
end ;
end ;
if flag_histoangle
% histogram of trace angles
f = figure ;
[ nAngles, binAngles ] = hist(traceAngles2, 0:360/nHistoBins:360) ;
if nReleaseYear < 2016
h = msgbox('Warning: FracPaQ needs MATLAB release of R2016a, or later, to plot double y-axis plots.', 'Warning!') ;
uiwait(h) ;
bar(binAngles, nAngles, 1, 'FaceColor', sColour) ;
ylabel('Frequency') ;
ylim([0 max(nAngles)*1.1]) ;
else
yyaxis left ;
bar(binAngles, nAngles, 1, 'FaceColor', sColour) ;
ylabel('Frequency') ;
ylim([0 max(nAngles)*1.1]) ;
yyaxis right ;
hold on ;
bar(binAngles, (nAngles/sum(nAngles))*100, 1, 'FaceColor', sColour) ;
hold off ;
ylim([0 max((nAngles/sum(nAngles))*100)*1.1]) ;
ylabel('Frequency, %') ;
end
xlabel('Trace segment angle, degrees') ;
xlim([-10 370]) ;
set(gca,'XTick', 0:60:360) ;
axis on square ;
box on ;
grid on ;
title({['Trace segment angles, n=', num2str(length(traceLengths))];''}) ;
% save to file
guiPrint(f, 'FracPaQ2D_histoangle') ;
end ;
if flag_cracktensor
guiFracPaQ2Dcracktensor(traces, northCorrection, flag_revY, flag_revX) ;
end ;
end