%Plots some standard results from the getrays function
%Change and disfigure at your will
%written by Keli Karason, karason@mit.edu

clear subs labels
  
%Plotting
figure(1)
clf
orient tall
ppos = get(gcf,'PaperPosition');
su = get(gcf,'Units');
pu = get(gcf,'PaperUnits');  
set(gcf,'Units',pu);
spos = get(gcf,'Position');
set(gcf,'Position',[spos(1)-(ppos(3)-spos(3)) spos(2)-(ppos(4)-spos(4)) ppos(3) ppos(4)])
set(gcf,'Units',su)

subs(1)=subplot(311);
plot(x,z,'k')
axis ij
axis([0 100 0 50]);
labels=text(x(end,:),z(end,:)-0.1,num2str(theta),'color','r');
xlabel('Distance (km)','fontweight','demi','fontsize',14)
ylabel('Depth (km)','fontweight','demi','fontsize',14)
title('Rays','fontweight','demi','fontsize',16)

% traveltime plot
subs(2)=subplot(312);
%Selecting only those rays that end at the surface, 
%note can still produce erranous results
it=find(abs(z(end,:))<1e-5)';
plot(x(end,it),t(end,it),'b.','markersize',10,'markerfacecolor','b');
labels=[labels;text(x(end,it),t(end,it),num2str(theta(it)),'color','r')];
xlabel('Distance (km)','fontweight','demi','fontsize',14)
ylabel('Time (s)','fontweight','demi','fontsize',14)
title('Traveltime for rays reaching the surface','fontweight','demi','fontsize',16)
axis([0 100 0 10]);

subs(3)=subplot(313);
plot(x,z,'--k')
hold on
plot(xwf,zwf)
axis ij
axis([0 100 0 50]);
xlabel('Distance (km)','fontweight','demi','fontsize',14)
ylabel('Depth (km)','fontweight','demi','fontsize',14)
title('Wavefronts','fontweight','demi','fontsize',16)

disp(['Zoom in to see the red labels for reference to theta,' 10 'type: "delete(labels)" at the prompt to remove them'])
set(subs,'fontweight','demi','fontsize',12)


figure
% traveltime plot
%Selecting only those rays that end at the surface, 
%note can still produce erranous results
it=find(abs(z(end,:))<1e-5)';
plot(x(end,it),t(end,it),'b.','markersize',10,'markerfacecolor','b');
%labels=[labels;text(x(end,it),t(end,it),num2str(theta(it)),'color','r')];
xlabel('Distance (km)','fontweight','demi','fontsize',14)
ylabel('Time (s)','fontweight','demi','fontsize',14)
title('Traveltime of rays that reach the surface','fontweight','demi','fontsize',16)
axis([10 80 4 9]);
