%load300ozone

%file header lines
%"TOA5","CR1000_300m","CR1000","2846","CR1000.Std.11","CPU:062210_BAO_MET3WOZONE_LMOD.CR1","58259","bao_ozo3"
%"TIMESTAMP","RECORD","OZS_O3PPB_Avg","OZS_CELLTDEGC_Avg","OZS_CELLPRESSMB_Avg","OZS_TEMPINTERFACE_Avg","OZS_PRESSINTERFACE_Avg","OZS_FLOWMETERVOLTS_Avg","OZS_2BFLOWMETER_Avg","OZS_O3MOD_Avg"
%"TS","RN","","","","","","","",""
%"","","Avg","Avg","Avg","Avg","Avg","Avg","Avg","Avg"

function [bao300 dt n] = load300ozone( filename, nmax )

dt = zeros(nmax,7);
bao300 = zeros( nmax, 8);

%fprintf(1,'    Reading %s\n', filename );
f300 = fopen(filename,'r');
n = 0;
while ~feof(f300)
    %read in next line and skip any that do not have 2 as second character
    temp=fgetl(f300);
    if( temp(2) == '2')
        n = n + 1;
        dt(n,1:6) = sscanf(temp,'"%4d-%2d-%2d %2d:%2d:%2d');
        % start reading the data line after the date/time string
        % convert each , to a blank space then read
        [data]=sscanf(strrep( temp(23:length(temp)), ',', ' ' ),'%f');
        nd=length(data);
        bao300(n,1:nd-1) = data(2:nd);
    end
end  %while ~feof(f300)

dt(:,7)=datenum(dt(:,1),dt(:,2),dt(:,3),dt(:,4),dt(:,5),dt(:,6));

fclose(f300);
