1 |
function []=gcmfaces_sphere(fld,cc,nn,vw,co); |
2 |
%object: display field and grid mesh on the sphere |
3 |
%inputs: fld is the field to be plotted |
4 |
% cc is the color range(s) |
5 |
% nn subsampling rate for grid lines ([] for no grid lines) |
6 |
% vw is either [],{az,elev},'N','S' |
7 |
% co color scheme option (1,2, or 3) |
8 |
% |
9 |
%Example: |
10 |
% mask=mygrid.mskC(:,:,1); |
11 |
% bathy=mygrid.Depth; |
12 |
% figure; gcmfaces_sphere(mask.*bathy); |
13 |
|
14 |
gcmfaces_global; |
15 |
|
16 |
if isempty(who('cc')); cc=[]; end; |
17 |
if isempty(who('nn')); nn=[]; end; |
18 |
if isempty(who('vw')); vw=[]; end; |
19 |
if isempty(who('co')); co=1; end; |
20 |
|
21 |
if iscell(vw); |
22 |
az=vw{1}; elev=vw{2}; |
23 |
elseif isempty(vw); |
24 |
az=0; elev=20; |
25 |
elseif strcmp(vw,'N'); |
26 |
az=0; elev=90; |
27 |
elseif strcmp(vw,'S'); |
28 |
az=0; elev=-90; |
29 |
end; |
30 |
|
31 |
%overlay the mesh: |
32 |
if ~isempty(nn); |
33 |
myfac=1.001; |
34 |
elev=myfac*elev; |
35 |
end; |
36 |
|
37 |
%color scheme: |
38 |
if co==1; |
39 |
listCol='kkkkkk'; |
40 |
bw=0; |
41 |
mm='jet'; |
42 |
elseif co==2; |
43 |
listCol='bbbbbb'; |
44 |
bw=-2; |
45 |
mm='hot'; |
46 |
elseif co==3; |
47 |
listCol='gmbcrk'; if mygrid.nFaces==4; listCol='rgmc'; end; |
48 |
%%listCol='rkbcmg'; if mygrid.nFaces==4; listCol='mrkc'; end; |
49 |
bw=-2; |
50 |
mm='gray'; |
51 |
end; |
52 |
|
53 |
%underlay plain sphere: |
54 |
[xs,ys,zs]=sphere(100); aa=0.99; |
55 |
aa=surf(aa*xs,aa*ys,aa*zs); hold on; |
56 |
set(aa,'LineStyle','none','FaceColor',[1 1 1]*0.7); |
57 |
|
58 |
%plot bathy: |
59 |
test1=1; test2=0; |
60 |
XC=exch_T_N(mygrid.XC); YC=exch_T_N(mygrid.YC); |
61 |
FLD=exch_T_N(fld); |
62 |
for ii=1:mygrid.nFaces; |
63 |
x=sin(pi/2-YC{ii}*pi/180).*cos(XC{ii}*pi/180); |
64 |
y=sin(pi/2-YC{ii}*pi/180).*sin(XC{ii}*pi/180); |
65 |
z=cos(pi/2-YC{ii}*pi/180); |
66 |
c=FLD{ii}; |
67 |
%subsampling |
68 |
k0=1; i0=1:k0:size(x,1); j0=1:k0:size(x,2); |
69 |
surf(x(i0,j0),y(i0,j0),z(i0,j0),c(i0,j0),'LineStyle','none'); hold on; |
70 |
test1=nanmin([test1;c(:)]); test2=nanmax([test2;c(:)]); |
71 |
end;%for ii=1:mygrid.nFaces; |
72 |
axis equal; |
73 |
view(az,elev); |
74 |
% |
75 |
if length(cc)==0; |
76 |
cb=colorbar; colormap(mm); |
77 |
elseif length(cc)==2; |
78 |
cb=colorbar; caxis(cc); colormap(mm); |
79 |
elseif length(cc)>2; |
80 |
cb=gcmfaces_cmap_cbar(cc,{'myBW',bw},{'myCmap',mm}); |
81 |
end; |
82 |
% |
83 |
%set(cb,'Position',[0.78 0.2 0.02 0.6]); |
84 |
%delete(cb); |
85 |
|
86 |
if ~isempty(nn); |
87 |
if mygrid.nFaces~=4; |
88 |
XG=exch_Z(mygrid.XG); YG=exch_Z(mygrid.YG); |
89 |
else; |
90 |
%replace XG,YG with XC,YC since exch_Z_llpc is lacking |
91 |
XG=exch_T_N(mygrid.XC); YG=exch_T_N(mygrid.YC); |
92 |
end; |
93 |
%now do the plot: |
94 |
for ii=1:mygrid.nFaces; |
95 |
x=myfac*sin(pi/2-YG{ii}*pi/180).*cos(XG{ii}*pi/180); |
96 |
y=myfac*sin(pi/2-YG{ii}*pi/180).*sin(XG{ii}*pi/180); |
97 |
z=myfac*cos(pi/2-YG{ii}*pi/180); |
98 |
[n1,n2]=size(x); i1=[1:nn:n1]; i2=[1:nn:n2]; |
99 |
mesh(x(i1,i2),y(i1,i2),z(i1,i2),0*x(i1,i2),'FaceColor','none','EdgeColor',listCol(ii)); hold on; |
100 |
end; |
101 |
end; |
102 |
|
103 |
%find tune plot: |
104 |
axis equal; axis off; |
105 |
%set(gca,'XTick',[],'YTick',[],'ZTick',[]); |
106 |
%set(gca,'Color','none'); |
107 |
%set(gcf,'Renderer','zbuffer'); |
108 |
%box on; |
109 |
|
110 |
|