% data selection (georges bank) - shows both local loadjg and network loadjg
clear all
load /d5/glenn/xmosaic/htdocs/dods/gbbathy -mat;
figure(1);clg;
lonbathy=reshape(gbbathy(:,1),100,100);
latbathy=reshape(gbbathy(:,2),100,100);
depthbathy=reshape(gbbathy(:,3),100,100);
colormap(gray);pcolor(lonbathy,latbathy,-depthbathy);shading flat;
xlabel('Longitude');ylabel('Latitude');
hold on
% dataset=input('data object = ');
dataset='//kelvin.whoi.edu/globec/ctd1995(cruiseid=en274,'
loadjg([dataset,'lat_begin,lon_begin,cast)']);
plot(-lon_begin,lat_begin,'xy');
longsave=-lon_begin;latsave=lat_begin;castsave=cast;

while(1)
figure(1);
fprintf(1,'Click on station; hit return with cursor in figure to end\n');
[x,y,b]=ginput(1);
if b>3
  return
end
% find point closest to cursor
distsq=(longsave-x).^2+(latsave-y).^2;
[md,is]=min(distsq);
line('EraseMode','none','Xdata',longsave(is),'Ydata',latsave(is),'LineStyle','o');
drawnow

% get data for station
ev=int2str(castsave(is));
fprintf(1,'You selected station number %s\n',ev);

str=[dataset,'cast=',ev,')'];
loadjg(str);

% display
figure(2)
plot(light_tran,-press);
xlabel('Light transmission');ylabel('pressure');
title(['Cast = ',ev]);
end
