function [data, calind] = drftreadcomp(file_loc,dname,calfile) fname = sprintf('%s%s\\%s_downloadcomp',file_loc,dname,dname); fid = fopen(fname); %burn the header token = '#'; trash = fgetl(fid); while strncmp(trash,token,1) trash = fgetl(fid); end %find deployment cal time and package start = ftell(fid); X=fgetl(fid); year=str2num(X(1:4)); comind=findstr(X,','); jday=str2num(X(comind(1)+1:comind(2)-1)); test_time=jul2date(jday,year); calind=near(calfile.times,test_time,1); fseek(fid,start,-1); N=str2num(calfile.instruments(calind).DC); k=1; while ~feof(fid) try %if there are weird characters from the drifter or dropped points from ecopuck lose the line temp=fgetl(fid); data(:,k) = strread(temp,'%f',N,'delimiter',','); if strcmp(dname,'MBARI5') & calind == 1 if data(2,k) > 234.709 & data(2,k) < 235.709 if data(40,k)<25 data(40,k)=33.3109; end end end k = k+1;temp = ''; catch temp = ''; end end fclose(fid); %find where salinity values are saltwater or greater/otherwise its on the ship and who cares if isfield(calfile.instruments,'CT') deployind = find(data(40,:)>=25); if ~isempty(deployind) data = data(:,deployind); end end