% data selection (eqpac)
clear all
loadjg('//dataone.whoi.edu/jgofs/eqpac/tt011/insitupp(event,lat,lon)');

% select a station
figure(1);clg
plot(lon,lat,'x',lon,lat);
xlabel('Longitude');ylabel('Latitude');
lonsave=lon;latsave=lat;eventsave=event;
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 event number %s\n',ev);

str=['//dataone.whoi.edu/jgofs/eqpac/tt011/insitupp(event=',ev,')'];
loadjg(str);

% display
figure(2)
plot(prim_p,-ndepth,light,-ndepth);
xlabel('PP (yellow) Light (purple)');ylabel('depth');
title(['Event = ',ev]);
end
