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

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

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


Revision 1.2 - (show annotations) (download)
Tue May 29 14:01:40 2001 UTC (22 years, 11 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint40pre1, checkpoint40pre2, checkpoint40pre5, checkpoint40pre6, checkpoint40pre8, checkpoint40pre4, checkpoint40pre3, checkpoint40pre7
Changes since 1.1: +48 -0 lines
Merge from branch pre38:
 o essential mods for cubed sphere
 o debugged atmosphere, dynamcis + physics (aim)
 o new packages (mom_vecinv, mom_fluxform, ...)

1 function [z] = cube2latlon(x,y,c,xi,yi)
2 % z=cube2latlon(x,y,c,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 % c is a 2-D or 3-D scalar field
7 % xi,yi are vectors of the new regular lat-lon grid to interpolate to.
8 % z is the interpolated data with dimensions of size(xi) by size(yi).
9 %
10 % e.g.
11 % >> x=rdmds('XC');
12 % >> y=rdmds('YC');
13 % >> t=rdmds('Ttave.0000513360');
14 % >> xi=-179:2:180;yi=-89:2:90;
15 % >> ti=cube2latlon(x,y,t,xi,yi);
16 %
17 % $Header: /u/gcmpack/models/MITgcmUV/utils/matlab/Attic/cube2latlon.m,v 1.1.2.1 2001/04/13 18:28:23 adcroft Exp $
18
19 [nx ny nz]=size(c);
20
21 for k=1:nz;
22 X=x;
23 Y=y;
24 C=c(:,:,k);
25
26 i=3*ny+(1:ny);j=floor(ny/2);
27 X(end+1,:)=X(i,j)'-360; Y(end+1,:)=Y(i,j)'; C(end+1,:)=C(i,j)';
28 i=3*ny+(1:ny);j=floor(ny/2)+1;
29 X(end+1,:)=X(i,j)'+360; Y(end+1,:)=Y(i,j)'; C(end+1,:)=C(i,j)';
30 i=5*ny+round(ny/2);j=1:floor(ny/2);
31 X(end+1,j)=X(i,j)+360;
32 Y(end+1,j)=Y(i,j);
33 C(end+1,j)=C(i,j);
34 i=5*ny+round(ny/2)+1;j=1:floor(ny/2);
35 X(end,j+ny/2)=X(i,j)-360;
36 Y(end,j+ny/2)=Y(i,j);
37 C(end,j+ny/2)=C(i,j);
38 i=2*32+(ny/2+1:ny);j=floor(ny/2);
39 X(end+1,1:ny/2)=X(i,j)'-360;
40 Y(end+1,1:ny/2)=Y(i,j)';
41 C(end+1,1:ny/2)=C(i,j)';
42 i=2*32+(ny/2+1:ny);j=floor(ny/2)+1;
43 X(end,ny/2+1:ny)=X(i,j)'+360;
44 Y(end,ny/2+1:ny)=Y(i,j)';
45 C(end,ny/2+1:ny)=C(i,j)';
46
47 z(:,:,k)=griddata(Y,X,C,yi,xi');
48 end % k

  ViewVC Help
Powered by ViewVC 1.1.22