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

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

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


Revision 1.2 - (hide annotations) (download)
Tue Jul 13 16:26:51 2004 UTC (21 years ago) by afe
Branch: MAIN
Changes since 1.1: +1 -0 lines
minor improvement

1 afe 1.1 function [z] = cart2cyl(c,thetai,rhoi,varargin)
2     % z=cart2cyl(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     [x y nz]=size(c);
18     %[RHO,THETA] = meshgrid(1:rho,-pi+2*pi/theta:2*pi/theta:pi);
19     [Y,X] = meshgrid(-(x-1)/2:(x-1)/2,-(y-1)/2:(y-1)/2);
20     %[x,y] = pol2cart(THETA,RHO);
21     [theta,rho] = cart2pol(X,Y);
22     theta=(theta./(pi*2)+0.5).*size(thetai,2);
23 afe 1.2 rho=max(rhoi)*rho/((x-1)/2);
24 afe 1.1 %theta=rot90(theta.*180./pi,-1);
25     %[nx ny nz]=size(c);
26     %nx=theta;ny=rho;
27     ntheta=x;nrho=y;
28    
29     %X=reshape(x,[1 nx*ny]);
30     %Y=reshape(y,[1 nx*ny]);
31     THETA=reshape(theta,[1 ntheta*nrho]);
32     RHO=reshape(rho,[1 ntheta*nrho]);
33     %del=griddata_preprocess(Y,X,yi,xi',varargin{:});
34     del=griddata_preprocess(RHO,THETA,rhoi,thetai',varargin{:});
35    
36     for k=1:nz;
37     C=reshape(c(:,:,k),[1 ntheta*nrho]);
38     z(:,:,k)=griddata(RHO,THETA,C,rhoi,thetai',varargin{:});
39     %z(:,:,k)=griddata(Y,X,C,yi,xi',varargin{:});
40     % z(:,:,k)=griddata_fast(del,[C C(il) C(ig)],varargin{:});
41     end % k
42    
43     % Split vertical and time dimensions
44     if size(NN,2)>2
45     z=reshape(z,[size(z,1) size(z,2) NN(3:end)]);
46     end

  ViewVC Help
Powered by ViewVC 1.1.22