/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_maps/gcmfaces_sphere.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_maps/gcmfaces_sphere.m

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


Revision 1.3 - (hide annotations) (download)
Sun Jan 24 13:32:02 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65v, checkpoint65t, checkpoint65u
Changes since 1.2: +1 -1 lines
- omit re-positioning of colorbar

1 gforget 1.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 gforget 1.2 %
9     %Example:
10     % mask=mygrid.mskC(:,:,1);
11     % bathy=mygrid.Depth;
12     % figure; gcmfaces_sphere(mask.*bathy);
13 gforget 1.1
14     gcmfaces_global;
15    
16 gforget 1.2 if isempty(who('cc')); cc=[]; end;
17 gforget 1.1 if isempty(who('nn')); nn=[]; end;
18     if isempty(who('vw')); vw=[]; end;
19 gforget 1.2 if isempty(who('co')); co=1; end;
20 gforget 1.1
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 gforget 1.2
37     %color scheme:
38 gforget 1.1 if co==1;
39     listCol='kkkkkk';
40 gforget 1.2 bw=0;
41     mm='jet';
42 gforget 1.1 elseif co==2;
43     listCol='bbbbbb';
44 gforget 1.2 bw=-2;
45     mm='hot';
46 gforget 1.1 elseif co==3;
47     listCol='gmbcrk'; if mygrid.nFaces==4; listCol='rgmc'; end;
48     %%listCol='rkbcmg'; if mygrid.nFaces==4; listCol='mrkc'; end;
49 gforget 1.2 bw=-2;
50     mm='gray';
51 gforget 1.1 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 gforget 1.2 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 gforget 1.1 end;
82     %
83 gforget 1.3 %set(cb,'Position',[0.78 0.2 0.02 0.6]);
84 gforget 1.1 %delete(cb);
85    
86     if ~isempty(nn);
87     XG=exch_Z(mygrid.XG); YG=exch_Z(mygrid.YG);
88     %now do the plot:
89     for ii=1:mygrid.nFaces;
90     x=myfac*sin(pi/2-YG{ii}*pi/180).*cos(XG{ii}*pi/180);
91     y=myfac*sin(pi/2-YG{ii}*pi/180).*sin(XG{ii}*pi/180);
92     z=myfac*cos(pi/2-YG{ii}*pi/180);
93     [n1,n2]=size(x); i1=[1:nn:n1]; i2=[1:nn:n2];
94     mesh(x(i1,i2),y(i1,i2),z(i1,i2),0*x(i1,i2),'FaceColor','none','EdgeColor',listCol(ii)); hold on;
95     end;
96     end;
97    
98     %find tune plot:
99     axis equal; axis off;
100     %set(gca,'XTick',[],'YTick',[],'ZTick',[]);
101     %set(gca,'Color','none');
102     %set(gcf,'Renderer','zbuffer');
103     %box on;
104    
105    

  ViewVC Help
Powered by ViewVC 1.1.22