function [del] = cube2latlon(x,y,xi,yi,varargin) % z=cube2latlon(x,y,xi,yi); % % Re-grids model output on expanded spherical cube to lat-lon grid. % x,y are 2-D arrays of the cell-centered coordinates % c is a 2-D or 3-D scalar 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. % >> x=rdmds('XC'); % >> y=rdmds('YC'); % >> t=rdmds('Ttave.0000513360'); % >> xi=-179:2:180;yi=-89:2:90; % >> del=cube2latlon(x,y,xi,yi); % % $Header: /home/ubuntu/mnt/e9_copy/MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/cube2latlon_preprocess.m,v 1.1.1.1 2003/11/11 18:08:08 cnh Exp $ NN=size(x); [nx ny nz]=size(x); X=reshape(x,[1 nx*ny]); Y=reshape(y,[1 nx*ny]); ig=find(X>90); il=find(X<-90); del=griddata_preprocess([Y Y(il) Y(ig)],[X X(il)+360 X(ig)-360],yi,xi',varargin{:}); del.ig=ig; del.il=il;