% data selection (N. Atl. sections)
% Edits made December 11, 2002 rcg
% 	Replace clg with clf.  replace object
%		//puddle.mit.edu/s24_36n
% with
%		//globec.whoi.edu/globec/test)
clear all
loadjg('//globec.whoi.edu/test(station,lat,lon)');

% select a station
figure(1);clf
plot(lon,lat,'x',lon,lat);
xlabel('Longitude');ylabel('Latitude');
lonsave=lon;latsave=lat;eventsave=station;
hold

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=(lonsave-x).^2+(latsave-y).^2;
[md,is]=min(distsq);
plot(lonsave(is),latsave(is),'o');
drawnow

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

str=['//globec.whoi.edu/test(station,lat,lon,press,o2,sigth,station=',ev,')'];
loadjg(str);

% display
figure(2)
plot(o2,-press,'k-',sigth,-press,'r-');
xlabel('O2 (black) Sigth (red)');ylabel('depth');
title(['Station = ',ev]);
end
