/[MITgcm]/MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/griddata_fast.m
ViewVC logotype

Contents of /MITgcm_contrib/high_res_cube/matlab-grid-generator/bin/griddata_fast.m

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue Nov 11 18:08:08 2003 UTC (23 years ago) by cnh
Branch: MAIN, initial
CVS Tags: baseline, HEAD
Changes since 1.1: +0 -0 lines
Checking in work done with Dimitri on high-resolution cube gridding and parallel 
communications. 
   o code is in a contrib experiment for now so we can continue collaborating
     on it. However most code is general and will be moved into main branch once 
     it is fully hardened.
   o There are README files in the contrib root and in the subdirectories that
     explain the contents

1 function zi = griddata_fast(delau,z,method)
2 %GRIDDATA_FAST Data gridding and surface fitting.
3 % ZI = GRIDDATA_FAST(DEL,Z)
4 %
5 % See also GRIDDATA_PREPROCESS
6
7 % Clay M. Thompson 8-21-95
8 % Copyright 1984-2001 The MathWorks, Inc.
9 % $Revision: 5.28 $ $Date: 2001/04/15 11:59:14 $
10
11 error(nargchk(2,3,nargin))
12
13 if nargin<3, method = 'linear'; end
14 if ~isstr(method),
15 error('METHOD must be one of ''linear'',''cubic'',''nearest'', or ''v4''.');
16 end
17
18
19 % Sort x and y so duplicate points can be averaged before passing to delaunay
20
21 switch lower(method),
22 case 'linear'
23 zi = linear(delau,z);
24 % case 'cubic'
25 % zi = cubic(x,y,z,xi,yi);
26 % case 'nearest'
27 % zi = nearest(x,y,z,xi,yi);
28 % case {'invdist','v4'}
29 % zi = gdatav4(x,y,z,xi,yi);
30 otherwise
31 error('Unknown method.');
32 end
33
34 if nargout<=1, xi = zi; end
35
36
37 %------------------------------------------------------------
38 function zi = linear(del,z)
39 %LINEAR Triangle-based linear interpolation
40
41 % Reference: David F. Watson, "Contouring: A guide
42 % to the analysis and display of spacial data", Pergamon, 1994.
43
44 z = z(:).'; % Treat z as a row so that code below involving
45 % z(tri) works even when tri is 1-by-3.
46 zi = sum(z(del.tri) .* del.w,2);
47
48 zi = reshape(zi,del.siz);
49
50 if ~isempty(del.out), zi(del.out) = NaN; end
51
52 %------------------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.22