1 |
function [] = merccube(XX,YY,C) |
2 |
% merccube(xg,yg,c) |
3 |
% |
4 |
% Plots cubed-sphere data in mercator projection. (xg,yg) are grid-corners |
5 |
% coordinates, c is cell-centered scalar to be plotted. |
6 |
% |
7 |
% e.g. |
8 |
% |
9 |
% xg=rdmds('XG'); |
10 |
% yg=rdmds('YG'); |
11 |
% ps=rdmds('Eta.0000000000'); |
12 |
% mercube(xg,yg,ps); |
13 |
% colorbar;xlabel('Longitude');ylabel('Latitude'); |
14 |
|
15 |
if max(max(max(YY)))-min(min(min(YY))) < 3*pi |
16 |
X=XX*180/pi; |
17 |
Y=YY*180/pi; |
18 |
else |
19 |
X=XX; |
20 |
Y=YY; |
21 |
end |
22 |
Q=C; |
23 |
|
24 |
if ndims(X)==2 & size(X,1)==6*size(X,2) |
25 |
disp('1'); |
26 |
[nx ny nt]=size(X); |
27 |
X=permute( reshape(X,[nx/6 6 ny]),[1 3 2]); |
28 |
Y=permute( reshape(Y,[nx/6 6 ny]),[1 3 2]); |
29 |
Q=permute( reshape(Q,[nx/6 6 ny]),[1 3 2]); |
30 |
elseif ndims(X)==3 & size(X,2)==6 |
31 |
X=permute( X,[1 3 2]); |
32 |
Y=permute( Y,[1 3 2]); |
33 |
Q=permute( Q,[1 3 2]); |
34 |
elseif ndims(X)==3 & size(X,3)==6 |
35 |
[nx ny nt]=size(X); |
36 |
else |
37 |
size(XX) |
38 |
size(YY) |
39 |
size(C) |
40 |
error('Dimensions should be 2 or 3 dimensions: NxNx6, 6NxN or Nx6xN'); |
41 |
end |
42 |
|
43 |
if size(X,1)==size(Q,1) |
44 |
whos |
45 |
X(end+1,:,:)=NaN; |
46 |
X(:,end+1,:)=NaN; |
47 |
X(end,:,[1 3 5])=X(1,:,[2 4 6]); |
48 |
X(:,end,[2 4 6])=X(:,1,[3 5 1]); |
49 |
X(:,end,[1 3 5])=squeeze(X(1,end:-1:1,[3 5 1])); |
50 |
X(end,:,[2 4 6])=squeeze(X(end:-1:1,1,[4 6 2])); |
51 |
Y(end+1,:,:)=NaN; |
52 |
Y(:,end+1,:)=NaN; |
53 |
Y(end,:,[1 3 5])=Y(1,:,[2 4 6]); |
54 |
Y(:,end,[2 4 6])=Y(:,1,[3 5 1]); |
55 |
Y(:,end,[1 3 5])=squeeze(Y(1,end:-1:1,[3 5 1])); |
56 |
Y(end,:,[2 4 6])=squeeze(Y(end:-1:1,1,[4 6 2])); |
57 |
end |
58 |
[nx ny nt]=size(X); |
59 |
|
60 |
Q(end+1,:,:)=0; |
61 |
Q(:,end+1,:)=0; |
62 |
Q(end,:,[1 3 5])=Q(1,:,[2 4 6]); |
63 |
Q(:,end,[2 4 6])=Q(:,1,[3 5 1]); |
64 |
Q(:,end,[1 3 5])=squeeze(Q(1,end:-1:1,[3 5 1])); |
65 |
Q(end,:,[2 4 6])=squeeze(Q(end:-1:1,1,[4 6 2])); |
66 |
|
67 |
hnx=ceil(nx/2); |
68 |
hny=ceil(ny/2); |
69 |
|
70 |
for k=1:6; |
71 |
i=1:hnx; |
72 |
x=longitude(X(i,:,k)); |
73 |
pcolor(x,Y(i,:,k),Q(i,:,k)) |
74 |
axis([-180 180 -90 90]) |
75 |
hold on |
76 |
if max(max(max(x)))>180 |
77 |
pcolor(x-360,Y(i,:,k),Q(i,:,k)) |
78 |
end |
79 |
i=hnx:nx; |
80 |
x=longitude(X(i,:,k)); |
81 |
pcolor(x,Y(i,:,k),Q(i,:,k)) |
82 |
if max(max(max(x)))>180 |
83 |
pcolor(x-360,Y(i,:,k),Q(i,:,k)) |
84 |
end |
85 |
end |
86 |
hold off |