forked from williamBarnhart/faultResampler
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfaultResampler.m
110 lines (91 loc) · 2.75 KB
/
faultResampler.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
close all
clear all
global b x2 y2 covd2
% FAULTRESAMPLER Tool for generating optimally discretized model fault
% planes
%
% Usage
% Script, no function
%
% Edited June 24, 2010
% Cornell University
%
% Updates
% November 9, 2010: Added lines to calcScales.m to allow for free rake
% inversion. Also added invertJRI_freerake.m for
% free rake inversions. Changed citation to
% appropriate journal citation.
%
% This program generates fault models for inversions of slip from GPS and
% InSAR observed surface displacements. It then conducts a final inversion
% of slip using the optimal fault model.
%
% Citation: Barnhart, W.D., R.B. Lohman (2010) Automated fault model
% discretization for inversions for coseismic slip distributions. Journ.
% Geophys. Res. V.115, B10419
%
% Turn warnings off singular matrices and delaunay triangulations as first
% iterations will have singular Green's matrices or too few model
% parameters.
% warning off MATLAB:nearlySingularMatrix
% warning off MATLAB:delaunayn:DuplicateDataPoints
% warning('off','Duplicate data points have been detected and removed. The Triangulation indices are defined with respect to the unique set of points in DelaunayTri property X.')
%
warning off
loadResampData
makeStartFault_multi
OK = 0;
iter= 1;
while OK<1
calcScales_multi
makeNewMesh_multi
checkScales_multi
end
% Do inversion of final
nPatch = length(patchstruct);
switch rake_type
case 'free'
[gsmooth,G, Gg, slip, synth, mil] = inversionFreeRake(patchstruct, resampstruct, Dnoise, lambdas, triId, 0);
% [gsmooth,G, Gg, slip, synth, mil] = invertJRI_freerake(patchstruct, resampstruct, Dnoise, lambdas, triId, 0);
case 'fixed'
[gsmooth,G, Gg, slip, synth] = inversionFixedRake(patchstruct, resampstruct, Dnoise, lambdas, triId, 0);
end
rotateFinal
figure
patch([patch_new1.yfault], [patch_new1.zfault], slip(1:length(patch_new))')
axis image
set(gca,'ydir', 'reverse')
colorbar
title('Final Slip Distribution')
saveas(gcf,'final_slip_distribution.png')
%Create matrix to save outputs
resultstruct = [];
resultstruct.patch_new1 = patch_new1;
resultstruct.patch_new = patch_new;
resultstruct.slip = slip;
figure
subplot(3,1,1)
patch(boxx,boxy, data');
axis image
shading flat
colorbar
title('Data')
subplot(3,1,2)
patch(boxx,boxy, synth')
axis image
shading flat
colorbar
title('Synthetic')
subplot(3,1,3)
patch(boxx,boxy, data'-synth')
axis image
shading flat
colorbar
title('Data Misfit')
saveas(gcf,'final_model.png')
resultstruct.boxx = boxx;
resultstruct.boxy = boxy;
resultstruct.data = transpose(data);
resultstruct.synth = transpose(synth);
save('resultstruct.mat','resultstruct');
disp('Final outputs saved!')