load ~/NC/grid
load ~/NC/area_1.9_2.5.mat
year=1:150;

WIND_year=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/WIND/ncfile/WIND_10th.nc','WIND_year');
DUSTSF=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/DUSTSF/ncfile/DUSTSF.nc','DUSTSF_DJF');

DUSTSF_weak_temp=zeros(144,96,sum(WIND_year));
n=0;
for yearID=1:length(year)
    if WIND_year(yearID)==1
        n=n+1;
        DUSTSF_weak_temp(:,:,n)=DUSTSF(:,:,yearID);
    end
end
DUSTSF_weak=mean(DUSTSF_weak_temp,3);


DUSTSF_aveg=mean(DUSTSF,3);
DUSTSF_diff=DUSTSF_weak-DUSTSF_aveg;

DUSTSF_aveg_GOBI=sum(sum(DUSTSF_aveg(41:45,67:73).*area(41:45,67:73),2),1)*60*60*24*90*1000/1e12;
DUSTSF_weak_GOBI=sum(sum(DUSTSF_weak(41:45,67:73).*area(41:45,67:73),2),1)*60*60*24*90*1000/1e12;
DUSTSF_diff_GOBI=sum(sum(DUSTSF_diff(41:45,67:73).*area(41:45,67:73),2),1)*60*60*24*90*1000/1e12;


save('DUSTSF_10th.mat','DUSTSF_weak','DUSTSF_aveg','DUSTSF_diff')

nccreate('DUSTSF_10th.nc','lat','Dimensions',{'lat',96},'Format','classic')
ncwrite('DUSTSF_10th.nc','lat', lat)
ncwriteatt('DUSTSF_10th.nc','lat','units','degrees_north')
ncwriteatt('DUSTSF_10th.nc','lat','long_name','Latitude')
nccreate('DUSTSF_10th.nc','lon','Dimensions',{'lon',144},'Format','classic')
ncwrite('DUSTSF_10th.nc','lon', lon)
ncwriteatt('DUSTSF_10th.nc','lon','units','degrees_east')
ncwriteatt('DUSTSF_10th.nc','lon','long_name','Longitude')
nccreate('DUSTSF_10th.nc','DUSTSF_weak','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUSTSF_10th.nc','DUSTSF_weak', DUSTSF_weak)
nccreate('DUSTSF_10th.nc','DUSTSF_aveg','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUSTSF_10th.nc','DUSTSF_aveg', DUSTSF_aveg)
nccreate('DUSTSF_10th.nc','DUSTSF_diff','Dimensions',{'lon',144,'lat',96},'Format','classic')
ncwrite('DUSTSF_10th.nc','DUSTSF_diff', DUSTSF_diff)
ncdisp('DUSTSF_10th.nc')