% visualization of sigle values
% clear all;
% clf;
% clc;
% 
clear num_o_file aa bb;
clear topo xx tt;
clear x_ t_ topo_;	
clear t ytick;

% file name
name = 'hfaao';
num_name= 0;
num_o_file=size(ls('hfaao*txt'));
ext='.txt';

% read all txt files, to construct three variables-time, x-coordinates,
% and corresponding altitudes
for i=1:num_o_file(1)
	fname    =  [name, num2str(num_name),ext];
	fid      =  fopen(fname,'r');
    if(fid==-1)
        break;
    end
	B        =  textscan(fid,'%n');
	fclose(fid);
	Data     =  B{1};
	
	t(i)  =  Data(2)/1e6;
	topo(:,i)=  11000-Data(4:3:end);
    
    % x-coordinates of the grids, only writen once
    if (i==1)
        coord_x=Data(3:3:end)/1000;
    end
        
    num_name    =  num_name + 1;  
end

[xx,tt]=meshgrid(coord_x,t);

% pcolor(xx,tt,topo');
% shading interp;
% colorbar;

aa = min(coord_x):1:max(coord_x);
bb = min(t):0.1:max(t);

[x_, t_] = meshgrid(aa, bb);
topo_ = interp2(xx, tt, topo', x_, t_);

figure(1);
load vik;
cc=vik;
% cc=flipud(cc);
colormap(cc);

pcolor(x_, t_, topo_);
shading interp;
% colorbar;
hold on;
contour(x_, t_, topo_,'LineWidth',1.0,'LevelList',[2000 ],'ShowText','off','LineColor',[1 1 1]);
contour(x_, t_, topo_,'LineWidth',1.0,'LevelList',[4000],'ShowText','off','LineColor',[0 0 0]);
axis([3200,6200,min(t),50]);
caxis([0 6000])
ytick=[0:10:max(t)];
set(gca,'YTick',ytick,'YDir','reverse');
set(gca,'XTick',[3200:500:6200]);
set(gca,'TickDir','out','TickLength',[0.006 0.006]);

    xlabel('X - Width in km');
    ylabel('Times in Myr');

set(gcf,'position',[100 100 600 300]);
set(gca,'position',[0.04 0.07 0.93 0.9]);
set(gcf,'PaperPositionMode','auto');

filename=['fig_Surface_topography'];
print('-dtiff','-r150','-zbuffer',filename)



close(1);
