-
Notifications
You must be signed in to change notification settings - Fork 0
/
plotAllperms.m
160 lines (149 loc) · 4.88 KB
/
plotAllperms.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
function plotAllperms(sol,iStep,Ne, jMAP, Nx,Ny,maxColor,minColor)
% This function plots all the permeability fields at a given iStep
% There are Ne RML realizations and MAP estimate (total Ne + 1
% realizations)
% Written by Mehrdad Gharib Shirangi, May
tStep = 210;
close all
set(0,'defaultaxesfontsize',14);
set(0,'defaulttextfontsize',14);
FontSize = 14;
% ================================================
% Nx = 50; Ny = 50;
Nz = 1; maxnwells = 8;
binWells = sol(1:maxnwells);
locs = sol(maxnwells+1:3*(maxnwells));
locs = reshape(locs,2,length(locs)/2)';
locs = [locs zeros(length(binWells),1)]; % Added column for drill order
injLocs = locs((binWells==-1),:);
prodLocs = locs((binWells==1),:);
ninj = size(injLocs,1);
nprod = size(prodLocs,1);
% Add drill order
drillNumber = 0;
injIndx = 0;
prodIndx = 0;
for i = 1:length(binWells)
if binWells(i) < 0
drillNumber = drillNumber + 1;
injIndx = injIndx + 1;
injLocs(injIndx,end) = drillNumber;
locs(i,end) =drillNumber;
elseif binWells(i) > 0
drillNumber = drillNumber + 1;
prodIndx = prodIndx + 1;
prodLocs(prodIndx,end) = drillNumber;
locs(i,end) =drillNumber;
end
end
% nctrlpers = length(ctrlPeriodVec);
% ctrls = sol(3*(maxnwells)+1:end);
% ctrls = reshape(ctrls,maxnwells,nctrlpers);
%
% injCtrls = ctrls((binWells==-1),:);
% prodCtrls = ctrls((binWells==1),:);
% ================================================
well = locs;
welltype =binWells;
Hard = [];
Hardtype = []; %[2,2,2];
figure(1);
% set(gcf,'units','normalized','outerposition',[0 0 1 1]);
if ( Ne < 6)
M = 2; N = 3; % dimension of the subplot
set(gcf,'units','normalized','outerposition',[0 0 0.55 0.72]);
elseif ( Ne < 7)
M = 3; N = 3; % dimension of the subplot
set(gcf,'units','normalized','outerposition',[0 0 0.55 1]);
else
set(gcf,'units','normalized','outerposition',[0 0 0.75 1]);
M = 3; N = 4; % dimension of the subplot
end
% s= 'permx.in';
s = 'mtrue.in';
m = load(s); %m = log(m);
figure(1);
if ( Ne < 7)
subplot(M,N,1)
else
subplot(M,N,2)
end
plot2Dperm(m,Nx,Ny,well,welltype,FontSize,maxColor,minColor); %colorbar('Fontsize',18)
title('Truth','FontSize',22)
failCounter = 0;
if (iStep <2) % plot prior realizations
iStep = 2;
i = 0;
for jens = [1:Ne]
% disp('yes')
i = i + 1 ;
s =['results.' num2str(iStep) '/mprior' num2str(iStep) '_' num2str(jens) '.in'];
% -----------------------------
fid = fopen(s, 'r');
if fid == -1
failCounter = failCounter + 1;
s =['results.' num2str(iStep) '/mprior' num2str(iStep) '_' num2str(Ne+failCounter) '.in'];
% continue
end
% else
fclose(fid);
% end
% -----------------------------
m = load(s);
figure(1);
if ( Ne < 6)
subplot(M,N,1+i)
else
subplot(M,N,2+i)
end
plot2Dperm(m,Nx,Ny,[],[],FontSize,maxColor,minColor); %colorbar('Fontsize',18)
if jens == jMAP
title(['Prior Mean'],'FontSize',22)
else
title(['Prior # ' num2str(jens)],'FontSize',22)
end
end
iStep = 1;
else
i = 0;
for jens = [1:Ne]
i = i + 1 ;
s =['results.' num2str(iStep) '/mcond' num2str(iStep) '_' num2str(jens) '.out'];
% -----------------------------
fid = fopen(s, 'r');
if fid == -1
failCounter = failCounter + 1;
disp(['File ' s ' not found \n'])
s =['results.' num2str(iStep) '/mcond' num2str(iStep) '_' num2str(Ne+failCounter) '.out'];
% continue
else
fclose(fid);
end
% ----------------------------- % Added April 7 2014
m = load(s);
figure(1);
if ( Ne < 6)
subplot(M,N,1+i)
else
subplot(M,N,2+i)
end
% plot2Dperm(m,Nx,Ny,well(1:iStep-1,:),welltype(1:iStep-1),FontSize); %colorbar('Fontsize',18)
plot2Dperm(m,Nx,Ny,well(1:min(iStep,size(well,1)),:),welltype(1:min(iStep,length(welltype))),FontSize,maxColor,minColor); %colorbar('Fontsize',18)
if jens == jMAP
title(['MAP'],'FontSize',22)
else
title(['RML # ' num2str(jens)],'FontSize',22)
end
end
end
t = (iStep-1) * tStep;
% figure(2)
% s ='MAP--';
% s1 = [s '.fig']; s2 = [s '.emf']; s3 = [s '.pdf']
% saveas2(s1); saveas2(s2); saveas2(s3);
%
figure(1)
s =['allreal' num2str(iStep)];
s1 = [s '.fig']; s2 = [s '.emf']; s3 = [s '.pdf'];
saveas2(s1); saveas(gcf,s,'emf'); saveas2(s3);
% %% Plotting each one separately