% ROUTINE FOR GETTING START/STOP INFO ON TRANSECTS
% FROM ALBATROSS SCS FILES

wd=menu('Which ship file?','gps1.new','merged ship.dat');
if wd==1;
  % assumes one has run "ridcomma.exe" to make "gps1.aco" space delimited
  load gps1.new
  d=gps1;
  ind=[2 6 7];% index for time lat lon
  % define subsample rate of posting
  ssr=120;
  pssr=50;
else;
  load /data5/jmanning/ship/al9805/ship.dat;
  d=ship;
  ind=[1 2 3];% index for time lat lon
  % define subsample rate of posting
  ssr=1;
  pssr=20;
end;


% define approximate (yday1_local) local times of six transect sets
tt=[125.25 125.8 125.9 126.15 126.36 126.6 126.89 127.166 127.43 127.542 127.76 127.854 ];


ss=[ ];
for it=7:2:7;
  figure(1);
  id=find(d(:,ind(1))>tt(it)&d(:,ind(1))<tt(it+1));
  plot(d(id(1:ssr:length(id)),ind(3)),d(id(1:ssr:length(id)),ind(2)));
  title(['VPR #',num2str((it+3)/2)]);
  for ip=1:pssr:length(id);
    if d(id(ip),ind(2))>d(id(ip)-1,ind(2));colval='r';else;colval='g';end;
    %color text according to N/S direction
    text(d(id(ip),ind(3)),d(id(ip),ind(2)),...
    num2str(d(id(ip),ind(1)),6),'fontsize',6,'color',colval);
  end;
  disp('Enter the start and end for each section as a two column vector');
  sst=input('now:');
  ss=[ss; sst];
  pthis;
  % colorcode shipt track with temp
  figure(2);
  clf;
  dsave=d;
  d=d(id,:);
  ccsst;
  text(d(1,3),d(1,2),['VPR deployment#',num2str((it+3)/2)]);
  keyboard;
  d=dsave;
end; 

% Now we need to extract lat & lon for these times
% and we can do that by interpolation

slat=interp1(d(1:length(d),ind(1)),d(1:length(d),ind(2)),ss(:,1));
slon=interp1(d(1:length(d),ind(1)),d(1:length(d),ind(3)),ss(:,1));
elat=interp1(d(1:length(d),ind(1)),d(1:length(d),ind(2)),ss(:,2));
elon=interp1(d(1:length(d),ind(1)),d(1:length(d),ind(3)),ss(:,2));

% form final matrix
fv=[ss(:,1) slat slon ss(:,2) elat elon];
fploopy(fv)

[nr nc]=size(fv);

for ik=1:nr;
  stime(ik,:)=calday(98,ss(ik,1));
  etime(ik,:)=calday(98,ss(ik,2));
end;

fv=[stime ss(:,1) slat slon etime ss(:,2) elat elon];


