function [uc,vc]=centering_llcuv_aste(uI,vI,nfx,nfy);
%----
%function [uc,vc]=centering_llcuv(uI,vI,nx,ny,nz);
%assume that hfac[W,S] have already been applied
%[uI,vI]: in compact format
%[uc,vc]: 5 faces
%adapted for ASTE, on input have nfx,nfy
%----

%keyboard

%%assume global, can readjust later to accomodate aste
%nfx=[nx,nx,nx,3*nx,3*nx];
%nfy=[3*nx,3*nx,nx,nx,nx];
iskip=[0,nfy(1),nfy(1),nfy(1)+nfx(3),nfy(1)+nfx(3)+nfx(4),nfy(1)+nfx(3)+nfx(4)+nfx(5)];

sz=size(uI);if(length(sz)==2);sz=[sz 1];end;
nz=sz(3);
nx=sz(1);

  for iface=1:5;
%define size
    u{iface}=zeros(nfx(iface)+1,nfy(iface),nz);
    v{iface}=zeros(nfx(iface),nfy(iface)+1,nz);
    uc{iface}=zeros(nfx(iface),nfy(iface),nz);
    vc{iface}=zeros(nfx(iface),nfy(iface),nz);

%now filling in faces:
    u{iface}(1:nfx(iface),1:nfy(iface),1:nz)=...
         reshape(uI(1:nx,iskip(iface)+1:(iskip(iface+1)),1:nz),nfx(iface),nfy(iface),nz);
    v{iface}(1:nfx(iface),1:nfy(iface),1:nz)=...
         reshape(vI(1:nx,iskip(iface)+1:(iskip(iface+1)),1:nz),nfx(iface),nfy(iface),nz);
  end;

%now u edge:
  clear ut;if(nfy(1)>0&nfy(2)>0);ut=u{2}(1,1:nfy(2),1:nz);else;ut=nan.*u{1}(nfx(1)+1,1:nfy(1),1:nz); end;u{1}(nfx(1)+1,1:nfy(1),1:nz)=ut;
  clear ut;if(nfx(4)>0&nfy(2)>0);ut=sym_g_mod(v{4}(1:nfx(4),1,1:nz),7,0);u{2}(nfx(2)+1,1:nfy(2),1:nz)=ut;end;
  clear ut;if(nfx(4)>0&nfy(3)>0);ut=u{4}(1,1:nfy(4),1:nz);u{3}(nfx(3)+1,1:nfy(3),1:nz)=ut;end;
%will not fill the last cells nx*3+1 for u{4} and u{5} because they're land, so assume zeros

%now v edge: (a bit more complicated that u)
  clear vt;if(nfy(3)>0&nfy(1)>0);vt=sym_g_mod(u{3}(1,1:nfy(3),1:nz),5,0);v{1}(1:nfx(1),nfy(1)+1,1:nz)=vt;end;
  clear vt;if(nfy(3)>0&nfy(2)>0);vt=v{3}(1:nfx(3),1,1:nz);v{2}(1:nfx(2),nfy(2)+1,1:nz)=vt;end;
  clear vt;if(nfx(5)>0&nfx(3)>0);vt=sym_g_mod(u{5}(1,1:nfy(5),1:nz),5,0);v{3}(1:nfx(3),nfy(3)+1,1:nz)=vt;end;
  clear vt;if(nfx(5)>0&nfx(4)>0);vt=v{5}(1:min(nfx(5),nfx(4)),1,1:nz);v{4}(1:min(nfx(4),nfx(5)),nfy(4)+1,1:nz)=vt;end;
  clear vt;if(nfy(1)>0&nfx(5)>0);vt=sym_g_mod(u{1}(1,1:nfy(1),1:nz),5,0);v{5}(1:nfx(5),nfy(5)+1,1:nz)=vt;end;


%now centering:
  for iface=1:5;
    uc{iface}=(u{iface}(1:nfx(iface),1:nfy(iface),1:nz)+u{iface}(2:nfx(iface)+1,1:nfy(iface),1:nz))./2;
    vc{iface}=(v{iface}(1:nfx(iface),1:nfy(iface),1:nz)+v{iface}(1:nfx(iface),2:nfy(iface)+1,1:nz))./2;
  end;

  for iface=1:5;
    if((nfx(iface)+nfy(iface))==0);uc{iface}=[];vc{iface}=[];end;
  end;

return
