function [T_Ap,apcSamp_ID]=apcproc

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This section sets up where to look and for what files.
PATH=('\thesis\astar\');
apcFILE=('eqpac080102.csv');

%other stuff one might change, so I keep it at the top.
nb=(5); %the number of blanks

%end of user specified variables.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%  Process the clevland spec files
%%%%%%%%%%%%%%%%%%%%%%%%%%%

%open the Clevland files for reading
apcfid=fopen([PATH,apcFILE]);     %the [] bolt things together

apcSamp_ID=fgetl(apcfid);        %store the first line, its got info I may need
apcHeader=fgetl(apcfid);         %what the hell, store this one too.

c=1;                             %initialize some vars that I need to do tests and counts.
xit=1;

%load in the data
while xit==1
  strbuf = fgetl(apcfid);
  if isempty(strbuf);               % hey! there be other crap in the file after the data!
    xit=2;                          % so test strbuf to see if its an empty line, if so end.
    disp(['exit ap_clevland loop on row number : ',num2str(c)])
  else                              % its not empty, so there must still be data there
    apcdata(c,:)= str2num(strbuf);  %put all (:) the numbers (col's) from strbuf in row 'c' 
  end
  c=c+1; 
end

% average the blanks.
apc_blank=apcdata(:,2:2:(2*nb));    %every other row from the second to the (2 * number of blanks) row.
apc_blank=mean(apc_blank,2);        %mean in the horizontal direction.. or median(ap_blank,2)..

[o,p]=size(apcdata);                %how many rows and cols?
apcABS=apcdata(:,((2*nb)+2):2:p);

%subtract blank from absoute values.
for j=1:o
  apcCOR(j,:)=apcABS(j,:)-apc_blank(j,1); 
end

%find 750nm
k=near(apcdata(:,1),750,1);          %its not exactly 750 so I use "near" instead of "find"
nm750=apcCOR(k,:);                   % So now I have a ROW of 750nm data

%normalize it all to 750
for ii=1:length(nm750)
  Odc(:,ii)=apcCOR(:,ii)-nm750(ii);
end                                  % 

%now its all loaded and corrected, lets do the math.
Occ   =  (0.378*Odc)+(0.523*Odc.^2);
T_Ap =  [apcdata(:,1),((2.303*Occ*0.000355324)/(0.00105))];
%wasnt that hard?
