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

DUST_year_33th=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/DUST/ncfile/DUST_33th_67th.nc','DUST_year_33th');
DUST_year_67th=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/DUST/ncfile/DUST_33th_67th.nc','DUST_year_67th');
WIND=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND.nc','WIND_DJF');

WIND_ECHINA=zeros(length(year),1);
WIND_ECHINA(:)=mean(mean(WIND(45:50,60:72,:),2),1);


WIND_33th_temp=zeros(144,96,sum(DUST_year_33th));
WIND_67th_temp=zeros(144,96,sum(DUST_year_67th));
WIND_ECHINA_33th=0;
WIND_ECHINA_67th=0;
n=0;
m=0;
for yearID=1:length(year)
    if DUST_year_33th(yearID)==1
        n=n+1;
        WIND_33th_temp(:,:,n)=WIND(:,:,yearID);
        WIND_ECHINA_33th=WIND_ECHINA_33th+WIND_ECHINA(yearID)/sum(DUST_year_33th);
    end
    if DUST_year_67th(yearID)==1
        n=n+1;
        WIND_67th_temp(:,:,n)=WIND(:,:,yearID);
        WIND_ECHINA_67th=WIND_ECHINA_67th+WIND_ECHINA(yearID)/sum(DUST_year_67th);
    end
end
WIND_33th=mean(WIND_33th_temp,3);
WIND_67th=mean(WIND_67th_temp,3);
WIND_diff=WIND_33th-WIND_67th;

WIND_ECHINA_diff=WIND_ECHINA_33th-WIND_ECHINA_67th;

save('WIND_33th_67th.mat','WIND_33th','WIND_67th','WIND_diff')

nccreate('WIND_33th_67th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('WIND_33th_67th.nc','lat', lat)
ncwriteatt('WIND_33th_67th.nc','lat','units','degrees_north')
ncwriteatt('WIND_33th_67th.nc','lat','long_name','Latitude')
nccreate('WIND_33th_67th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('WIND_33th_67th.nc','lon', lon)
ncwriteatt('WIND_33th_67th.nc','lon','units','degrees_east')
ncwriteatt('WIND_33th_67th.nc','lon','long_name','Longitude')
nccreate('WIND_33th_67th.nc','WIND_33th','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('WIND_33th_67th.nc','WIND_33th', WIND_33th)
nccreate('WIND_33th_67th.nc','WIND_67th','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('WIND_33th_67th.nc','WIND_67th', WIND_67th)
nccreate('WIND_33th_67th.nc','WIND_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('WIND_33th_67th.nc','WIND_diff', WIND_diff)
ncdisp('WIND_33th_67th.nc')