function OCR_100_QC(infile)

qcdrawfile=netcdf(infile, 'write');
j=1;
h=1;

v=var(qcdrawfile);
for i=1:length(v)
 if~isempty(qcdrawfile{i}.bank(:))
    if qcdrawfile{i}.bank(:)==1
      
     name=ncnames(qcdrawfile{i});
     name=char(name);
     
     if name(1:2)=='Lu'
        
        if j<8
           SatA(:,j)=qcdrawfile{name}(:);
           j=j+1;
        else
           SatB(:,h)=qcdrawfile{name}(:);
           h=h+1;
        end;
        
     end;
     
  end;
  
 end;

end;

   
   %testrats=[1 0.89 0.77 0.47 0.19 0.01 0.01];
   ratiosA(1:length(SatA),1)=1;
   
   for i=2:(j-1)
      error=0.1;
      if i>5
         error=0.025;
      end;
      ratiosA(:,i)=SatA(:,i)./SatA(:,1);
      %baselineA=find(ratiosA(:,i)>=(testrats(i)-error)&ratiosA(:,i)<=(testrats(i)+error));
      %if ~isempty(baselineA)
         baseline=ratiosA(195,i);
         %baseline=ratiosA(baselineA(baseline(1)),i);
      	bad=find(ratiosA(:,i)<(baseline-error)|ratiosA(:,i)>(baseline+error));
         SatA(bad,i)=-999;
      %end;
   end;
   
   ratiosB(1:length(SatB),1)=1;
   
   for i=2:(h-1)
      error=0.1;
      if i>5
         error=0.025;
      end;
        
         
      ratiosB(:,i)=SatB(:,i)./SatB(:,1);
		%baselineB=find(ratiosB(:,i)>=(testrats(i)-error)&ratiosB(:,i)<=(testrats(i)+error));
      %if ~isempty(baselineB)
         baseline=ratiosB(195,i);
         %baseline=ratiosB(baselineB(baseline(1)),i);
         bad=find(ratiosB(:,i)<(baseline-error)|ratiosB(:,i)>(baseline+error));
         SatB(bad,i)=-999;
      %end;
   end;
   
   
  	badStart = NaN;
	badEnd = NaN;
	time=utc2sdn(qcdrawfile{'time'}(:));

   switch lower(qcdrawfile.mooring(:))
   case 'ep1'
      badStart = [datenum('20 Oct 2000');datenum('19 Dec 2000');];
      badEnd   = [datenum('22 Oct 2000');datenum('07 Jun 2001');];
      
   case 'ep2'
      badStart = [datenum('29 Oct 2000');datenum('19 Dec 2000');];
      badEnd   = [datenum('01 Nov 2000');datenum('17 Jun 2001');];
   end
   
   for i = 1:length(badStart)
      bad = find(time >= badStart(i) & time <= badEnd(i));
      SatA(bad,:)=-999;
      SatB(bad,:)=-999;
   end;

   j=1;
   h=1;
   
  for i=1:length(v)
 if~isempty(qcdrawfile{i}.bank(:))
  	if qcdrawfile{i}.bank(:)==1
     name=ncnames(qcdrawfile{i});
     name=char(name);
     
     if name(1:2)=='Lu'
        if j<8
           qcdrawfile{name}(:)=SatA(:,j);
           j=j+1;
        else
           qcdrawfile{name}(:)=SatB(:,h);
           h=h+1;
        end;
     end;
   end;   
 end;
end;

ncquit(qcdrawfile);
      
      
      
    

  


