% average U and V from daily averages


clear
region_name='global';
nx=4320;

folderU = ['~dmenemen/llc_4320/regions/global/U_daily'];
folderV = ['~dmenemen/llc_4320/regions/global/V_daily'];
siz = [4320 56160 1];
  
fnamesU = dir([folderU '/*.2*']);  
fnamesV = dir([folderV '/*.2*']);

numFiles = length(fnamesU);
numAvg = 27;

Ut = 0;
Vt = 0;
for ii =42:42+numAvg
    
    fnamU = [folderU '/' fnamesU(ii).name];
    fnamV = [folderV '/' fnamesV(ii).name];
    [U, V]= quikreadpcolor_uv_llc(fnamU,fnamV,nx);
    Ut = U + Ut;
    Vt = V + Vt;
end

Vout = Vt./numAvg;
Uout = Ut./numAvg;

save(['UV_' num2str(numAvg) 'day_avg'],'Uout','Vout');

