/[MITgcm]/MITgcm/utils/matlab/uvcube2latlon.m
ViewVC logotype

Contents of /MITgcm/utils/matlab/uvcube2latlon.m

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


Revision 1.3 - (show annotations) (download)
Wed Aug 15 13:40:40 2001 UTC (22 years, 8 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint40pre8
Changes since 1.2: +3 -3 lines
fix bug: no reset of argument xc,yc

1 function [U,V] = uvcube2latlon(LON,LAT,u,v,xc,yc)
2 % [ui,vi]=cube2latlon(x,y,u,v,xi,yi);
3 %
4 % Re-grids model output on expanded spherical cube to lat-lon grid.
5 % x,y are 2-D arrays of the cell-centered coordinates
6 % u,v is a 2-D or 3-D horizontal components of model flow fields.
7 % xi,yi are vectors of the new regular lat-lon grid to interpolate to.
8 % ui,vi are the flow fields with dimensions of size(xi) x size(yi) size(u,3).
9 %
10 % e.g.
11 % >> x=rdmds('XC');
12 % >> y=rdmds('YC');
13 % >> u=rdmds('uVeltave.0000513360');
14 % >> v=rdmds('vVeltave.0000513360');
15 % >> xi=-179:2:180;yi=-89:2:90;
16 % >> [ui,vi]=uvcube2latlon(x,y,u,v,xi,yi);
17 %
18 % $Header: /u/gcmpack/models/MITgcmUV/utils/matlab/uvcube2latlon.m,v 1.2 2001/05/29 14:01:41 adcroft Exp $
19
20 [nnx ny nz]=size(u);
21
22 U=reshape(u,[ny 6 ny nz]);
23 V=reshape(v,[ny 6 ny nz]);
24
25 uu=zeros(ny+1,6,ny,nz);
26 vv=zeros(ny,6,ny+1,nz);
27
28 for k=1:6;
29 uu(1:ny,k,:,:)=U(:,k,:,:);
30 vv(:,k,1:ny,:)=V(:,k,:,:);
31 end
32
33 for k=1:nz;
34 uu(ny+1,1:2:6,:,k)=uu(1,2:2:6,:,k);
35 uu(ny+1,2:2:6,:,k)=vv(ny:-1:1,[4:2:6 2:2:3],1,k)';
36 vv(:,2:2:6,ny+1,k)=vv(:,[3:2:6 1],1,k);
37 vv(:,1:2:6,ny+1,k)=squeeze(uu(1,[3:2:6 1],ny:-1:1,k))';
38 end
39
40 ub=(uu(1:ny,:,:,:)+uu(2:ny+1,:,:,:))/2;
41 vb=(vv(:,:,1:ny,:)+vv(:,:,2:ny+1,:))/2;
42
43 load TUV
44
45 clear U V
46 for kk=1:nz;
47 for k=1:6;
48 U(:,k,:,kk)=TUu(:,:,k).*squeeze(ub(:,k,:,kk))+TUv(:,:,k).*squeeze(vb(:,k,:,kk));
49 V(:,k,:,kk)=TVu(:,:,k).*squeeze(ub(:,k,:,kk))+TVv(:,:,k).*squeeze(vb(:,k,:,kk));
50 end
51 end
52
53 U=reshape(U,[nnx ny nz]);
54 V=reshape(V,[nnx ny nz]);
55
56 % xc=-179:2:179;
57 % yc=-89:2:89;
58 U=cube2latlon(LON,LAT,U,xc,yc);
59 V=cube2latlon(LON,LAT,V,xc,yc);

  ViewVC Help
Powered by ViewVC 1.1.22