anim_joint_distribution.m 1.98 KB
clear all;
close all;


dossier=['temp1'];
path=['/home/bauj0001/projets/WIM/output/',dossier,'/',dossier,'.nc'];

x=ncread(path,'x_axis');
t=ncread(path,'time');
om=ncread(path,'omega');
spectre=ncread(path,'Spectrum');
Dave=ncread(path,'Dave');
Dmax=ncread(path,'Dmax');
FSD=ncread(path,'Floe size distribution');
Fsize=ncread(path,'floe size');
thick=ncread(path,'Ice thickness');
conc=ncread(path,'Ice concentration');
Hs=ncread(path,'significant height');
IDT=ncread(path,'Ice Thickness Distribution');
hcat=ncread(path,'thickness categories');


fig=figure(1);
u = fig.Units;
fig.Units = 'inches';
set(fig,'outerposition',[3 3 12 10])

cm=colormap('jet');


cm1(1,:)=[1 1 1];
for i=2:10
    cm1(i,:)=[1-0.08*i 1-0.06*i 1];
end
cmap(1:10,:)=cm1;
cmap(11:59,:)=cm(16:end,:);


 w = waitforbuttonpress;
%figure
%filename = 'joint_distribution_anim.gif';

for j=1:length(t)

FSD1=reshape(FSD(j,j,:,:),length(Fsize),length(hcat));

IDT1=IDT(j,:);
for i=1:length(hcat)
    FSD1(:,i)=FSD1(:,i)*IDT1(i);
    nfloe(:,i)=((FSD1(:,i)*(5000)^2)./Fsize.^2) ;
end
 nfloe=nfloe/sum(sum(nfloe));
FSD2(j,:)=sum(FSD1,2);

subplot(2,2,1)
hh=surf(hcat,Fsize,nfloe);
 shading interp
% 
zoom(1.5)
caxis([0 0.06])

colormap(cmap)
   axis([0.1 10 0 400 0 0.1])
 view(108,60)
   
   xlabel('Ice thickness [m]')
   ylabel('Floe size [m]')
   zlabel('area fraction')
   subplot(2,2,2)
nfloe2=((FSD2(j,:)*5000^2)./Fsize.^2')/sum((FSD2(j,:)*5000^2)./Fsize.^2');
   plot((Fsize),nfloe2)
   
   axis([0 400 0 1])
   xlabel('Floe size [m]')
   ylabel('normalized number of floe')
 
   subplot(2,2,3:4)
   plot(x,thick)
   hold on
   plot(x(j),thick(j),'ro','markerfacecolor','r')
   hold off
   xlabel('distance [km]')
   ylabel('Average  ice thickness [m]')
%pause(0.02) 
 w = waitforbuttonpress;

% drawnow
% frame = getframe(1);
% im = frame2im(frame);
% [A,map] = rgb2ind(im,256); 
% 	if j == 1;
% 		imwrite(A,map,filename,'gif','LoopCount',Inf,'DelayTime',0);
% 	else
% 		imwrite(A,map,filename,'gif','WriteMode','append','DelayTime',0);
% 	end
end