/[MITgcm]/MITgcm_contrib/mlosch/interp_llc/pcol.m
ViewVC logotype

Annotation of /MITgcm_contrib/mlosch/interp_llc/pcol.m

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


Revision 1.1 - (hide annotations) (download)
Thu May 3 21:07:21 2007 UTC (17 years ago) by mlosch
Branch: MAIN
CVS Tags: HEAD
initial checkin of topography and hydrography interpolation scripts for
the llc-grid, based on old matlab scripts by Alistair Adcroft
Let's hope, they are useful.

1 mlosch 1.1 % Similar to pcolor except that pcol() doesn't drop the last column
2     % or row of data (ie. doesn't interpolated). It uses the shading flat
3     % method by default.
4     %
5     % See also PCOLOR, IMAGESC
6     function [hh] = pcol(varargin);
7    
8     %cmap=colormap;
9     %if cmap(size(cmap,1),:)==[0 0 0]
10     %else
11     % if sum(sum(isnan(data)))~=0
12     % colormap( [colormap' [0 0 0]']')
13     % end
14     %end
15    
16     % Scale data to fit colormap
17     %clim=[min(min(data)) max(max(data))];
18     %data=(data-clim(1))/(clim(2)-clim(1))*(size(colormap,1)-1)+1;
19     %data(find(isnan(data)==1))=size(colormap,1)+1;
20    
21     if nargin == 1
22     data=varargin{1};
23     h = pcolor(data([1:end 1],[1:end 1]));
24     else
25     x=varargin{1};
26     y=varargin{2};
27     data=varargin{3};
28     if isvector(x) & isvector(y)
29     x=x(:);
30     y=y(:);
31     h = pcolor([x' 2*x(end)-x(end-1)],...
32     [y' 2*y(end)-y(end-1)],...
33     data([1:end 1],[1:end 1]));
34     else
35     x=[x 2*x(:,end)-x(:,end-1)];
36     x=[x; 2*x(end,:)-x(end-1,:)];
37     y=[y 2*y(:,end)-y(:,end-1)];
38     y=[y; 2*y(end,:)-y(end-1,:)];
39     h = pcolor(x, ...
40     y, ...
41     data([1:end 1],[1:end 1]));
42     end
43     end
44     set(gca,'Layer','top')
45     shading flat;
46    
47     if nargout == 1;
48     hh = h;
49     end
50    
51     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
52     function answer = isvector(v)
53    
54     if prod(size(v)) == length(v)
55     answer = 1;
56     else
57     answer = 0;
58     end
59    
60     return

  ViewVC Help
Powered by ViewVC 1.1.22