Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/cs_grid/cube2latlon.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 [z] = cube2latlon(x,y,c,xi,yi,varargin)
aea29c8517 Alis*0002 % z=cube2latlon(x,y,c,xi,yi);
                0003 %
                0004 % Re-grids model output on expanded spherical cube to lat-lon grid.
                0005 %  x,y   are 2-D arrays of the cell-centered coordinates 
                0006 %  c     is a 2-D or 3-D scalar field
                0007 %  xi,yi are vectors of the new regular lat-lon grid to interpolate to.
                0008 %  z     is the interpolated data with dimensions of size(xi) by size(yi).
                0009 %
                0010 % e.g.
                0011 % >> x=rdmds('XC');
                0012 % >> y=rdmds('YC');
                0013 % >> t=rdmds('Ttave.0000513360');
                0014 % >> xi=-179:2:180;yi=-89:2:90;
                0015 % >> ti=cube2latlon(x,y,t,xi,yi);
                0016 %
f8d374081f Jean*0017 % Written by adcroft@.mit.edu, 2001.
c3849470ee Alis*0018 NN=size(c);
aea29c8517 Alis*0019 [nx ny nz]=size(c);
                0020 
22586ff4d2 Alis*0021 X=reshape(x,[1 nx*ny]);
                0022 Y=reshape(y,[1 nx*ny]);
                0023 ig=find(X>90);
                0024 il=find(X<-90);
                0025 del=griddata_preprocess([Y Y(il) Y(ig)],[X X(il)+360 X(ig)-360],yi,xi',varargin{:});
aea29c8517 Alis*0026 
22586ff4d2 Alis*0027 for k=1:nz;
                0028  C=reshape(c(:,:,k),[1 nx*ny]);
                0029 %z(:,:,k)=griddata([Y Y(il) Y(ig)],[X X(il)+360 X(ig)-360],[C C(il) C(ig)],yi,xi',varargin{:});
                0030  z(:,:,k)=griddata_fast(del,[C C(il) C(ig)],varargin{:});
aea29c8517 Alis*0031 end % k
c3849470ee Alis*0032 
22586ff4d2 Alis*0033 % Split vertical and time dimensions
c3849470ee Alis*0034 if size(NN,2)>2
                0035 z=reshape(z,[size(z,1) size(z,2) NN(3:end)]);
                0036 end