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=1981:2015;

temp=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_NCEP_1949_2016.nc','WIND_DJF');
WIND=temp(:,:,1981-1949+1:2015-1949+1);

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

WIND_ECHINA_10th=prctile(WIND_ECHINA,10);

WIND_weak=zeros(length(lon),length(lat));
WIND_ECHINA_weak=0;
WIND_year=zeros(length(year),1);
for yearID=1:length(year)
    if WIND_ECHINA(yearID)<WIND_ECHINA_10th
        WIND_year(yearID)=1;
        WIND_weak=WIND_weak+WIND(:,:,yearID)/3;
        WIND_ECHINA_weak=WIND_ECHINA_weak+WIND_ECHINA(yearID)/3;
    end
end

WIND_aveg=mean(WIND,3);
WIND_diff=WIND_weak-WIND_aveg;

WIND_ECHINA_aveg=mean(WIND_ECHINA);
WIND_ECHINA_diff=WIND_ECHINA_weak-WIND_ECHINA_aveg;

save('WIND_NCEP_10th_1981_2015.mat','WIND_year','WIND_weak','WIND_aveg','WIND_diff')

nccreate('WIND_NCEP_10th_1981_2015.nc','lat','Dimensions',{'lat',length(lat)},'Format','classic')
ncwrite('WIND_NCEP_10th_1981_2015.nc','lat', lat)
ncwriteatt('WIND_NCEP_10th_1981_2015.nc','lat','units','degrees_north')
ncwriteatt('WIND_NCEP_10th_1981_2015.nc','lat','long_name','Latitude')
nccreate('WIND_NCEP_10th_1981_2015.nc','lon','Dimensions',{'lon',length(lon)},'Format','classic')
ncwrite('WIND_NCEP_10th_1981_2015.nc','lon', lon)
ncwriteatt('WIND_NCEP_10th_1981_2015.nc','lon','units','degrees_east')
ncwriteatt('WIND_NCEP_10th_1981_2015.nc','lon','long_name','Longitude')
nccreate('WIND_NCEP_10th_1981_2015.nc','WIND_year','Dimensions',{'year',length(year)},'Format','classic')
ncwrite('WIND_NCEP_10th_1981_2015.nc','WIND_year', WIND_year)
nccreate('WIND_NCEP_10th_1981_2015.nc','WIND_weak','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('WIND_NCEP_10th_1981_2015.nc','WIND_weak', WIND_weak)
nccreate('WIND_NCEP_10th_1981_2015.nc','WIND_aveg','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('WIND_NCEP_10th_1981_2015.nc','WIND_aveg', WIND_aveg)
nccreate('WIND_NCEP_10th_1981_2015.nc','WIND_diff','Dimensions',{'lon',length(lon),'lat',length(lat)},'Format','classic')
ncwrite('WIND_NCEP_10th_1981_2015.nc','WIND_diff', WIND_diff)
ncdisp('WIND_NCEP_10th_1981_2015.nc')