1 |
cnh |
1.1 |
function [z] = cube2latlon(del,c,varargin) |
2 |
|
|
% z=cube2latlon(x,y,c,xi,yi); |
3 |
|
|
% |
4 |
|
|
% Re-grids model output on expanded spherical cube to lat-lon grid. |
5 |
|
|
% x,y are 2-D arrays of the cell-centered coordinates |
6 |
|
|
% c is a 2-D or 3-D scalar field |
7 |
|
|
% xi,yi are vectors of the new regular lat-lon grid to interpolate to. |
8 |
|
|
% z is the interpolated data with dimensions of size(xi) by size(yi). |
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 |
|
|
% >> ti=cube2latlon(x,y,t,xi,yi); |
16 |
|
|
% |
17 |
|
|
% $Header: /u/gcmpack/models/MITgcmUV/utils/matlab/cube2latlon.m,v 1.3 2001/08/28 17:58:03 adcroft Exp $ |
18 |
|
|
|
19 |
|
|
NN=size(c); |
20 |
|
|
[nx ny nz]=size(c); |
21 |
|
|
|
22 |
|
|
for k=1:nz; |
23 |
|
|
C=reshape(c(:,:,k),[1 nx*ny]); |
24 |
|
|
|
25 |
|
|
z(:,:,k)=griddata_fast(del,[C C(del.il) C(del.ig)],varargin{:}); |
26 |
|
|
|
27 |
|
|
end % k |
28 |
|
|
|
29 |
|
|
% Split vertical and time dimensions |
30 |
|
|
if size(NN,2)>2 |
31 |
|
|
z=reshape(z,[size(z,1) size(z,2) NN(3:end)]); |
32 |
|
|
end |