%
% Routine to generate a time plot of cruises or deployments
% given start and stop times. 
%
clf;
hold off;



% load the data
load timeplt.dat

d=timeplt;
[nr,nc]=size(d);
clear timeplt;

% convert to YYMMDD to yearday
dd=(d(:,6)/100-floor(d(:,6)/100))*100;
mm1=d(:,6)-dd;
mm=(mm1/10000-floor(mm1/10000))*100;
yy=1900+floor(d(:,6)/10000.);
for i=1:nr;
  yd(i,1)=1976 + (yy(i)-1976) + ...
     julian(round(mm(i)),round(dd(i)),round(yy(i)),0)/365;
  if yd(i,1)>1981;yd(i,1)=yd(i,1)-4;end;
  if yd(i,1)<1977;yd(i,1)=yd(i,1)+1;end;
 
end;

dd=(d(:,7)/100-floor(d(:,7)/100))*100;
mm1=d(:,7)-dd;
mm=(mm1/10000-floor(mm1/10000))*100;
yy=1900+floor(d(:,7)/10000.);
for i=1:nr;
  yd(i,2)=1976 + (yy(i)-1976) + ...
     julian(round(mm(i)),round(dd(i)),round(yy(i)),0)/365;
  if yd(i,2)>1981;yd(i,2)=yd(i,2)-4;end;
  if yd(i,2)<1977;yd(i,2)=yd(i,2)+1;end;
end;

set(0,'defaultlinelinewidth',3);

hold on;
for k=1:length(yy);
    plot([yd(k,1) yd(k,2)],[floor(d(k,1)/10)+1-d(k,10)/100 floor(d(k,1)/10)+1-d(k,10)/100])
end;

set(gca,'xticklabels',['     1976';'     1978';'     1979';'     1980';'     1985';'     1986';'         ']);

%set(gca,'yticklabels',[' 1';' 2';' 3';' 4';' 5';' 6';' N';' M';' O';'  ']);
set(gca,'yticklabels',[' ']);

for ll=1:6;
  text(1977.03,ll+.5,int2str(ll))
end;
  text(1977.03,7.5,'M');
  text(1977.03,8.5,'N');
  text(1977.03,9.5,'O');
grid;
ylabel('Mooring Site');
xlabel('Deployment Year')


%axis([0 365 min(yy)-1 max(yy+1)]);
