/[MITgcm]/MITgcm_contrib/osse/cyl2cart.m
ViewVC logotype

Annotation of /MITgcm_contrib/osse/cyl2cart.m

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


Revision 1.1 - (hide annotations) (download)
Thu May 20 21:40:02 2004 UTC (20 years ago) by afe
Branch: MAIN
o converts model output from cyl to cartesian coords

1 afe 1.1 function [z] = cyl2cart(c,xi,yi,varargin)
2     % z=cyl2cart(c,xi,yi);
3     %
4     % Re-grids model output in cylindrical coords to cartesian.
5     % c is a 2-D or 3-D scalar or z-vector field
6     % xi,yi are vectors of the new regular lat-lon grid to interpolate to.
7     % z is the interpolated data with dimensions of size(xi) by size(yi).
8     %
9     % e.g.
10     % >> t=rdmds('Ttave.0000513360');
11     % >> xi=-179:2:180;yi=-89:2:90;
12     % >> ti=cyl2cart(t,xi,yi);
13     %
14    
15     NN=size(c);
16     [theta rho nz]=size(c);
17     [RHO,THETA] = meshgrid(1:rho,-pi+2*pi/theta:2*pi/theta:pi);
18     [x,y] = pol2cart(THETA,RHO);
19     %[nx ny nz]=size(c);
20     nx=theta;ny=rho;
21    
22     X=reshape(x,[1 nx*ny]);
23     Y=reshape(y,[1 nx*ny]);
24     del=griddata_preprocess(Y,X,yi,xi',varargin{:});
25    
26     for k=1:nz;
27     C=reshape(c(:,:,k),[1 nx*ny]);
28     z(:,:,k)=griddata(Y,X,C,yi,xi',varargin{:});
29     % z(:,:,k)=griddata_fast(del,[C C(il) C(ig)],varargin{:});
30     end % k
31    
32     % Split vertical and time dimensions
33     if size(NN,2)>2
34     z=reshape(z,[size(z,1) size(z,2) NN(3:end)]);
35     end

  ViewVC Help
Powered by ViewVC 1.1.22