/[MITgcm]/MITgcm_contrib/enderton/Diagnostics/DiagUtility/cubeuv2uvEN_C.m
ViewVC logotype

Contents of /MITgcm_contrib/enderton/Diagnostics/DiagUtility/cubeuv2uvEN_C.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Mon Sep 12 19:15:34 2005 UTC (19 years, 10 months ago) by enderton
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
Added some how-to-use comments accessed by the Matlab help command.

1 function [uE,vN] = cubeuv2uvEN_C(u,v,AngleCS,AngleSN,XG,YG)
2 % [uE,vN] = cubeuv2uvEN_C(u,v,AngleCS,AngleSN,XG,YG)
3 %
4 % Rotate cube sphere C-grid U and V vector components of to east-west (uE),
5 % north-south (vN) components locateds and cube sphere grid centers.
6 %
7 % Incoming u and v matricies are assumed to be cube sphere C-grid vector
8 % fields where the first two dimensions are (6*nc nc), where nc is the cube
9 % face resolution. There may up to 4 additional dimensions (likely z and
10 % time, trials, etc.) beyond this.
11 %
12 % e.g.
13 %
14 % >> u=rdmds('uVeltave.0000513360');
15 % >> v=rdmds('vVeltave.0000513360');
16 % >> AngleCS=rdmds('AngleCS');
17 % >> AngleSN=rdmds('AngleSN');
18 % >> XG=rdmds('XG');
19 % >> YG=rdmds('YG');
20 % >> [uE,vN] = cubeuv2uvEN_C(u,v,AngleCS,AngleSN,XG,YG);
21
22 if ~isequal(size(u,1),6.*size(u,2)) | ...
23 ~isequal(size(v,1),6.*size(v,2))
24 error(['Error in CS-dimensions: ',...
25 'u = ',mat2str(size(u)),', ',...
26 'v = ',mat2str(size(v))]);
27 end
28
29 % Parse dimension information, flatted extra dimensions.
30 dim=size(u); nc=dim(2); nz=prod(dim(3:end));
31 u=reshape(u,[6*nc nc nz]);
32 v=reshape(v,[6*nc nc nz]);
33
34 % Do simple average to put u,v at the cell center (A-grid).
35 [uu,vv] = split_UV_cub(u,v);
36 uu=reshape(uu,[nc+1 nc nz 6]);
37 vv=reshape(vv,[nc nc+1 nz 6]);
38 u=(uu(1:nc,:,:,:)+uu(2:nc+1,:,:,:))/2;
39 v=(vv(:,1:nc,:,:)+vv(:,2:nc+1,:,:))/2;
40 u=reshape(permute(u,[1 4 2 3]),[6*nc*nc nz]);
41 v=reshape(permute(v,[1 4 2 3]),[6*nc*nc nz]);
42
43 % Make rotation to find uE, vN.
44 uE=NaN.*zeros(6*nc*nc,nz);
45 vN=NaN.*zeros(6*nc*nc,nz);
46 for k=1:nz;
47 uE(:,k)=AngleCS(:).*u(:,k)-AngleSN(:).*v(:,k);
48 vN(:,k)=AngleSN(:).*u(:,k)+AngleCS(:).*v(:,k);
49 end
50 uE = reshape(uE,dim);
51 vN = reshape(vN,dim);

  ViewVC Help
Powered by ViewVC 1.1.22