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

Annotation of /MITgcm_contrib/osse/utils/cyl2cart.m

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


Revision 1.2 - (hide annotations) (download)
Mon Jul 12 21:43:16 2004 UTC (21 years ago) by afe
Branch: MAIN
Changes since 1.1: +1 -0 lines
added help note about orientation of output

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 afe 1.2 % theta=0 is at 12 o'clock.
9 afe 1.1 %
10     % e.g.
11     % >> t=rdmds('Ttave.0000513360');
12     % >> xi=-179:2:180;yi=-89:2:90;
13     % >> ti=cyl2cart(t,xi,yi);
14     %
15    
16     NN=size(c);
17     [theta rho nz]=size(c);
18     [RHO,THETA] = meshgrid(1:rho,-pi+2*pi/theta:2*pi/theta:pi);
19     [x,y] = pol2cart(THETA,RHO);
20     %[nx ny nz]=size(c);
21     nx=theta;ny=rho;
22    
23     X=reshape(x,[1 nx*ny]);
24     Y=reshape(y,[1 nx*ny]);
25     del=griddata_preprocess(Y,X,yi,xi',varargin{:});
26    
27     for k=1:nz;
28     C=reshape(c(:,:,k),[1 nx*ny]);
29     z(:,:,k)=griddata(Y,X,C,yi,xi',varargin{:});
30     % z(:,:,k)=griddata_fast(del,[C C(il) C(ig)],varargin{:});
31     end % k
32    
33     % Split vertical and time dimensions
34     if size(NN,2)>2
35     z=reshape(z,[size(z,1) size(z,2) NN(3:end)]);
36     end

  ViewVC Help
Powered by ViewVC 1.1.22