/[MITgcm]/MITgcm/utils/matlab/plotcube.m
ViewVC logotype

Annotation of /MITgcm/utils/matlab/plotcube.m

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


Revision 1.4 - (hide annotations) (download)
Thu Sep 15 20:07:45 2005 UTC (18 years, 7 months ago) by jmc
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
FILE REMOVED
moved from utils/matlab to utils/matlab/cs_grid.

1 adcroft 1.3 function [] = plotcube(XX,YY,C)
2     % plotcube(x,y,c)
3     %
4     % Plots cubed-sphere data in 3D on sphere. (x,y) are
5     % coordinates, c is cell-centered scalar to be plotted.
6     % Dimensions should be N+1 x N+1 x 6 for (x,y)
7     % and N x N x 6 for c
8     %
9     % The default plotting mode is shading faceted. Using this or
10     % shading flat, (x,y) should be the coordinates of grid-corners
11     % and can legitimately have dimension (N+1)x(N+1)x6.
12     %
13     % If using shading interp, then (x,y) must be the coordinates of
14     % the cell centers with same dimensions as c.
15     %
16 adcroft 1.2 % e.g.
17     %
18 adcroft 1.3 % xg=rdmds('XG');
19     % yg=rdmds('YG');
20     % ps=rdmds('Eta.0000000000');
21     % plotube(xg,yg,ps);
22     %
23     % xc=rdmds('XC');
24     % yc=rdmds('YC');
25     % plotube(xg,yg,ps);shading interp
26    
27     if max(max(max(YY)))-min(min(min(YY))) < 3*pi
28     X=tiles(XX*180/pi,1:6);
29     Y=tiles(YY*180/pi,1:6);
30     else
31     X=tiles(XX,1:6);
32     Y=tiles(YY,1:6);
33     end
34     Q=tiles(C,1:6);
35    
36     % Assume model grid corner coordinates were provided.
37     if size(X,1)==size(Q,1)
38     X(end+1,:,:)=NaN;
39     X(:,end+1,:)=NaN;
40     X(end,:,[1 3 5])=X(1,:,[2 4 6]);
41     X(:,end,[2 4 6])=X(:,1,[3 5 1]);
42     X(:,end,[1 3 5])=squeeze(X(1,end:-1:1,[3 5 1]));
43     X(end,:,[2 4 6])=squeeze(X(end:-1:1,1,[4 6 2]));
44     Y(end+1,:,:)=NaN;
45     Y(:,end+1,:)=NaN;
46     Y(end,:,[1 3 5])=Y(1,:,[2 4 6]);
47     Y(:,end,[2 4 6])=Y(:,1,[3 5 1]);
48     Y(:,end,[1 3 5])=squeeze(Y(1,end:-1:1,[3 5 1]));
49     Y(end,:,[2 4 6])=squeeze(Y(end:-1:1,1,[4 6 2]));
50     end
51     [nx ny nt]=size(X);
52 adcroft 1.2
53 adcroft 1.3 z=sin(Y*pi/180);
54     x=cos(Y*pi/180).*cos(X*pi/180);
55     y=cos(Y*pi/180).*sin(X*pi/180);
56 adcroft 1.2
57 adcroft 1.3 surf(x(:,:,1),y(:,:,1),z(:,:,1),Q(:,:,1))
58 adcroft 1.2 hold on
59     for j=2:6
60 adcroft 1.3 surf(x(:,:,j),y(:,:,j),z(:,:,j),Q(:,:,j))
61 adcroft 1.2 end
62     hold off
63     xlabel('X');
64     ylabel('Y');
65     zlabel('Z');

  ViewVC Help
Powered by ViewVC 1.1.22