lon=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/uwnd.mon.mean.nc','lon');
lat=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/dat/uwnd.mon.mean.nc','lat');
year=1978:1992;

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_NCEP_10th_1978_1992.nc','WIND_year');
UWND=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/UWND/ncfile/UWND_NCEP_1978_1992.nc','UWND_DJF');

UWND_ECHINA=zeros(length(year),1);
UWND_ECHINA(:)=mean(mean(UWND(45:50,19:29,:),2),1);

UWND_weak_temp=zeros(length(lon),length(lat));
UWND_ECHINA_weak=0;
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        UWND_weak_temp(:,:,n)=UWND(:,:,yearID);
        UWND_ECHINA_weak=UWND_ECHINA_weak+UWND_ECHINA(yearID)/sum(WIND_year);
    end
end
UWND_weak=mean(UWND_weak_temp,3);

UWND_aveg=mean(UWND,3);
UWND_diff=UWND_weak-UWND_aveg;

UWND_ECHINA_aveg=mean(UWND_ECHINA);
UWND_ECHINA_diff=UWND_ECHINA_weak-UWND_ECHINA_aveg;

save('UWND_NCEP_10th_1978_1992.mat','UWND_weak','UWND_aveg','UWND_diff')

nccreate('UWND_NCEP_10th_1978_1992.nc','lat','Dimensions',{'lat',length(lat)},'Format','classic')
ncwrite('UWND_NCEP_10th_1978_1992.nc','lat', lat)
ncwriteatt('UWND_NCEP_10th_1978_1992.nc','lat','units','degrees_north')
ncwriteatt('UWND_NCEP_10th_1978_1992.nc','lat','long_name','Latitude')
nccreate('UWND_NCEP_10th_1978_1992.nc','lon','Dimensions',{'lon',length(lon)},'Format','classic')
ncwrite('UWND_NCEP_10th_1978_1992.nc','lon', lon)
ncwriteatt('UWND_NCEP_10th_1978_1992.nc','lon','units','degrees_east')
ncwriteatt('UWND_NCEP_10th_1978_1992.nc','lon','long_name','Longitude')
nccreate('UWND_NCEP_10th_1978_1992.nc','UWND_weak','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('UWND_NCEP_10th_1978_1992.nc','UWND_weak', UWND_weak)
nccreate('UWND_NCEP_10th_1978_1992.nc','UWND_aveg','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('UWND_NCEP_10th_1978_1992.nc','UWND_aveg', UWND_aveg)
nccreate('UWND_NCEP_10th_1978_1992.nc','UWND_diff','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('UWND_NCEP_10th_1978_1992.nc','UWND_diff', UWND_diff)
ncdisp('UWND_NCEP_10th_1978_1992.nc')