clear

nx = 2160;
pinV = '/nobackupp8/awinetee/global_1080/dopplerscat/KE_V'
pinU = '/nobackupp8/awinetee/global_1080/dopplerscat/KE_U'
n = 0;
keTU = 0;
keTV = 0;

keTUnn = 0;
keTVnn = 0;
for ts=700800:(40*24):700800+(40*24)*365
        
            
    dy=ts2dte(ts,90,2010,1,1)    
     
    fld=0; nn=0;
    
    finV = [pinV '/KE_V_' num2str(4320) 'x' num2str(3780) '.' dy];
    finU = [pinU '/KE_U_' num2str(4320) 'x' num2str(3780) '.' dy];
    finVnn = [pinV '_noNoise/KE_V_noNoise_' num2str(4320) 'x' num2str(3780) '.' dy];
    finUnn = [pinU '_noNoise/KE_U_noNoise_' num2str(4320) 'x' num2str(3780) '.' dy];
    
    if exist(finU) 
        n = n + 1;
        keTU = keTU + readbin(finU,[4320,3780]);
        keTV = keTV + readbin(finV,[4320,3780]);

        keTUnn = keTUnn + readbin(finUnn,[4320,3780]);
        keTVnn = keTVnn + readbin(finVnn,[4320,3780]);

        if n == 4
            keT4 = keTU./4+keTV./4;
        elseif n == 6
            keT6 = keTU./6+keTV./6;
        elseif n == 8
            keT8 = keTU./8+keTV./8;
            keT8nn = keTUnn./8+keTVnn./8;
        end
        
    end
end

%%

ke = (keTU + keTV)./n;
kenn = (keTUnn + keTVnn)./n;

fig = figure('color','white','units','normalized','outerposition',[0 0 1 1],'name','1');
quikpcolor((keT8)');
c = colorbar;
caxis([-.02 .05])
title('Total Power Per Area 3x3 Median Filter-- Filtered + Noisy, 8 day avg of hourly snapshots')
xlabel(c,'Power Per Area (W/m^2)')
set(get(gca,'title'),'fontsize',16);
a = get(c,'xlabel');
set(a,'fontsize',16);
set(gca,'xtick',[])
set(gca,'ytick',[])
daspect([1 1 1])
%print('-dpng','-r300','totalPWR_medfilt_global_dopplerscat_8d.png')
       
fig = figure('color','white','units','normalized','outerposition',[0 0 1 1],'name','1');
quikpcolor((keT8nn)');
c = colorbar;
caxis([-.02 .05])
title('Total Power Per Area 3x3 Median Filter-- Filtered + Noisy, 8 day avg of hourly snapshots')
xlabel(c,'Power Per Area (W/m^2)')
set(get(gca,'title'),'fontsize',16);
a = get(c,'xlabel');
set(a,'fontsize',16);
set(gca,'xtick',[])
set(gca,'ytick',[])
daspect([1 1 1]) 
    
        