Lisstcheck

From Pnb
Jump to navigation Jump to search
function lisstcheck(filename)
%Written by Erik Stassinos 10/08/2011
%This function is designed to look at IOP fram lisst data.
%file names are DH4 waped LISST names
fp = fopen(filename)
i=1;
startbrak(i)  = 1;
count =1;
deptharray =0;
while ~feof(fp) %to get size of file
    databuff = fgets(fp);
    count = count +1;
end
frewind(fp)
ind =1;
clsind =1;
for i = 1:count
    databuff = fgets(fp);
    %size(databuff)
    
    if strncmp(databuff,'{',1) % == 1 %index to find open bracket
        disp('found it first');
        startbrack(ind) =i;
        ind = ind +1;

    end
%     if ind < 3

        if i == (startbrack(ind-1)) + 37 %finding the depth
            disp('found depth')
            depth = databuff;
            depth  = str2num(depth)*.01;
            deparr(ind)  = depth;
        end
%    end
    
    if strncmp(databuff,'}',1) %== 1 %index to find close bracket
        endbrack(clsind) = i;
        disp('found close bracket')
        clsind = clsind +1;
    end
end
deparr;
dlmwrite(strcat('lisstdepth',filename),deparr',''); %write the depth array

%read just data loop
%checking for indexes
%endbrack
%startbrack

rp = fopen(filename);
goodindex =1;
np = fopen('lisstnobrack','w+')

for rpi =1:count % loop to print without brackets
    num = fgets(rp)

              if strncmp(num,'{',1) == 1
                  disp('passing')
                  continue
              end
              if strncmp(num,'}',1) == 1
                  continue
              end
              fprintf(np,'%s',num)
              lisstnumbers(rpi) = {num};
              count
              rpi
              
 end
 fclose all
 ct =1;
 r=1;
 t=1;
lisstdat = load('lisstnobrack'); %put data into parallel columns
%40 columns in all
while t <= length(lisstdat)
       
       holder(r,:) = lisstdat(t,:);
       r=r+1;
       if t == 40*ct %|| t ==1 cycle through 40 columns then restart to get data
           indexarr(ct,:) = holder';
           ct = ct +1;
           clear holder
           r=1;
       end
       t = t +1;
       if t == length(lisstdat)
           dlmwrite('LISST_indexarr',indexarr,' ')
          return
       end
       
end
%save('indexarr', indexarr)
return