function [u,v] = uv_from_h_h(lon,lat,h)
% [u,v] = uv_from_h_h(lon,lat,h)
% Calculate velocities from surface height h by geostrophy
% [u,v] will be at h grid locations
% For h in metres u,v will be m/s
%
% John Wilkin 8 Oct 96

% Indexing convention is that the first index of a matrix is
% latitude (y), and second index is longitude (x),
% i.e. h(lat,lon), lon(lat,lon), lat(lat,lon) etc
% Take care in differencing operations to get this right

% Staggered grid arrangement:
%
%    h------v------h
%    |      |
%    u(1,1)--------h
%    |      |
%    h(1,1)-v(1,1)-h...

% dx at v points and dy at u points
[dx_v,dy_u] = dxdy_uv(lon,lat);

% u,v on staggered grid locations
[u_u,v_v] = uv_from_h_s(lon,lat,h);

% assume du/dy = 0 at edges
[nlat nlon] = size(u_u);
tmp = [u_u(1,:); u_u; u_u(nlat,:)];
[nlat nlon] = size(tmp);
u = 0.5*(tmp(2:nlat,:)+tmp(1:nlat-1,:));

% assume dv/dx = 0 at edges
[nlat nlon] = size(v_v);
tmp = [v_v(:,1) v_v v_v(:,nlon)];
[nlat nlon] = size(tmp);
v = 0.5*(tmp(:,2:nlon)+tmp(:,1:nlon-1));
