

% a matlab plotting program to read successive matrices from disk files
% this version used for geoadj model, among others. 

clear all
close all

%  Set some default graphics things.
set(0,'DefaultTextFontSize',12)
set(0,'DefaultAxesFontSize',12)
set(0,'DefaultAxesLineWidth',1.2)
set(0,'DefaultLineLineWidth',1.0)


load what.dat
nx = what(1);
ny = what(2);
nz = what(3);
dx = what(5);
dy = what(6);
x1 = what(7);
y1 = what(9); 


x1 = 0.
y1 = 0.

x = zeros(nx,1); y = zeros(ny,1);

for i=1:nx;
x(i) = x1 + (i-1)*dx;
x(i) = x(i)/1000.;
end;
for i=1:ny;
y(i) = y1 + (i-1)*dy;
y(i) = y(i)/1000.;
end;
       

 load looktim.dat

[ntim, kkk] = size(looktim)

h1 = zeros(ny, nx); h2 = h1; h3 = h1;        

load basin1.dat
load basin2.dat
load basin3.dat        

% h1 is layer 1 eta, h2, h3 are U1, V1.

 for i=1:ntim;

  
 n1 = (i-1)*ny + 1
 n2 = n1 + ny - 1


 h1(:,:) = basin1(n1:n2,:);
 h2(:,:) = basin2(n1:n2,:); 
 h3(:,:) = basin3(n1:n2,:);

 figure
 
 clf reset
 
 orient tall
 
 h1 = h1;
 ha = mean(mean(h1))
 h1 = h1 - ha;
 
 
% replace the largest h1 elements (near the source) with 1.0

toobig = 30.
toosmall = -30.


% try rescaling to give the little ones a chance

v = (h2.^2 + h3.^2).^0.5;
vmax = max(max(v)) + 0.000001

% subsample
nxs = 3;
nys = 3;
myc = 0;
mxc = 0;

for m1 = 1:nys:ny
myc = myc + 1;

mxc = 0;
for m2 = 1:nxs:nx
mxc = mxc + 1;

h2s(myc,mxc) = h2(m1,m2);
h3s(myc,mxc) = h3(m1,m2);
xs(mxc) = x(m2);
ys(myc) = y(m1);

end
end


orient tall

subplot(2,1,2)

quiver(xs,ys,h2s,h3s,2.,'b')
xlabel('East, km')
ylabel('North, km')
axis([0 max(xs) 0 max(ys) ])
% axis('square')

% add the equator

 xx = [0. x(nx)];
 yd2 = y(ny)/2.;
 yy = [yd2 yd2];
 hold on
% line(xx,yy)
 


 subplot(2,1,1)
 orient tall

 pcolor(h1)
 mesh(h1) 
 
 view(-30., 50.)
 
 h9p = 7.
 h9m = -2
 axis([0 nx 0 ny h9m h9p ])
  
 xlabel(' ');  ylabel(' '); zlabel('Displacement, m');           
  
 % add the time
 tim = looktim(i)
 title(['Time = ',num2str(tim), ' days,     Mean height =',num2str(ha),' m,   Max Speed = ',num2str(vmax),' m/sec'])
                             
 pause;

 end
 end
