--- MITgcm_contrib/osse/utils/cart2cyl.m 2004/07/12 23:24:35 1.1 +++ MITgcm_contrib/osse/utils/cart2cyl.m 2005/01/05 20:40:21 1.3 @@ -1,25 +1,30 @@ function [z] = cart2cyl(c,thetai,rhoi,varargin) % z=cart2cyl(c,xi,yi); % -% Re-grids model output in cylindrical coords to cartesian. -% c is a 2-D or 3-D scalar or z-vector field -% xi,yi are vectors of the new regular lat-lon grid to interpolate to. -% z is the interpolated data with dimensions of size(xi) by size(yi). -% -% e.g. -% >> t=rdmds('Ttave.0000513360'); -% >> xi=-179:2:180;yi=-89:2:90; -% >> ti=cyl2cart(t,xi,yi); -% NN=size(c); %[theta rho nz]=size(c); [x y nz]=size(c); %[RHO,THETA] = meshgrid(1:rho,-pi+2*pi/theta:2*pi/theta:pi); -[Y,X] = meshgrid(-(x-1)/2:(x-1)/2,-(y-1)/2:(y-1)/2); +%[Y,X] = meshgrid(-(x-1)/2:(x-1)/2,-(y-1)/2:(y-1)/2); +%stepx=(2*x+1)/(2*x); +%stepy=(2*y+1)/(2*y); +stepx=(x+1)/(x); +stepy=(y+1)/(y); +[Y,X] = meshgrid(-(x)/2:stepx:(x)/2,-(y)/2:stepy:(y)/2); +%[Y,X] = meshgrid(x,y); +%[Y,X] = meshgrid(-(x)/2:stepx:(x)/2+stepx,-(y)/2:stepy:(y)/2+stepy); %[x,y] = pol2cart(THETA,RHO); [theta,rho] = cart2pol(X,Y); -theta=(theta./(pi*2)+0.5).*size(thetai,2); +%theta=(theta./(pi*2)+0.5).*size(thetai,2); +%theta=theta.*2*((size(thetai,2)+1)/size(thetai,2)); +%theta=(theta./(pi*2)+0.5).*(size(thetai,2)+1); +%theta=(theta./(pi*2)+0.5).*(size(thetai,2)); +theta=(theta./(pi*2)+0.5).*(size(thetai,2)); +%theta=(theta./pi).*size(thetai,2); +%theta=(theta./(pi*2)).*size(thetai,2); +%rho=max(rhoi)*rho/((x-1)/2); +rho=max(rhoi)*rho/((x)/2); %theta=rot90(theta.*180./pi,-1); %[nx ny nz]=size(c); %nx=theta;ny=rho;