% dsc1.m
% depthsurvey.m
% grabs and maps 1-sec ship depth data
% saves z,y,z data in depth*.mat file
% used to make dsc1final.jpg
% 2/23/02

% for ii=1:1000 
clf;clear all
npts=36;

load depthC1.dat
z=depthC1;z(1:1,:)=[]; % c1
x=z(:,1);y=z(:,2);z=z(:,3);

%edit raw data
n=find(z<200);
x(n)=[];y(n)=[];z(n)=[];
n=find(z>800);
x(n)=[];y(n)=[];z(n)=[];

% save data
save c1xyz x y z

% box average data 
x=boxave(x,1,10);y=boxave(y,1,10);z=boxave(z,1,10);

% delete outside points for C1
x1=-69.38000 + .00167 + .00083;x2=-69.349;
y1=-68.05500;y2=-68.04500;
ppp=find(x>=x1 & x<=x2 & y>=y1 & y<=y2);
x=x(ppp);y=y(ppp);z=z(ppp);

% interpolate it to a regular grid
xi=linspace(min(x),max(x),npts);
yi=linspace(min(y),max(y),npts);
[Xi,Yi]=meshgrid(xi,yi); % create meshgrid
Zi=griddata(x,y,z,Xi,Yi); % grid the scattered data at Xi and Yi points
[cs,hh]=contour(Xi,Yi,Zi,'l','k');hold on;
%clabel(cs,hh,'fontsize',10,'color','k','rotation',0)
hold on;

% enter station location
stnloc=[-69.3632 -68.049]; % c1
%plot station location
h=plot(stnloc(1),stnloc(2),'.b');set(h,'markersize',24);
set(gca,'fontw','bold')
grid

% plot ships track
h=plot(x,y,'r.');set(h,'markersize',12)
aspect5(-68);
mapax(2,0,.5,1);

%Color contour
figure(2);clf;
pcolor(xi,yi,Zi);shading interp;hold on
colormap(flipud(jet));colorbar;
[cs,hh]=contour(Xi,Yi,Zi,'col','w');hold on;
 clabel(cs,hh,'fontsize',10,'color','w','rotation',0)
 %set(gca,'fontw','bold')
h=plot(x,y,'k.');set(h,'markersize',20,'linew',3);hold on;
h=plot(stnloc(1),stnloc(2),'.r');set(h,'markersize',24);hold on;


A=[x1,x2,y1,y2];
axis(A);
mapax(1,0,.25,2);
aspect5(-68);
grid
set(gca,'fontw','bold','fonts',12)
title('C1 Bathymetry M')

figure(gcf)

figure(3)
clf
plot(z)
set(gca,'ydir','reverse')
set(gca,'fontw','bold','fonts',20)
figure(gcf)

figure(1)
clear all
load c1xyz
