function [t,dat,name,units] = sms_read_tsd(file)
% SMS_READ_TSD Reads an SMS Time Series Data file
%
% Description:
%  Reads an SMS Time Series Data file (*.tsd)
%
% Usage:
%  [t,dat,name,units] = sms_read_tsd(file)
%
% written by Alex Sanchez, USACE-CHL

fid = fopen(file,'r');
fgets(fid); %Skip header line
str = fgets(fid);
ind = strfind(str,'"');
name = str(ind(1)+1:ind(2)-1);
units = str(ind(3)+1:ind(4)-1);
sdate = str(ind(5)+1:ind(6)-1);
ncolrow = str2double(str(ind(4)+1:ind(5)-1));
tstart = datenum(sdate);
data = fscanf(fid,'%f %f',ncolrow)';
fclose(fid);
t = datenum(data(:,1)/86400+tstart);
dat = data(:,2:end);

return
end
