1 |
x=rdmds('XC');x=x(:,1)/1e3; % X coordinate (km) |
2 |
y=rdmds('YC');y=y(1,:)/1e3; % Y coordinate (km) |
3 |
t0=rdmds('T',0); % Initial T |
4 |
dz=144*rdmds('hFacC'); % Level thicknesses |
5 |
D=sum(dz,3); % Total water depth |
6 |
D=max(D,.001); % avoid division by zero later |
7 |
freq=100; % Output frequency |
8 |
|
9 |
figure(1) % Create a figure window |
10 |
pos=get(gcf,'Position'); % Set aspect ratio and size of image |
11 |
set(gcf,'Position',[pos(1:2) 320*[1 .75]]); |
12 |
set(gcf,'Color',[1 1 1]); % White background for movie |
13 |
mov=avifile('dome.avi'); % Name of AVI movie file |
14 |
mov.Quality=100; mov.Fps=10; % Quality and frames per second |
15 |
|
16 |
[t,nits]=rdmds('T',Inf); % Read last snap-shot |
17 |
nits=120*freq; |
18 |
|
19 |
m=t; m(find(m~=0))=1; % Create a mask |
20 |
k=max(sum(m,3),1); % Index of bottom level |
21 |
[i,j]=ndgrid(1:length(x),1:length(y)); % I,J indices |
22 |
ijk=sub2ind(size(t),i,j,k); % I,J,K indices of bottom level |
23 |
|
24 |
|
25 |
for iter=freq:freq:nits; |
26 |
s=rdmds('S',iter); % Read snap-shot |
27 |
|
28 |
subplot(211) |
29 |
pcolor(x,y, sq(s(ijk))' ); % Plot tracer at ocean bottom |
30 |
shading flat |
31 |
caxis([1 2]) |
32 |
colorbar |
33 |
title('Tracer concentration on bottom') |
34 |
|
35 |
subplot(212) |
36 |
pcolor(x,y, sq( sum(s.*dz,3)./D )' ); % Plot tracer inventory |
37 |
shading flat |
38 |
caxis([1 1.6]) |
39 |
colorbar |
40 |
title('Tracer inventory (vertical average)') |
41 |
|
42 |
drawnow |
43 |
frame=getframe(gcf); mov=addframe(mov,frame); % Add to movie |
44 |
end |
45 |
|
46 |
mov=close(mov); % Finish writing the movie |