% data selection (geosecs) - shows both local loadjg and network loadjg
clear all
loadjg('fullmap.mat');
figure(1);clg;
plot(lon,lat,'b');axis([-180,180,-90,90]);
xlabel('Longitude');ylabel('Latitude');
hold
loadjg('//popeye.uchicago.edu/jgofs/geosecs(sta,lat,long)');
plot(long,lat,'x');
longsave=long;latsave=lat;stasave=sta;

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(stasave(is));
fprintf(1,'You selected station number %s\n',ev);

str=['//popeye.uchicago.edu/jgofs/geosecs(sta=',ev,')'];
loadjg(str);

% display
figure(2)
%plot(no3(no3>0),-depth(no3>0),tco2(tco2>0)/100,-depth(tco2>0));
plot(no3(no3>0),-depth(no3>0),o2(o2>0)/10,-depth(o2>0));
%xlabel('NO3 (yellow) TCO2/100 (purple)');ylabel('depth');
xlabel('NO3 (yellow) O2/10 (purple)');ylabel('depth');
title(['Station = ',ev]);
end
