-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFun_PlotFault.m
More file actions
152 lines (135 loc) · 5.34 KB
/
Copy pathFun_PlotFault.m
File metadata and controls
152 lines (135 loc) · 5.34 KB
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
function Fun_PlotFault(locaSub, depSub, source, grid, epicenter)
% =========================================================================
% Plot a 3-D filled finite-fault surface and hypocentral subfault.
%
% Input:
% locaSub : Subfault-center coordinates [latitude, longitude], N x 2
% depSub : Subfault-center depths [km], N x 1
% source : Hypocentral subfault index [idip, istrike]
% grid : Number of subfaults [Ndip, Nstrike]
% epicenter : Surface epicenter [latitude, longitude]
%
% Grid ordering:
% index = (istrike - 1) * Ndip + idip
%
% Note:
% Depth increases downward through:
% set(gca, 'ZDir', 'reverse')
% =========================================================================
if size(locaSub, 2) ~= 2
error('locaSub must be an N-by-2 matrix: [latitude, longitude].');
end
if numel(grid) ~= 2 || numel(source) ~= 2
error('grid and source must both be two-element vectors.');
end
grid = round(grid(:)');
source = round(source(:)');
depSub = depSub(:);
Ndip = grid(1);
Nstrike = grid(2);
nsub = Ndip * Nstrike;
if size(locaSub, 1) ~= nsub
error(['locaSub contains %d subfaults, but grid requires %d ', ...
'subfaults (%d x %d).'], ...
size(locaSub, 1), nsub, Ndip, Nstrike);
end
if numel(depSub) ~= nsub
error('The length of depSub must equal prod(grid).');
end
if source(1) < 1 || source(1) > Ndip || ...
source(2) < 1 || source(2) > Nstrike
error('source = [idip, istrike] is outside the specified grid.');
end
% Convert [idip, istrike] to linear index.
index = (source(2) - 1) * Ndip + source(1);
%% ------------------------------------------------------------------------
% Reshape subfault-center vectors into a 2-D fault-plane grid
% -------------------------------------------------------------------------
% Each column corresponds to one strike-direction position;
% each row corresponds to one dip-direction position.
latMat = reshape(locaSub(:, 1), Ndip, Nstrike);
lonMat = reshape(locaSub(:, 2), Ndip, Nstrike);
depMat = reshape(depSub, Ndip, Nstrike);
hypoLat = latMat(source(1), source(2));
hypoLon = lonMat(source(1), source(2));
hypoDep = depMat(source(1), source(2));
%% ------------------------------------------------------------------------
% Create figure
% -------------------------------------------------------------------------
figure('Color', 'w', 'Position', [160, 100, 800, 600]);
tiledlayout('flow','TileSpacing','compact','Padding','loose');
nexttile;
hold on;
box on;
%% ------------------------------------------------------------------------
% Plot the fault-plane projection at the surface (Depth = 0 km)
% -------------------------------------------------------------------------
deppro = zeros(size(depMat));
hProjection = surf(lonMat, latMat, deppro, depMat, ...
'FaceColor', 'interp', ...
'FaceAlpha', 0.7, ...
'EdgeColor', [0.25, 0.25, 0.25], ...
'EdgeAlpha', 0.7, ...
'LineStyle', '--', ...
'LineWidth', 0.7, ...
'DisplayName', 'Fault projection at surface');
%% ------------------------------------------------------------------------
% Plot the filled fault surface
% -------------------------------------------------------------------------
% CData = depMat means that the fault color represents depth.
hFault = surf(lonMat, latMat, depMat, depMat, ...
'FaceColor', 'interp', ...
'FaceAlpha', 0.7, ...
'EdgeColor', [0.35, 0.35, 0.35], ...
'EdgeAlpha', 0.7, ...
'LineWidth', 0.7, ...
'DisplayName', 'Finite-fault plane');
% Improve the visual three-dimensional appearance.
shading interp;
lighting gouraud;
% camlight('headlight');
%% ------------------------------------------------------------------------
% Plot surface epicenter
% -------------------------------------------------------------------------
plot3(epicenter(2), epicenter(1), 0, 'kp', ...
'MarkerFaceColor', [0.8902 0.1529 0.4471], ...
'MarkerEdgeColor', 'k', ...
'MarkerSize', 16, ...
'LineWidth', 1.2, ...
'DisplayName', 'Surface epicenter');
%% ------------------------------------------------------------------------
% Plot hypocentral subfault
% -------------------------------------------------------------------------
plot3(hypoLon, hypoLat, hypoDep, 'rp', ...
'MarkerFaceColor', [0.8902 0.1529 0.4471], ...
'MarkerEdgeColor', 'k', ...
'MarkerSize', 18, ...
'LineWidth', 1, ...
'DisplayName', 'Hypocentral subfault');
% Dashed line between surface epicenter and hypocentral subfault.
plot3([epicenter(2), hypoLon], ...
[epicenter(1), hypoLat], ...
[0, hypoDep], 'k--', ...
'LineWidth', 1, ...
'HandleVisibility', 'off');
%% ------------------------------------------------------------------------
% Axis and appearance settings
% -------------------------------------------------------------------------
xlabel('Longitude');
ylabel('Latitude');
zlabel('Depth (km)');
% Seismological/geophysical convention: depth grows downward.
set(gca, 'ZDir', 'reverse');
colormap(slanCM('viridis', 60));
% A suitable initial viewing angle
view(45, 25);
axis vis3d;
cb = colorbar;
cb.Label.String = 'Depth';
cb.FontSize = 14;
set(gca, ...
'FontSize', 16, ...
'LineWidth', 1, ...
'Projection', 'perspective','fontname','Times New Roman');
hold off;
end