clear all ; close all ; clc

% . . Elliptic test plotting...
A = load_history('WZCCcut0.H');
B = load_data(A);
C = B.data;
C = C/abs(max(C(:)));

zaxis = ([0:B.n(1)]*B.d(1)+B.o(1))/1000.;
xaxis = ([0:B.n(2)]*B.d(2)+B.o(2))/1000.;

[u]= find(zaxis < 6);
ztodo = find(zaxis(u) > 2);

acut=20;
pclip=98.5;
figure(1)
axes('position',[0.2 0.34 0.6 0.15])
pcut = prctile(C(:),pclip);
PP = [-pcut pcut];

imagesc(xaxis,zaxis(ztodo),C(ztodo,:),PP)
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2:6])
l1=text(18.5,1.75,'e)');
set(l1,'FontSize',12)

t1=ylabel('Depth (km)');
t2=xlabel('Distance (km)');
%set(t1,'FontSize',12)
%set(t2,'FontSize',12)

c1=3;
c2=4;
c3=4.2;

t1=line([20 40] ,[c1 c1]);
set(t1,'LineWidth',2)
t1=line([20 40] ,[c2 c2]);
set(t1,'LineWidth',2);
t1=line([20 40] ,[c3 c3]);
set(t1,'LineWidth',2);

% . . PANEL f)
axes('position',[0.2 0.24 0.6 0.05])
CC1 = load_data(load_history('WZCCcut1.H'));
aaxis = [0:CC1.n(2)]*CC1.d(2)+CC1.o(2);
pcut = prctile(CC1.data(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,aaxis,CC1.data' ,PP)
t1=xlabel('Distance (km)');
t2=ylabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
l1=text(18.5,-95,'f)');
set(l1,'FontSize',12)

% . . PANEL g)
axes('position',[0.2 0.14 0.6 0.05])
CC2 = load_data(load_history('WZCCcut2.H'));
pcut = prctile(CC2.data(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,aaxis,CC2.data',PP)
t1=xlabel('Distance (km)');
t2=ylabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
l1=text(18.5,-95,'g)');
set(l1,'FontSize',12)

% . . PANEL h)
axes('position',[0.2 0.04 0.6 0.05])
CC3 = load_data(load_history('WZCCcut3.H'));
pcut = prctile(CC3.data(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,aaxis,CC3.data',PP)
t1=xlabel('Distance (km)');
t2=ylabel('Angle (\circ)');
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
set(t1,'FontSize',10);
set(t2,'FontSize',10);
l1=text(18.5,-95,'h)');
set(l1,'FontSize',12)


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

colormap('gray')

clear A B C;

% . . For elliptic
A = load_history('WZECcut0.H');
B = load_data(A);
C = B.data;

C = C/abs(max(C(:)));

axes('position',[0.2 0.84 0.6 0.15])
pcut = prctile(C(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,zaxis(ztodo),C(ztodo,:),PP)
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2:6])
l1=text(18.5,1.75,'a)');
set(l1,'FontSize',12)

t1=ylabel('Depth (km)');
t2=xlabel('Distance (km)');
%set(t1,'FontSize',12)
%set(t2,'FontSize',12)

c1=3;
c2=4;
c3=4.2;

t1=line([20 40] ,[c1 c1]);
set(t1,'LineWidth',2)
t1=line([20 40] ,[c2 c2]);
set(t1,'LineWidth',2);
t1=line([20 40] ,[c3 c3]);
set(t1,'LineWidth',2);

% . . PANEL b)
axes('position',[0.2 0.74 0.6 0.05])
EC1 = load_data(load_history('WZECcut1.H'));
pcut = prctile(EC1.data(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,aaxis,EC1.data',PP )
t1=xlabel('Distance (km)');
t2=ylabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
l1=text(18.5,-95,'b)');
set(l1,'FontSize',12)

% . . PANEL c)
axes('position',[0.2 0.64 0.6 0.05])
EC2 = load_data(load_history('WZECcut2.H'));
pcut = prctile(EC2.data(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,aaxis,EC2.data',PP )
t1=xlabel('Distance (km)');
t2=ylabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
l1=text(18.5,-95,'c)');
set(l1,'FontSize',12)

%  . . PANEL d)
axes('position',[0.2 0.54 0.6 0.05])
EC3 = load_data(load_history('WZECcut3.H'));
pcut = prctile(EC3.data(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,aaxis,EC3.data',PP )
t1=xlabel('Distance (km)');
t2=ylabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'XTickLabel',{'20'; '25'; '30'; '35'},'XTick',[20:5:35])
l1=text(18.5,-95,'d)');
set(l1,'FontSize',12)

%brighten(0.5)
orient tall
print -depsc2 BADZ.eps
dos('epstopdf BADZ.eps');
dos('cp BADZ.pdf ./Fig');
disp(['Finished writing image file'])

