load ~/NC/grid
year=1:150;

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/DRUN/WIND/ncfile/WIND_10th.nc','WIND_year');
VWNDVERT=ncread('/Users/yangyang/Aerosol_Variaiton/DRUN/VWNDVERT/ncfile/VWNDVERT.nc','VWNDVERT_DJF');


VWNDVERT_weak_temp=zeros(96,30,sum(WIND_year));
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        VWNDVERT_weak_temp(:,:,n)=VWNDVERT(:,:,yearID);
    end
end
VWNDVERT_weak=mean(VWNDVERT_weak_temp,3);


VWNDVERT_aveg=mean(VWNDVERT,3);
VWNDVERT_diff=VWNDVERT_weak-VWNDVERT_aveg;

save('VWNDVERT_10th.mat','VWNDVERT_weak','VWNDVERT_aveg','VWNDVERT_diff')

nccreate('VWNDVERT_10th.nc','lev','Dimensions',{'lev',30},'Format','classic')
ncwrite('VWNDVERT_10th.nc','lev', lev)
nccreate('VWNDVERT_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('VWNDVERT_10th.nc','lat', lat)
ncwriteatt('VWNDVERT_10th.nc','lat','units','degrees_north')
ncwriteatt('VWNDVERT_10th.nc','lat','long_name','Latitude')
nccreate('VWNDVERT_10th.nc','VWNDVERT_weak','Dimensions',{'lat',96,'lev',30},'Format','classic')
ncwrite('VWNDVERT_10th.nc','VWNDVERT_weak', VWNDVERT_weak)
nccreate('VWNDVERT_10th.nc','VWNDVERT_aveg','Dimensions',{'lat',96,'lev',30},'Format','classic')
ncwrite('VWNDVERT_10th.nc','VWNDVERT_aveg', VWNDVERT_aveg)
nccreate('VWNDVERT_10th.nc','VWNDVERT_diff','Dimensions',{'lat',96,'lev',30},'Format','classic')
ncwrite('VWNDVERT_10th.nc','VWNDVERT_diff', VWNDVERT_diff)
ncdisp('VWNDVERT_10th.nc')