%  TestGrid.m
%     make a 2d grid of values from a cruise
%
cl=[0 .2 .4 .6 .8 1 1.2 1.4 1.6 1.8 2];


%load NBP0103.grid.mat;
%load NBP0104.grid.mat;

%   extract a depth interval  (idep=12 is 300 m)
idep=12;
disp(['Extracting depth level ' num2str(stddep(idep))])
[nx,ncast]=size(pt);
xpt=pt(idep,:);

i=find(~isnan(xpt));

xi=20:40:500;
yi=-20:40:300;
[xxi,yyi]=meshgrid(xi,yi);
pti=griddata(xgrid(i),ygrid(i),xpt(i),xxi,yyi);

figure
[Con,Han]=contour(xxi,yyi,pti,cl);
clabel(Con,Han);
title(' 40 km grid');
axis([0 500 -50 300]);
hold on;
plot(xgrid(i),ygrid(i),'r*');
hold off

xi=20:20:500;
yi=-20:20:300;
[xxi,yyi]=meshgrid(xi,yi);
pti=griddata(xgrid(i),ygrid(i),xpt(i),xxi,yyi);

figure
[Con,Han]=contour(xxi,yyi,pti,cl);
clabel(Con,Han);
title(' 20 km grid');
axis([0 500 -50 300]);
hold on;
plot(xgrid(i),ygrid(i),'r*');
hold off

xi=20:10:500;
yi=-20:10:300;
[xxi,yyi]=meshgrid(xi,yi);
pti=griddata(xgrid(i),ygrid(i),xpt(i),xxi,yyi);

figure
[Con,Han]=contour(xxi,yyi,pti,cl);
clabel(Con,Han);
title(' 10 km grid');
axis([0 500 -50 300]);
hold on;
plot(xgrid(i),ygrid(i),'r*');
hold off


