Back to home page

MITgcm

 
 

    


Warning, /utils/matlab/Graphix/GraphixUtility/merccube_mod.m is written in an unsupported language. File is not indexed.

view on githubraw file Latest commit 4cf7d6e4 on 2006-06-29 18:52:07 UTC
892fe9e2f3 Dani*0001 function [] = merccube(XX,YY,C)
                0002 % merccube(x,y,c)
                0003 %
                0004 % Plots cubed-sphere data in mercator projection. (x,y) are
                0005 % coordinates, c is cell-centered scalar to be plotted.
                0006 % All arrays (x,y,c) should have dimensions of NxNx6 or 6NxN.
                0007 %
                0008 % The default plotting mode is shading faceted. Using this or
                0009 % shading flat, (x,y) should be the coordinates of grid-corners
                0010 % and can legitimately have dimension (N+1)x(N+1)x6.
                0011 %
                0012 % If using shading interp, then (x,y) must be the coordinates of
                0013 % the cell centers.
                0014 %
                0015 % e.g.
                0016 %
                0017 % xg=rdmds('XG');
                0018 % yg=rdmds('YG');
                0019 % ps=rdmds('Eta.0000000000');
                0020 % mercube(xg,yg,ps);
                0021 % colorbar;xlabel('Longitude');ylabel('Latitude');
                0022 %
                0023 % xc=rdmds('XC');
                0024 % yc=rdmds('YC');
                0025 % mercube(xc,yc,ps);shading interp
                0026 
                0027 XXdim = size(XX);
                0028 XX = reshape(XX,[prod(XXdim),1]);
                0029 XX(find(abs(XX) < 0.01)) = 0;
                0030 XX(find(abs(XX) > 179.99)) = 180;
                0031 XX = reshape(XX,XXdim);
                0032 
                0033 if max(max(max(YY)))-min(min(min(YY))) < 3*pi
4cf7d6e47a Dani*0034  convert=(180/pi);
892fe9e2f3 Dani*0035 else
4cf7d6e47a Dani*0036  convert=1;
892fe9e2f3 Dani*0037 end
4cf7d6e47a Dani*0038 X=XX;
                0039 Y=YY;
892fe9e2f3 Dani*0040 Q=C;
                0041 
                0042 if ndims(Q)==2 & size(Q,1)==6*size(Q,2)
                0043  [nx ny nt]=size(X);
                0044  X=permute( reshape(X,[nx/6 6 ny]),[1 3 2]);
                0045  Y=permute( reshape(Y,[nx/6 6 ny]),[1 3 2]);
                0046  Q=permute( reshape(Q,[nx/6 6 ny]),[1 3 2]);
                0047 elseif ndims(Q)==3 & size(Q,2)==6
                0048  X=permute( X,[1 3 2]);
                0049  Y=permute( Y,[1 3 2]);
                0050  Q=permute( Q,[1 3 2]);
                0051 elseif ndims(Q)==3 & size(Q,3)==6
                0052  [nx ny nt]=size(X);
                0053 else
                0054  size(XX)
                0055  size(YY)
                0056  size(C)
                0057  error('Dimensions should be 2 or 3 dimensions: NxNx6, 6NxN or Nx6xN');
                0058 end
                0059 
                0060 if size(X,1)==size(Q,1)
                0061  X(end+1,:,:)=NaN;
                0062  X(:,end+1,:)=NaN;
                0063  X(end,:,[1 3 5])=X(1,:,[2 4 6]);
                0064  X(:,end,[2 4 6])=X(:,1,[3 5 1]);
                0065  X(:,end,[1 3 5])=squeeze(X(1,end:-1:1,[3 5 1]));
                0066  X(end,:,[2 4 6])=squeeze(X(end:-1:1,1,[4 6 2]));
4cf7d6e47a Dani*0067  X(1,end,[1 3 5])=X(1,1,1);
                0068  X(end,1,[2 4 6])=X(end,end,2);
892fe9e2f3 Dani*0069  Y(end+1,:,:)=NaN;
                0070  Y(:,end+1,:)=NaN;
                0071  Y(end,:,[1 3 5])=Y(1,:,[2 4 6]);
                0072  Y(:,end,[2 4 6])=Y(:,1,[3 5 1]);
                0073  Y(:,end,[1 3 5])=squeeze(Y(1,end:-1:1,[3 5 1]));
                0074  Y(end,:,[2 4 6])=squeeze(Y(end:-1:1,1,[4 6 2]));
4cf7d6e47a Dani*0075  Y(1,end,[1 3 5])=Y(end,end,1);
                0076  Y(end,1,[2 4 6])=Y(1,1,2);
892fe9e2f3 Dani*0077 end
                0078 [nx ny nt]=size(X);
                0079 
                0080 Q(end+1,:,:)=NaN;
                0081 Q(:,end+1,:)=NaN;
                0082 Q(end,:,[1 3 5])=Q(1,:,[2 4 6]);
                0083 Q(:,end,[2 4 6])=Q(:,1,[3 5 1]);
                0084 Q(:,end,[1 3 5])=squeeze(Q(1,end:-1:1,[3 5 1]));
                0085 Q(end,:,[2 4 6])=squeeze(Q(end:-1:1,1,[4 6 2]));
                0086 
                0087 hnx=ceil(nx/2);
                0088 hny=ceil(ny/2);
                0089 
                0090 for k=1:6;
                0091  i=1:hnx;
4cf7d6e47a Dani*0092  x=longitude(convert.*X(i,:,k))./convert;
892fe9e2f3 Dani*0093  pcolor(x,Y(i,:,k),Q(i,:,k))
4cf7d6e47a Dani*0094  axis([-180 180 -90 90]./convert);
892fe9e2f3 Dani*0095  hold on
4cf7d6e47a Dani*0096  if max(max(max(x)))>180./convert
                0097   pcolor(x-360./convert,Y(i,:,k),Q(i,:,k))
892fe9e2f3 Dani*0098  end
                0099  i=hnx:nx;
4cf7d6e47a Dani*0100  x=longitude(convert.*X(i,:,k))./convert;
892fe9e2f3 Dani*0101  pcolor(x,Y(i,:,k),Q(i,:,k))
4cf7d6e47a Dani*0102  if max(max(max(x)))>180./convert
                0103   pcolor(x-360./convert,Y(i,:,k),Q(i,:,k))
892fe9e2f3 Dani*0104  end
                0105 end
                0106 hold off