1 
function [hc,hh,hcf] = pcolorfv(x,z,h,a,varargin) 
2 
% PCOLORFV(X,Z,H,A) 
3 
% 
4 
% Is the same as PCOLORFV except it automatically extends the dataset 
5 
% to the depth of the topography "H". This is srictly for plotting 
6 
% vertical (x,z) sections in conjuction with "partial cells" in the MITgcm. 
7 
% 
8 
% X is horizontal coordinate (vector) 
9 
% Z is vertical coordinate (vector) 
10 
% H is depth of bottom (vector) 
11 
% A is field to be plotted (matrix) 
12 
% 
13 
% Optional arguments are passed on to PCOLOR 
14 

15 
% $Header: /u/gcmpack/MITgcm/utils/matlab/pcolorfv.m,v 1.2 2004/06/04 17:09:11 adcroft Exp $ 
16 
% $Name: $ 
17 

18 
nx=prod(size(x)); 
19 
nz=prod(size(z)); 
20 
%max(size(h)) 
21 
%prod(size(h)) 
22 
if max(size(h)) ~= prod(size(h))  prod(size(h)) ~= nx 
23 
error('H must have dimensions of size(X)'); 
24 
end 
25 
%ndims(squeeze(a)) 
26 
%size(squeeze(a)) 
27 
if ndims(squeeze(a)) ~= 2  sum(size(squeeze(a)) ~= [nx nz]) 
28 
error('A must have dimensions of size(X) x size(H)'); 
29 
end 
30 

31 
% Create extended Z coordinate 
32 
zz=zeros(1,nz+2); 
33 
zz(2:nz+1)=z; 
34 
zz(1)=0; 
35 
zz(nz+2)=1.5*z(nz)0.5*z(nz1); 
36 

37 
[Z,X]=meshgrid(zz,x); 
38 

39 
aa=squeeze(a); 
40 
au=aa(:,[1 1:nz1]); 
41 
aa(isnan(aa))=au(isnan(aa)); 
42 
A=zeros(nx,nz+2); 
43 
A(:,2:nz+1)=aa; 
44 
A(:,1)=aa(:,1); 
45 
A(:,nz+2)=aa(:,nz); 
46 
clear aa au 
47 

48 
[Hz,Hx]=meshgrid(zz,h); 
49 
clear Hz 
50 

51 

52 
% H might be positive... 
53 
if min(z)*min(h) > 0 
54 
Z=max(Z,Hx); 
55 
else 
56 
Z=max(Z,Hx); 
57 
end 
58 
clear Hx 
59 

60 
pcolor(X,Z,A,varargin{:}); 