function [temp,sal,jd]=getts(cdf,start,stop);
%GETV gets velocity time series from cdf file(s)
%  USAGE 
%     [temp,sal,jd]=getts(cdf,start,stop);
%     or
%     [temp,sal,jd]=getts(cdf);
% 
%  where: cdf = string containing the name of the cdf file, or a 
%               string array containing the names of multiple cdf files, i.e.
%               cdf=['cdf_file1.cdf'
%                    'cdf_file2.cdf'
%                    'junk.cdf     '];
%         start = [yyyy mm dd hh mi sc];
%         stop  = [yyyy mm dd hh mi sc];
%
%    if start and stop are missing, then the series overlapping in time are 
%     returned.  U and V must be var1 and var2 in cdf file.
%
%         jd = julian day 
%
var1='temp';   % the u component of velocity
var2='salinity';  % the v component of velocity
%
[m,n]=size(cdf);
if nargin==1,
  if m==1,
    [start,stop]=mcgtim(cdf);    %get whole file if only 1 cdf file
  else
    [start,stop]=overlap(cdf);   %for multiple files, get overlapping data
    [icyc,ncyc,jd]=mctime(cdf(1,:),start,stop);
    nt=length(jd);
  end
else
  jd0=julian(start);
  jd1=julian(stop);
  [icyc,ncyc,jd]=mctime(cdf(1,:),start,stop);
  delt=jd(2)-jd(1);
  nt=round((jd1-jd0)/delt)+1;    % how long is the output series?
  jda=[jd0:delt:jd1];
end
w=ones(nt,m)*NaN;
for i=1:m
  cdfi=cdf(i,:);
  [icyc,ncyc,jd]=mctime(cdfi,start,stop);
  temperature=mcvgt(cdfi,var1,icyc,ncyc);
  salinity=mcvgt(cdfi,var2,icyc,ncyc);
  ind=length(temp);
  if(nargin==3),
    ind=round((jd-jd0)/delt)+1;
    temp(ind,i)=temperature;
    sal(ind,i)=salinity;
    jd=jda;
  else
    temp(:,i)=temperature;
    sal(:,i)=salinity;
  end
end
