Skip to content

Commit

Permalink
test_dip.m checks for existence of CVX
Browse files Browse the repository at this point in the history
  • Loading branch information
jploveless committed Jun 20, 2022
1 parent b4853f7 commit aee4437
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions test_dip.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@
title('Input slip distribution');
caxis([-1 1]);
colormap(bluewhitered);
% Add observed displacements
hold on
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
axis equal

% Visualize estimated dip slip in a new figure
meshview(p.c, p.v, u(2:3:end));
title('Basic slip estimate, beta = 100');
Expand All @@ -23,13 +29,21 @@
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
quiver(s.x, s.y, scale_factor*pred(1:3:end), scale_factor*pred(2:3:end), 0); % Plot predictions as manually scaled vectors
axis equal

%### Estimate with different smoothing weight, reusing the partial derivatives output in line 10
[u_500, pred_500] = triinvx(p, s, 500, 'partials', gsave);
meshview(p.c, p.v, u_500(2:3:end));
title('Basic slip estimate, beta = 500');
caxis([-1 1]);
colormap(bluewhitered);
% Add observed and estimated displacements
hold on
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
quiver(s.x, s.y, scale_factor*pred_500(1:3:end), scale_factor*pred_500(2:3:end), 0); % Plot predictions as manually scaled vectors
axis equal


%### Estimate enforcing reverse slip

Expand All @@ -38,6 +52,13 @@
title('Force reverse slip, beta = 100');
caxis([-1 1]);
colormap(bluewhitered);
% Add observed and estimated displacements
hold on
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
quiver(s.x, s.y, scale_factor*pred_rev(1:3:end), scale_factor*pred_rev(2:3:end), 0); % Plot predictions as manually scaled vectors
axis equal


%### Estimate enforcing reverse slip and no slip at fault edges

Expand All @@ -46,6 +67,13 @@
title('Force reverse slip, no edge slip, beta = 100');
caxis([-1 1]);
colormap(bluewhitered);
% Add observed and estimated displacements
hold on
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
quiver(s.x, s.y, scale_factor*pred_rev_noedge(1:3:end), scale_factor*pred_rev_noedge(2:3:end), 0); % Plot predictions as manually scaled vectors
axis equal


%### Estimate using total variation regularization, outputs requested as structures
if exist('cvx_begin') ~= 0
Expand All @@ -54,6 +82,13 @@
title('TVR, beta = 0.01');
caxis([-1 1]);
colormap(bluewhitered);
% Add observed and estimated displacements
hold on
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
quiver(s.x, s.y, scale_factor*pred_tvr(1:3:end), scale_factor*pred_tvr(2:3:end), 0); % Plot predictions as manually scaled vectors
axis equal


%### Estimate using total variation regularization, forcing reverse slip and no slip at edges, outputs requested as structures

Expand All @@ -62,6 +97,12 @@
title('TVR, force reverse slip, no edge slip, beta = 0.01');
caxis([-1 1]);
colormap(bluewhitered);
% Add observed and estimated displacements
hold on
scale_factor = 50; % Manual scaling factor
quiver(s.x, s.y, scale_factor*s.eastVel, scale_factor*s.northVel, 0); % Plot data as manually scaled vectors
quiver(s.x, s.y, scale_factor*pred_tvr_rev_noedge(1:3:end), scale_factor*pred_tvr_rev_noedge(2:3:end), 0); % Plot predictions as manually scaled vectors
axis equal
else
disp('CVX package not found.')
end

0 comments on commit aee4437

Please sign in to comment.