function makeCodarAvg( infile )

if( nargin == 0 )
    infile = '2006_2007';
end
load(infile);

times = floor( length( codar_time ) / 120 );

codar_speed = sqrt(codar_u.^2+codar_v.^2);
nans = zeros(size(codar_speed));
nansAt = find(isnan(codar_speed));
nans(nansAt) = 1;
codar_speed(nansAt) = 0;
codar_u(nansAt) = 0;
codar_v(nansAt) = 0;
for( i = 1:times )
    index = (i-1)*120+1;
    codar_time_avg(i) = mean(codar_time(1,index:index+120));
    items = numel(nans(:,index:index+120)) - sum(sum(nans(:,index:index+120)));
    codar_speed_avg(i) = sum(sum(codar_speed(:,index:index+120)))/items;
    codar_u_avg(i) = sum(sum(codar_u(:,index:index+120)))/items;
    codar_v_avg(i) = sum(sum(codar_v(:,index:index+120)))/items;
end

save([infile '_avg'], 'codar_time_avg', 'codar_u_avg', 'codar_v_avg', 'codar_speed_avg');