Warning, /utils/matlab/cs_grid/latloncap/calcFacetAngles.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
6a75a3b8ef Chri*0001 function [cos_alpha, sin_alpha, u_a, v_a] = calcFacetAngles(yG,dxG,dyG)
0002 % [cos_alpha, sin_alpha, u_a, v_a] = calcFacetAngles
0003 %
0004 % Find the rotation angle that projects cell centered velocity on
0005 % locally orthogonal mesh1 to cell centered velocity on locally orthogonal
0006 % mesh2.
0007 % yG is location in meridional mesh2 coordinate of mesh1 points.
0008 % dxG is spacing between mesh1 points along local x coordinate line of mesh1.
0009 % dyG is spacing between mesh2 points along local y coordinate line of mesh1.
0010 % Indexing is assumed to be standard MITgcm (western most, southern most)
0011 % indexing.
0012 % yG is defined at cell corners.
0013 % dxG is along cell southern most face.
0014 % dyG is along cell western most face.
0015 % x-coordinate is dimension 1 (the left most dimension)
0016 % y-coordinate is dimension 2 (the right most dimension)
0017 % cos_alpha, sin_alpha, u_a and v_a are at cell centers.
0018 % u_a and v_a are returned for testing, they are not really needed.
0019
0020 % Define a stream function that varies along the meridional coordinate of
0021 % mesh2 only.
0022 psi= (yG);
0023 % Calculate local gradients of psi and the cell centered averages of gradients
0024 % on mesh1.
0025 v =-(psi(2:end,:)-psi(1:end-1,:))./dxG(:,:);
0026 u = (psi(:,2:end)-psi(:,1:end-1))./dyG(:,:);
0027 u_a=0.5*(u(1:end-1,:)+u(2:end,:));
0028 v_a=0.5*(v(:,1:end-1)+v(:,2:end));
0029 speed = ( u_a.^2 + v_a.^2 ).^0.5;
0030 % Using v_mesh2 = cos_alpha.v_a + sin_alpha.u_a
0031 % u_mesh2 = cos_alpha.u_a - sin_alpha.v_a
0032 % and u_mesh2^2 = u_a^2 + v_a^2
0033 % we get
0034 sin_alpha = -v_a./speed;
0035 cos_alpha = u_a./speed;
0036 return
0037 end