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

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

WIND_ECHINA_20th=prctile(WIND_ECHINA,20);

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_20th
        WIND_year(yearID)=1;
        WIND_weak=WIND_weak+WIND(:,:,yearID)/30;
        WIND_ECHINA_weak=WIND_ECHINA_weak+WIND_ECHINA(yearID)/30;
    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_20th.mat','WIND_year','WIND_weak','WIND_aveg','WIND_diff')

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