clear all ; close all ; clc

% . . Elliptic test plotting...
A = load_history('CCcut0.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=15;
pclip=98.5;
figure(1)
axes('position',[0.075 0.065 0.5 0.4])
pcut = prctile(C(:),pclip);
PP = [-pcut pcut];

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

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

c1=21;
c2=25;
c3=33;

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

% . . PANEL f)
axes('position',[0.635 0.065 0.08 0.4])
CC1 = load_data(load_history('CCcut1.H'));
aaxis = [0:CC1.n(2)]*CC1.d(2)+CC1.o(2);
pcut = prctile(CC1.data(:),pclip);
PP = [-pcut pcut];
imagesc(aaxis,zaxis(ztodo),CC1.data(ztodo,:) ,PP)
t1=ylabel('Depth (km)');
t2=xlabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
l1=text(-110,1.75,'f)');
set(l1,'FontSize',12)

% . . PANEL g)
axes('position',[0.7775 0.065 0.08 0.4])
CC2 = load_data(load_history('CCcut2.H'));
pcut = prctile(CC2.data(:),pclip);
PP = [-pcut pcut];
imagesc(aaxis,zaxis(ztodo),CC2.data(ztodo,:),PP)
t1=ylabel('Depth (km)');
t2=xlabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
l1=text(-110,1.75,'g)');
set(l1,'FontSize',12)

% . . PANEL h)
axes('position',[0.9175 0.065 0.08 0.4])
CC3 = load_data(load_history('CCcut3.H'));
pcut = prctile(CC3.data(:),pclip);
PP = [-pcut pcut];
imagesc(aaxis,zaxis(ztodo),CC3.data(ztodo,:),PP)
t1=ylabel('Depth (km)');
t2=xlabel('Angle (\circ)');
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
set(t1,'FontSize',10);
set(t2,'FontSize',10);
l1=text(-110,1.75,'h)');
set(l1,'FontSize',12)


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

colormap('gray')

clear A B C;

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

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

axes('position',[0.075 0.56 0.5 0.4])
pcut = prctile(C(:),pclip);
PP = [-pcut pcut];
imagesc(xaxis,zaxis(ztodo),C(ztodo,:),PP)
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
l1=text(18,1.75,'a)');
set(l1,'FontSize',12)

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

c1=21;
c2=25;
c3=33;

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

% . . PANEL b)
axes('position',[0.635 0.56 0.08 0.4])
EC1 = load_data(load_history('ECcut1.H'));
pcut = prctile(EC1.data(:),pclip);
PP = [-pcut pcut];
imagesc(aaxis,zaxis(ztodo),EC1.data(ztodo,:),PP )
t1=ylabel('Depth (km)');
t2=xlabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
l1=text(-110,1.75,'b)');
set(l1,'FontSize',12)

% . . PANEL c)
axes('position',[0.7775 0.56 0.08 0.4])
EC2 = load_data(load_history('ECcut2.H'));
pcut = prctile(EC2.data(:),pclip);
PP = [-pcut pcut];
imagesc(aaxis,zaxis(ztodo),EC2.data(ztodo,:),PP )
t1=ylabel('Depth (km)');
t2=xlabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
l1=text(-110,1.75,'c)');
set(l1,'FontSize',12)

%  . . PANEL d)
axes('position',[0.9175 0.56 0.08 0.4])
EC3 = load_data(load_history('ECcut3.H'));
pcut = prctile(EC3.data(:),pclip);
PP = [-pcut pcut];
imagesc(aaxis,zaxis(ztodo),EC3.data(ztodo,:),PP )
t1=ylabel('Depth (km)');
t2=xlabel('Angle (\circ)');
set(t1,'FontSize',10);
set(t2,'FontSize',10);
set(gca,'YTickLabel',{'2'; '3'; '4'; '5';'6'},'YTick',[2 3 4 5 6])
l1=text(-110,1.75,'d)');
set(l1,'FontSize',12)

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

