/[MITgcm]/MITgcm/utils/cs_grid/rotate_csAg_EN.m
ViewVC logotype

Contents of /MITgcm/utils/cs_grid/rotate_csAg_EN.m

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


Revision 1.1 - (show annotations) (download)
Tue Jun 28 02:34:54 2005 UTC (18 years, 3 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint57o_post, checkpoint57l_post, checkpoint57j_post, checkpoint57k_post, checkpoint57n_post, checkpoint57m_post, checkpoint57p_post
add matlab scripts that deal with vector components on CS-grid

1 function [uE,vN] = rotate_csAg_EN(u,v)
2 % [uE,vN] = rotate_csAg_EN(u,v)
3 %
4 % Rotate U,V vector components of cs-grid (A-grid) to East,North directions
5 % u,v is a 2-D or 3-D horizontal components of a flow fields.
6 % uE,vN are the Eastward,Northward components of the rotated flow field
7 % assume that the 1rst 2 dimensions of (u,v) are [6*nc nc] for a CS(nc x nc) grid
8 %
9 % $Header: $
10
11 %Rac='/home/jmc/grid_cs32/' ;
12 Rac='grid_files/';
13
14 NN=size(u);
15 [nnx nc nz]=size(u);
16 nPg=nnx*nc;
17 if nnx ~= 6*nc,
18 fprintf('Error in CS-dim: %i %i %i \n',NN);
19 return
20 end
21
22 u=reshape(u,[nPg nz]);
23 v=reshape(v,[nPg nz]);
24
25 %- rotate toward E,N (lon,lat) directions :
26 % load COS & SIN of rotation angle:
27 namfil=['proj_cs',int2str(nc),'_2uEvN.bin'];
28 fid=fopen([Rac,namfil],'r','b'); uvEN=fread(fid,nPg*2,'real*8'); fclose(fid);
29 uvEN=reshape(uvEN,[nPg 2]);
30
31 uE=zeros(nPg,nz); vN=zeros(nPg,nz);
32 for k=1:nz;
33 uE(:,k)=uvEN(:,1).*u(:,k)-uvEN(:,2).*v(:,k);
34 vN(:,k)=uvEN(:,2).*u(:,k)+uvEN(:,1).*v(:,k);
35 end
36
37 uE=reshape(uE,[nnx NN(2:end)]);
38 vN=reshape(vN,[nnx NN(2:end)]);
39
40 return

  ViewVC Help
Powered by ViewVC 1.1.22