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

1 function [z] = cube2latlon(x,y,c,xi,yi,varargin)
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/MITgcm/utils/matlab/cube2latlon.m,v 1.4 2004/06/04 17:03:50 adcroft Exp $
18
19 NN=size(c);
20 [nx ny nz]=size(c);
21
22 X=reshape(x,[1 nx*ny]);
23 Y=reshape(y,[1 nx*ny]);
24 ig=find(X>90);
25 il=find(X<-90);
26 del=griddata_preprocess([Y Y(il) Y(ig)],[X X(il)+360 X(ig)-360],yi,xi',varargin{:});
27
28 for k=1:nz;
29 C=reshape(c(:,:,k),[1 nx*ny]);
30 %z(:,:,k)=griddata([Y Y(il) Y(ig)],[X X(il)+360 X(ig)-360],[C C(il) C(ig)],yi,xi',varargin{:});
31 z(:,:,k)=griddata_fast(del,[C C(il) C(ig)],varargin{:});
32 end % k
33
34 % Split vertical and time dimensions
35 if size(NN,2)>2
36 z=reshape(z,[size(z,1) size(z,2) NN(3:end)]);
37 end

  ViewVC Help
Powered by ViewVC 1.1.22