-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathIHotVol_PickMask.m
67 lines (49 loc) · 1.65 KB
/
IHotVol_PickMask.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
function [Xpoly,Ypoly,INP]=IHotVol_PickEdifice(grdfile,AGES)
%% Hand pick edifice from residual-separated bathymetry
% load residual grid and contour
[Xres,Yres,Zres]=grdread2([grdfile '_residual.grd']);
% zero out negative anomalies
Zres(Zres<=0)=0;
close all
% PICKING ------------ %
% contour residual bathy and plot age data
figure
C=contourf(Xres,Yres,Zres,20);
title('Residual bathymetry');
axis equal
hold on
plot(AGES(:,1),AGES(:,2),'ro-');
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 0.5 1]);
pause(5);
disp(['I cleaned this up as best I can. Please pick a polygon around ' ...
'the edifice of interest']);
% select edifice bounds - will zero residual outside polygon
[Xpoly,Ypoly]=ginput;
% ------------ %
close all
% meshing the X and Y values for polygon
[Xg,Yg]=meshgrid(Xres,Yres);
% find grid values within polygon
INP=inpolygon(Xg,Yg,Xpoly,Ypoly);
Zed=Zres.*INP;
Edifice=Zed;
Zed(Zed==0)=nan;
% output edifice grid
grdwrite2(Xres,Yres,Edifice,'ED.grd')
grdwrite2(Xres,Yres,double(INP),'INP.grd')
% reformat grid (output from grdwrite2 is deprecated and does not cooperate with grdflexure)
system(['grd2xyz ED.grd | xyz2grd -G' grdfile '_edifice.grd -R' grdfile '.trim']);
% de-nan the edifice grid (0 outside)
system(['grdmath ' grdfile '_edifice.grd 0 DENAN = ' grdfile '_edifice.grd']);
% write out the in-polygon grid
[Xg,Yg,Zg]=grdread2([grdfile '_edifice.grd']);
grdwrite2(Xg,Yg,double(INP),'INP.grd');
% contour edifice grid
figure
C=contourf(Xg,Yg,Zg,20);
title('Edifice');
axis equal;
% final display
set(gcf, 'Units', 'Normalized', 'OuterPosition', [0 0 0.5 1]);
disp('You picked this material as your volcanic edifice');
drawnow;