function [hZ]=get_hFacZ(hW,hS)
%-------------------------------------------------------------
%function [hZ]=get_hFacZ(hW,hS)
%
% function to get mask at zeta point for ASTE domain
% input: h[W,S]: size [541,901,:]
% output: hZ: size [541,901,:] but only values at [2:540,2:900,:] are filled
%         hZ(i,j) = [hW(i,j)+hW(i,j-1)+hS(i,j)+hS(i-1,j)]/4
%                 = [0,1] where [1] = exact wet point, 
%					 less than 1 = dry point
%                   based on option 0 in mom_calc_hfacz.F
% ATN 25-Apr-2013
%-------------------------------------------------------------

szW=size(hW);
szS=size(hS);
if(sum(szW)~=sum(szS));
  fprintf('error in size hW and hS, must be the same\n');
  return;
end;

  hZ=nan(szW);
  nx=szW(1);ny=szW(2);if(length(szW)<3);nz=1;else;nz=szW(3);end;
  ix=2:nx-1;iy=2:ny-1;iz=1:nz;

  a=hW(ix,iy,iz);a=a(:);
  b=hW(ix,iy-1,iz);b=b(:);
  c=hS(ix,iy,iz);c=c(:);
  d=hS(ix-1,iy,iz);d=d(:);

  temp=min([a,b,c,d],[],2);

%hZ(ix,iy,iz)=1/4.*...
%   (hW(ix,iy,iz)+hW(ix,iy-1,iz)+hS(ix,iy,iz)+hS(ix-1,iy,iz));
  hZ(ix,iy,iz)=reshape(temp,length(ix),length(iy),length(iz));

return
