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

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

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


Revision 1.3 - (show annotations) (download)
Thu Jan 13 15:50:36 2005 UTC (20 years, 6 months ago) by afe
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -2 lines
removed commented cruft from m-files, added handy-dandy ready-made test data

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 % theta=0 is at 12 o'clock.
9 %
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=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 end % k
30
31 % Split vertical and time dimensions
32 if size(NN,2)>2
33 z=reshape(z,[size(z,1) size(z,2) NN(3:end)]);
34 end

  ViewVC Help
Powered by ViewVC 1.1.22