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

Contents of /MITgcm_contrib/osse/cyl2cartuv.m

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


Revision 1.2 - (show annotations) (download)
Tue Jun 8 14:14:44 2004 UTC (19 years, 11 months ago) by afe
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +1 -1 lines
FILE REMOVED
moving m-files around

1 function [u,v] = cyl2cartuv(thetav,rhov,xi,yi,varargin)
2 % [u,v]=cyl2cartuv(thetav,rhov,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(x,y,t,xi,yi);
13 %
14 % $Header: /u/gcmpack/MITgcm_contrib/osse/cyl2cartuv.m,v 1.1 2004/05/24 21:45:14 afe Exp $
15
16 if ~isequal(size(thetav),size(rhov))
17 error('Theta and rho vector arrays must be same size');
18 end
19
20 %work out mappings of polar to cartesian
21 NN=size(thetav);
22 [ntheta nrho nz]=size(thetav);
23 [RHO,THETA,NZ] = meshgrid(1:nrho,-pi+2*pi/ntheta:2*pi/ntheta:pi,1:nz);
24 [x,y] = pol2cart(THETA(:,:,1),RHO(:,:,1));
25 %[nx ny nz]=size(c);
26 nx=ntheta;ny=nrho;
27
28 % break out components
29 %vv=-(thetav.*-cos(THETA)+rhov.*sin(THETA));
30 %uv=-(thetav.*-sin(THETA)+rhov.*cos(THETA));
31 uv=thetav.*cos(THETA)+rhov.*sin(THETA);
32 vv=thetav.*-sin(THETA)+rhov.*cos(THETA);
33 %uv=thetav.*cos(THETA); %+rhov.*sin(THETA);
34 %vv=thetav.*-sin(THETA); %+rhov.*cos(THETA);
35 %uv=rhov.*sin(THETA);
36 %vv=rhov.*cos(THETA);
37
38
39 X=reshape(x,[1 nx*ny]);
40 Y=reshape(y,[1 nx*ny]);
41 del=griddata_preprocess(Y,X,yi,xi',varargin{:});
42
43 for k=1:nz;
44 UV=reshape(uv(:,:,k),[1 nx*ny]);
45 VV=reshape(vv(:,:,k),[1 nx*ny]);
46 u(:,:,k)=griddata(Y,X,UV,yi,xi',varargin{:});
47 v(:,:,k)=griddata(Y,X,VV,yi,xi',varargin{:});
48 % z(:,:,k)=griddata_fast(del,[C C(il) C(ig)],varargin{:});
49 end % k
50
51 % Split vertical and time dimensions
52 if size(NN,2)>2
53 u=reshape(u,[size(u,1) size(u,2) NN(3:end)]);
54 v=reshape(v,[size(v,1) size(v,2) NN(3:end)]);
55 end

  ViewVC Help
Powered by ViewVC 1.1.22