Warning, /utils/matlab/cs_grid/fancycube.m is written in an unsupported language. File is not indexed.
view on githubraw file Latest commit add29e06 on 2018-01-31 20:35:05 UTC
9e9d388224 Alis*0001 function [] = fancycube(XX,YY,C,H,r)
0002 % fancycube(x,y,c,h)
0003 %
0004 % Plots cubed-sphere data in 3D on sphere. (x,y) are
0005 % coordinates, c is cell-centered scalar to be plotted.
0006 % Dimensions should be N+1 x N+1 x 6 for (x,y)
0007 % and N x N x 6 for c
0008 %
0009 % The default plotting mode is shading faceted. Using this or
0010 % shading flat, (x,y) should be the coordinates of grid-corners
0011 % and can legitimately have dimension (N+1)x(N+1)x6.
0012 %
0013 % If using shading interp, then (x,y) must be the coordinates of
0014 % the cell centers with same dimensions as c.
0015 %
0016 % e.g.
0017 %
0018 % xg=rdmds('XG');
0019 % yg=rdmds('YG');
0020 % ps=rdmds('Eta.0000000000');
0021 % h=rdmds('ETOPO5');
0022 % fancycube(xg,yg,ps,h,0.05/5000);
f8d374081f Jean*0023 %
0024 % Written by adcroft@.mit.edu, 2005.
9e9d388224 Alis*0025 if max(max(max(YY)))-min(min(min(YY))) < 3*pi
0026 X=tiles(XX*180/pi,1:6);
0027 Y=tiles(YY*180/pi,1:6);
0028 else
0029 X=tiles(XX,1:6);
0030 Y=tiles(YY,1:6);
0031 end
0032 Q=(tiles(C,1:6));
0033 Qmin=min(Q(:)); Qmax=max(Q(:)); Q=(Q-Qmin)/(Qmax-Qmin)-1;
0034 q=(tiles(H,1:6));
0035 q( find(~isnan(Q)) )=NaN;
0036 %q=min(q,5000);
0037 %q=max(q,0);
0038 qmin=min(q(:)); qmax=max(q(:)); q=(q-qmin)/(qmax-qmin);
0039 Q( find(isnan(Q)) )=q( find(isnan(Q)) );
0040
0041 % Assume model grid corner coordinates were provided.
0042 if size(X,1)==size(Q,1)
0043 X(end+1,:,:)=NaN;
0044 X(:,end+1,:)=NaN;
0045 X(end,:,[1 3 5])=X(1,:,[2 4 6]);
0046 X(:,end,[2 4 6])=X(:,1,[3 5 1]);
0047 X(:,end,[1 3 5])=squeeze(X(1,end:-1:1,[3 5 1]));
0048 X(end,:,[2 4 6])=squeeze(X(end:-1:1,1,[4 6 2]));
0049 Y(end+1,:,:)=NaN;
0050 Y(:,end+1,:)=NaN;
0051 Y(end,:,[1 3 5])=Y(1,:,[2 4 6]);
0052 Y(:,end,[2 4 6])=Y(:,1,[3 5 1]);
0053 Y(:,end,[1 3 5])=squeeze(Y(1,end:-1:1,[3 5 1]));
0054 Y(end,:,[2 4 6])=squeeze(Y(end:-1:1,1,[4 6 2]));
0055 end
0056 [nx ny nt]=size(X);
0057
0058 H=tiles(H,1:6); H(end+1,:,:)=H(end,:,:);H(:,end+1,:)=H(:,end,:);
0059 R=ones(size(X))+r*H;
0060
0061 z=R.*sin(Y*pi/180);
0062 x=R.*cos(Y*pi/180).*cos(X*pi/180-pi/2);
0063 y=R.*cos(Y*pi/180).*sin(X*pi/180-pi/2);
0064
0065 surf(x(:,:,1),y(:,:,1),z(:,:,1),Q(:,:,1))
0066 hold on
0067 for j=2:6
0068 surf(x(:,:,j),y(:,:,j),z(:,:,j),Q(:,:,j))
0069 end
0070 hold off
0071 xlabel('X');
0072 ylabel('Y');
0073 zlabel('Z');
0074
0075 % Remake colormap
0076 if size(colormap,1)==64
0077 CM=colormap;
0078 cm=cm_landwater(64,0);
0079 colormap( [CM' cm']' )
0080 end
0081
0082 shading flat
0083 axis([-1 1 -1 1 -1 1]*max(R(:)))
0084 axis square
0085 axis vis3d
0086 pos=get(gcf,'pos');set(gcf,'pos',[pos(1:2) [1 1]*480]) % Movie size (+ screen)
0087 set(gca,'pos',[0 0 1 1]+.25*[-1 -1 2 2]); % Fill window
0088 set(gcf,'paperposition',[0 0 4 4]) % Square printing
106c7fa961 Alis*0089 set(gca,'projection','perspective')
9e9d388224 Alis*0090
0091