%          that travel with the velocity measured at the current meter
%          would travel to in KD days.
%
%  doshot(cdf,kd) or
%  doshot(cdf,kd,start_time,stop_time)
%
%  example:  doshot('3391-a1h.cdf',1)
%               does a one day shotgun from sta 3391 over the 
%               whole time period
%
%      doshot('3391-a1h.cdf',2,[1990 1 8 13 0 0],[1990 3 27 0 0 0])
%               does a two day shotgun from sta 3391
%               from 3/28/90 13:00 GMT to 4/17/90 00:00 GMT
len=length(cdf);  %tack on cdf suffix if missing
if (cdf(len-3:len)~='.cdf'),
  cdf=[cdf '.cdf'];
  len=length(cdf);  
end
hold off
axis('square')
ax=[210 280 110 180];   % dimensions of plot in Stae Plane Coords (km)
axis(ax)
buoyb=[242.4574  152.7128];  % Buoy B location in State Plane Coords (km)
origin=buoyb;
%
% change to data directory and get cdf data
%
if(nargin==2),
  icyc=0;
  [name,ncyc]=mcdinq(cdf,'cycles');   % number of points in series
  [start_time,stop_time]=mcgtim(cdf);
else
  [icyc,ncyc]=mctime(cdf,start_time,stop_time);
end
%
icyc=0;    % netCDF C notation for first point
u=mcvgt(cdf,'east',icyc,ncyc);       % get all the EAST values
v=mcvgt(cdf,'north',icyc,ncyc);      % get all the NORTH values
t=mcvgt(cdf,'time',1,2);          % get two time values to find sample interval
units=mcagt(cdf,'time','units');  % get time units
%
if(units(1:7)=='seconds'),
  dt=(t(2)-t(1))/3600/24;         % sample interval in days
elseif(units(1:12)=='milliseconds'),
  dt=(t(2)-t(1))/3600/1000/24;   
else
  disp('invalid time units')
  return
end
nsub=1/(4*dt);                           % do 6 points a day
ind=[1:nsub:length(u)];
%scat2(u(ind),v(ind),kd,dt*nsub)
%keyboard;
[x,y]=shot(u(ind),v(ind),kd,dt*nsub);
%
load mbay.sp
plot(mbay(:,1)/1000,mbay(:,2)/1000)      % convert to km
xlabel('km')
ylabel('km')
%
cdf_file=cdf([1:(len-3)]);
kdtit=int2str(kd);
title('Simulated Particle Displacements at LNB');
hold on
x=x+origin(1);
y=y+origin(2);
%
plot(x,y,'gx')    % plot points
plot([ax(1) ax(2)],[origin(2) origin(2)],'c6')  % draw crosshairs on origin
plot([origin(1) origin(1)],[ax(3) ax(4)],'c6')
%  add info to plot
text(0.27,0.19,['Tracking time= ' kdtit ' days'],'sc');
text(0.27,0.27,depth_lbl(cdf,'east'),'sc');
text(0.27,0.23,date_lbl(start_time,stop_time),'sc');
text(0.27,0.14,file_lbl(cdf),'sc');
