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

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


OMEGAVERT_weak_temp=zeros(96,30,sum(WIND_year));
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        OMEGAVERT_weak_temp(:,:,n)=OMEGAVERT(:,:,yearID);
    end
end
OMEGAVERT_weak=mean(OMEGAVERT_weak_temp,3);


OMEGAVERT_aveg=mean(OMEGAVERT,3);
OMEGAVERT_diff=OMEGAVERT_weak-OMEGAVERT_aveg;

save('OMEGAVERT_10th.mat','OMEGAVERT_weak','OMEGAVERT_aveg','OMEGAVERT_diff')

nccreate('OMEGAVERT_10th.nc','lev','Dimensions',{'lev',30},'Format','classic')
ncwrite('OMEGAVERT_10th.nc','lev', lev)
nccreate('OMEGAVERT_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('OMEGAVERT_10th.nc','lat', lat)
ncwriteatt('OMEGAVERT_10th.nc','lat','units','degrees_north')
ncwriteatt('OMEGAVERT_10th.nc','lat','long_name','Latitude')
nccreate('OMEGAVERT_10th.nc','OMEGAVERT_weak','Dimensions',{'lat',96,'lev',30},'Format','classic')
ncwrite('OMEGAVERT_10th.nc','OMEGAVERT_weak', OMEGAVERT_weak)
nccreate('OMEGAVERT_10th.nc','OMEGAVERT_aveg','Dimensions',{'lat',96,'lev',30},'Format','classic')
ncwrite('OMEGAVERT_10th.nc','OMEGAVERT_aveg', OMEGAVERT_aveg)
nccreate('OMEGAVERT_10th.nc','OMEGAVERT_diff','Dimensions',{'lat',96,'lev',30},'Format','classic')
ncwrite('OMEGAVERT_10th.nc','OMEGAVERT_diff', OMEGAVERT_diff)
ncdisp('OMEGAVERT_10th.nc')