/[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.6 - (show annotations) (download)
Thu Sep 15 20:07:45 2005 UTC (18 years, 10 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +1 -1 lines
FILE REMOVED
moved from utils/matlab to utils/matlab/cs_grid.

1 function [U,V,ub,vb] = 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/MITgcm/utils/matlab/uvcube2latlon.m,v 1.5 2004/06/04 17:03:50 adcroft Exp $
19
20 NN=size(u);
21 [nnx ny nz]=size(u);
22
23 U=reshape(u,[ny 6 ny nz]);
24 V=reshape(v,[ny 6 ny nz]);
25
26 uu=zeros(ny+1,6,ny,nz);
27 vv=zeros(ny,6,ny+1,nz);
28
29 for k=1:6;
30 uu(1:ny,k,:,:)=U(:,k,:,:);
31 vv(:,k,1:ny,:)=V(:,k,:,:);
32 end
33
34 for k=1:nz;
35 uu(ny+1,1:2:6,:,k)=uu(1,2:2:6,:,k);
36 uu(ny+1,2:2:6,:,k)=vv(ny:-1:1,[4:2:6 2:2:3],1,k)';
37 vv(:,2:2:6,ny+1,k)=vv(:,[3:2:6 1],1,k);
38 vv(:,1:2:6,ny+1,k)=squeeze(uu(1,[3:2:6 1],ny:-1:1,k))';
39 end
40
41 ub=(uu(1:ny,:,:,:)+uu(2:ny+1,:,:,:))/2;
42 vb=(vv(:,:,1:ny,:)+vv(:,:,2:ny+1,:))/2;
43
44 load TUV
45
46 clear U V
47 for kk=1:nz;
48 for k=1:6;
49 U(:,k,:,kk)=TUu(:,:,k).*squeeze(ub(:,k,:,kk))+TUv(:,:,k).*squeeze(vb(:,k,:,kk));
50 V(:,k,:,kk)=TVu(:,:,k).*squeeze(ub(:,k,:,kk))+TVv(:,:,k).*squeeze(vb(:,k,:,kk));
51 end
52 end
53
54 ub=reshape(U,[nnx NN(2:end)]);
55 vb=reshape(V,[nnx NN(2:end)]);
56
57 %U=cube2latlon(LON,LAT,U,xc,yc);
58 %V=cube2latlon(LON,LAT,V,xc,yc);
59 del=cube2latlon_preprocess(LON,LAT,xc,yc);
60 U=cube2latlon_fast(del,ub);
61 V=cube2latlon_fast(del,vb);

  ViewVC Help
Powered by ViewVC 1.1.22