1 |
function [del] = cube2latlon_preprocess(x,y,xi,yi,varargin) |
2 |
% del=cube2latlon_preprocess(x,y,xi,yi); |
3 |
% |
4 |
% Calculates the data required for fast interpolation from the cube to a |
5 |
% latitude-longitude grid |
6 |
% x,y are 2-D arrays of the cell-centered coordinates |
7 |
% xi,yi are vectors of the new regular lat-lon grid to interpolate to. |
8 |
% del is the transformation data used by cube2latlon_fast |
9 |
% |
10 |
% e.g. |
11 |
% >> x=rdmds('XC'); |
12 |
% >> y=rdmds('YC'); |
13 |
% >> t=rdmds('Ttave.0000513360'); |
14 |
% >> xi=-179:2:180;yi=-89:2:90; |
15 |
% >> del=cube2latlon_preprocess(x,y,xi,yi); |
16 |
% >> ti=cube2latlon_fast(del,t); |
17 |
% |
18 |
% $Header: /u/gcmpack/MITgcm/utils/matlab/cube2latlon_preprocess.m,v 1.1 2004/06/04 15:50:52 adcroft Exp $ |
19 |
|
20 |
NN=size(x); |
21 |
[nx ny nz]=size(x); |
22 |
|
23 |
X=reshape(x,[1 nx*ny]); |
24 |
Y=reshape(y,[1 nx*ny]); |
25 |
ig=find(X>90); |
26 |
il=find(X<-90); |
27 |
del=griddata_preprocess([Y Y(il) Y(ig)],[X X(il)+360 X(ig)-360],yi,xi',varargin{:}); |
28 |
|
29 |
del.ig=ig; |
30 |
del.il=il; |