load /Users/yang146/Aerosol_Variaiton/OBS/ncfile/sites.mat
n=0;
for i=1:length(siteID)
    if lon_site(i)>10000 && lon_site(i)<11000 && lat_site(i)>3000 && lat_site(i)<4500
        n=n+1;
        site_Gobi(n)=siteID(i);
        lon_Gobi(n)=lon_site(i);
        lat_Gobi(n)=lat_site(i);
    end
end

year=1981:2007;
dust_1981_2007=zeros(length(year),90);

file=importdata('/Users/yang146/Aerosol_Variaiton/OBS/dat/china_dust/SURF_CLI_CHN_WEP_DAY_DSS-1980.TXT');
site=file(:,1);
month=file(:,5);
day=file(:,6);
for i=1:length(site)
    if month(i)==12
        for j=1:n
            if site(i)==site_Gobi(j)
                dust_1981_2007(1,day(i))=dust_1981_2007(1,day(i))+1;
            end
        end
    end
end

file=importdata('/Users/yang146/Aerosol_Variaiton/OBS/dat/china_dust/SURF_CLI_CHN_WEP_DAY_DSS-1981.TXT');
site=file(:,1);
month=file(:,5);
day=file(:,6);
for i=1:length(site)
    if month(i)==1
        for j=1:n
            if site(i)==site_Gobi(j)
                dust_1981_2007(1,day(i)+31)=dust_1981_2007(1,day(i)+31)+1;
            end
        end
    end
end

file=importdata('/Users/yang146/Aerosol_Variaiton/OBS/dat/china_dust/SURF_CLI_CHN_WEP_DAY_DSS-1981.TXT');
site=file(:,1);
month=file(:,5);
day=file(:,6);
for i=1:length(site)
    if month(i)==2
        for j=1:n
            if site(i)==site_Gobi(j) && day(i)<29
                dust_1981_2007(1,day(i)+62)=dust_1981_2007(1,day(i)+62)+1;
            end
        end
    end
end


for yearID=2:length(year)
    
    file=importdata(['/Users/yang146/Aerosol_Variaiton/OBS/dat/china_dust/SURF_CLI_CHN_WEP_DAY_DSS-',num2str(year(yearID)-1),'.TXT']);
    site=file(:,1);
    month=file(:,5);
    day=file(:,6);
    for i=1:length(site)
        if month(i)==12
            for j=1:n
                if site(i)==site_Gobi(j)
                    dust_1981_2007(yearID,day(i))=dust_1981_2007(yearID,day(i))+1;
                end
            end
        end
    end
    
    file=importdata(['/Users/yang146/Aerosol_Variaiton/OBS/dat/china_dust/SURF_CLI_CHN_WEP_DAY_DSS-',num2str(year(yearID)),'.TXT']);
    site=file(:,1);
    month=file(:,5);
    day=file(:,6);
    for i=1:length(site)
        if month(i)==1
            for j=1:n
                if site(i)==site_Gobi(j)
                    dust_1981_2007(yearID,day(i)+31)=dust_1981_2007(yearID,day(i)+31)+1;
                end
            end
        end
    end
    
    file=importdata(['/Users/yang146/Aerosol_Variaiton/OBS/dat/china_dust/SURF_CLI_CHN_WEP_DAY_DSS-',num2str(year(yearID)),'.TXT']);
    site=file(:,1);
    month=file(:,5);
    day=file(:,6);
    for i=1:length(site)
        if month(i)==2
            for j=1:n
                if site(i)==site_Gobi(j) && day(i)<29
                    dust_1981_2007(yearID,day(i)+62)=dust_1981_2007(yearID,day(i)+62)+1;
                end
            end
        end
    end
    
end

save('Dust_Gobi_1981_2007_daily','dust_1981_2007')

