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

clf
clear
npts=35;

load C3xyz
xm=x;ym=y;zm=z;
load B2xyz
x=boxave(x,1,10);y=boxave(y,1,10);z=boxave(z,1,10);
x1=boxave(xm,1,10);y1=boxave(ym,1,10);z1=boxave(zm,1,10);
x=[x;x1];y=[y;y1];z=[z;z1];
save C3xyzmerged  x y z

% mooring position
xc3=-70.52998;yc3=-68.10010; 

% delete outside points for C3
dlon=1/60;dlat1=.6/60;dlat2=.3/60;
x1=xc3-dlon;x2=xc3+dlon;
y1=yc3-dlat1;y2=yc3+dlat2;
x1=-70.54167;x2=-70.51667;
y1=-68.10833;y2=-68.09667;

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=[xc3,yc3]; % c3

%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),'.b');set(h,'markersize',24);hold on;

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

figure(gcf)
clear 

load C3xyzmerged