Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/cs_grid/uvcube2latlon_fast.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
22586ff4d2 Alis*0001 function [U,V] = uvcube2latlon_fast(del,u,v)
                0002 % [ui,vi]=cube2latlon_fast(del,u,v);
                0003 %
                0004 % Re-grids model output on expanded spherical cube to lat-lon grid.
                0005 %  del   pre-processed transformation data
                0006 %  u,v   is a 2-D or 3-D horizontal components of model flow fields.
                0007 %  ui,vi are the flow fields with dimensions of size(xi) x size(yi) size(u,3).
                0008 %
                0009 % e.g.
                0010 % >> x=rdmds('XC');
                0011 % >> y=rdmds('YC');
                0012 % >> u=rdmds('uVeltave.0000513360');
                0013 % >> v=rdmds('vVeltave.0000513360');
                0014 % >> xi=-179:2:180;yi=-89:2:90;
                0015 % >> del=cube2latlon_preprocess(xi,yi,xc,yc);
                0016 % >> [ui,vi]=uvcube2latlon_fast(del,u,v);
                0017 %
f8d374081f Jean*0018 % Written by adcroft@.mit.edu, 2000.
22586ff4d2 Alis*0019 NN=size(u);
                0020 [nnx ny nz]=size(u);
                0021 
                0022 U=reshape(u,[ny 6 ny nz]);
                0023 V=reshape(v,[ny 6 ny nz]);
                0024 
                0025 uu=zeros(ny+1,6,ny,nz);
                0026 vv=zeros(ny,6,ny+1,nz);
                0027 
                0028 for k=1:6;
                0029  uu(1:ny,k,:,:)=U(:,k,:,:);
                0030  vv(:,k,1:ny,:)=V(:,k,:,:);
                0031 end
                0032 
                0033 for k=1:nz;
                0034 uu(ny+1,1:2:6,:,k)=uu(1,2:2:6,:,k);
                0035 uu(ny+1,2:2:6,:,k)=vv(ny:-1:1,[4:2:6 2:2:3],1,k)';
                0036 vv(:,2:2:6,ny+1,k)=vv(:,[3:2:6 1],1,k);
                0037 vv(:,1:2:6,ny+1,k)=squeeze(uu(1,[3:2:6 1],ny:-1:1,k))';
                0038 end
                0039 
                0040 ub=(uu(1:ny,:,:,:)+uu(2:ny+1,:,:,:))/2;
                0041 vb=(vv(:,:,1:ny,:)+vv(:,:,2:ny+1,:))/2;
                0042 
                0043 load TUV
                0044 
                0045 clear U V
                0046 for kk=1:nz;
                0047 for k=1:6;
                0048  U(:,k,:,kk)=TUu(:,:,k).*squeeze(ub(:,k,:,kk))+TUv(:,:,k).*squeeze(vb(:,k,:,kk));
                0049  V(:,k,:,kk)=TVu(:,:,k).*squeeze(ub(:,k,:,kk))+TVv(:,:,k).*squeeze(vb(:,k,:,kk));
                0050 end
                0051 end
                0052 
                0053 U=reshape(U,[nnx NN(2:end)]);
                0054 V=reshape(V,[nnx NN(2:end)]);
                0055 
                0056 U=cube2latlon_fast(del,U);
                0057 V=cube2latlon_fast(del,V);