Warning, /utils/matlab/cs_grid/cubeCalcAngle.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit 6940509b on 2005-10-20 16:42:30 UTC
6940509b5a Dani*0001 function [AngleCS,AngleSN] = cubeCalcAngle(YG,RAC,dxG,dyG);
0002 % [AngleCS,AngleSN] = cubeCalcAngle(YG,RAC,dxG,dyG);
0003 %
0004 % Determine rotation angle, alpha (returned as cos(alpha) and sin(alpha)),
0005 % to convert cube sphere C-grid vectors to east-west and north-south
0006 % components.
0007 %
0008 % e.g.
0009 %
0010 % >> XG=rdmds('XG');
0011 % >> YG=rdmds('YG');
0012 % >> RAC=rdmds('RAC');
0013 % >> dxG=rdmds('dxG');
0014 % >> dyG=rdmds('dyG');
0015 % >> [AngleCS,AngleSN] = cubeCalcAngle(YG,RAC,dxG,dyG);
0016 %
0017 % >> u=rdmds('uVeltave.0000513360');
0018 % >> v=rdmds('vVeltave.0000513360');
0019 % >> [uE,vN] = rotate_csCg_EN(u,v,AngleCS,AngleSN,XG,YG);
0020
0021 nc=size(RAC,2);
0022 deg2rad=pi/180;
0023 r_earth=sqrt(sum(sum(RAC))./(4.*pi));
0024
0025 [yZ6]=split_Z_cub(YG);
0026
0027 % Build purely zonal flow from a stream function, psi = r_earth * latitude.
0028 psi=-r_earth.*yZ6.*deg2rad;
0029 uZ=psi([1:nc],[1:nc],:)-psi([1:nc],[2:nc+1],:);
0030 vZ=psi([2:nc+1],[1:nc],:)-psi([1:nc],[1:nc],:);
0031 uZ=reshape(permute(uZ,[1 3 2]),[6.*nc nc])./dyG;
0032 vZ=reshape(permute(vZ,[1 3 2]),[6.*nc nc])./dxG;
0033
0034 % Put constructed zonal wind at cell center.
0035 [uu,vv]=split_UV_cub(uZ,vZ);
0036 u=(uu(1:nc,:,:)+uu(2:nc+1,:,:))/2;
0037 v=(vv(:,1:nc,:)+vv(:,2:nc+1,:))/2;
0038 uZc=reshape(permute(u,[1 3 2]),[6.*nc nc]);
0039 vZc=reshape(permute(v,[1 3 2]),[6.*nc nc]);
0040
0041 % Calculate angles.
0042 norm=sqrt(uZc.*uZc+vZc.*vZc);
0043 AngleCS = uZc./norm;
0044 AngleSN = -vZc./norm;