% dsc2A
% depthsurvey.m
% grabs and maps 1-sec ship depth data
% saves z,y,z data in depth*.mat file
% to make final C2 mooring map
% 2/23/02

clf
npts=30;

load C2xyzA
x=xA;y=yA;z=zA;
% load C2xyz

x=boxave(x,1,10);y=boxave(y,1,10);z=boxave(z,1,10);

% mooring position
xc2=-70.02883;yc2=-68.22218; 

% delete outside points for C2
dlon=1.2/60;dlat1=.6/60;dlat2=.3/60;
x1=xc2-dlon;x2=xc2+dlon;
y1=yc2-dlat1;y2=yc2+dlat2;
ppp=find(x>=x1 & x<=x2 & y>=y1 & y<=y2);
x=x(ppp);y=y(ppp);z=z(ppp);
A=[x1 x2 y1 y2];

% 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=[-70.02883 -68.22218]; % c2 
%plot station location
h=plot(stnloc(1),stnloc(2),'*r');set(h,'markersize',24);
set(gca,'fontw','bold')
grid

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


%Color contour
figure(1);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;

axis(A);
mapax(1,0,.25,2);
aspect5(-68);grid
set(gca,'fontw','bold','fonts',12)
title('C2 Bathymetry (m)')

figure(gcf)
