load ~/NC/grid
year=1:150;
WIND=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_12.nc','WIND_DJF');

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

WIND_ECHINA_10th=prctile(WIND_ECHINA,10);

WIND_weak=zeros(length(lon),length(lat));
WIND_ECHINA_weak=0;
WIND_year=zeros(150,1);
for yearID=1:length(year)
    if WIND_ECHINA(yearID)<WIND_ECHINA_10th
        WIND_year(yearID)=1;
        WIND_weak=WIND_weak+WIND(:,:,yearID)/15;
        WIND_ECHINA_weak=WIND_ECHINA_weak+WIND_ECHINA(yearID)/15;
    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_10th_12.mat','WIND_year','WIND_weak','WIND_aveg','WIND_diff')

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