lon_ECMWF=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/U10/dat/U10_ECMWF.nc','longitude');
lat_ECMWF=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/U10/dat/U10_ECMWF.nc','latitude');
lat=-89.5:1:89.5;
lon=-179.5:1:179.5;
year=1:36;
month=1:432;

U10_ECMWF_temp=ncread('/Users/yangyang/Aerosol_Variaiton/IRUN/U10/dat/U10_ECMWF.nc','si10');
temp=U10_ECMWF_temp(1:180,:,:);
U10_ECMWF_temp2(1:180,:,:)=U10_ECMWF_temp(181:360,:,:);
U10_ECMWF_temp2(181:360,:,:)=temp;
U10_ECMWF_temp2(:,1:181,:)=U10_ECMWF_temp2(:,181:-1:1,:);

U10_ECMWF=zeros(length(lon),length(lat),length(month));
for j=1:180
    U10_ECMWF(:,j,:)=(U10_ECMWF_temp2(:,j,:)+U10_ECMWF_temp2(:,j+1,:))/2;
end

U10_temp=zeros(length(lon),length(lat),12,length(year));

n=0;
for yearID=1:length(year)
    for monthID=1:12
        n=n+1;
        U10_temp(:,:,monthID,yearID)=U10_ECMWF(:,:,n);
    end
end
        
U10_ANN=zeros(length(lon),length(lat),length(year));
U10_ANN(:,:,:)=mean(U10_temp,3);


save('U10_ECMWF_1979_2014.mat','U10_ANN')

nccreate('U10_ECMWF_1979_2014.nc','Year','Dimensions',{'time',Inf},'Format','classic')
ncwrite('U10_ECMWF_1979_2014.nc','Year', year)
nccreate('U10_ECMWF_1979_2014.nc','lat','Dimensions',{'lat',length(lat)},'Format','classic')
ncwrite('U10_ECMWF_1979_2014.nc','lat', lat)
ncwriteatt('U10_ECMWF_1979_2014.nc','lat','units','degrees_north')
ncwriteatt('U10_ECMWF_1979_2014.nc','lat','long_name','Latitude')
nccreate('U10_ECMWF_1979_2014.nc','lon','Dimensions',{'lon',length(lon)},'Format','classic')
ncwrite('U10_ECMWF_1979_2014.nc','lon', lon)
ncwriteatt('U10_ECMWF_1979_2014.nc','lon','units','degrees_east')
ncwriteatt('U10_ECMWF_1979_2014.nc','lon','long_name','Longitude')
nccreate('U10_ECMWF_1979_2014.nc','U10_ANN','Dimensions',{'lon',length(lon),'lat',length(lat),'year',length(year)},'Format','classic')
ncwrite('U10_ECMWF_1979_2014.nc','U10_ANN', U10_ANN)
ncdisp('U10_ECMWF_1979_2014.nc')