1 |
gforget |
1.1 |
function []=example_display(method); |
2 |
|
|
% EXAMPLE_DISPLAY(method) illustrate various options to display 2D fields. |
3 |
|
|
% |
4 |
|
|
% method (optional) selects the plotting method |
5 |
|
|
% 1: plot a gcmfaces object face by face (as in Fig. C1) of doi:10.5194/gmd-8-3071-2015). |
6 |
|
|
% 2: use convert2array via qwckplot (a quick but crude display option). |
7 |
|
|
% 3: use convert2pcol then pcolor (for a display in lat-lon coordinates). |
8 |
|
|
% 4: use the m_map_gcmfaces front end to m_map (https://www.eoas.ubc.ca/~rich/map.html). |
9 |
|
|
% 5: use gcmfaces_sphere to display fields on a sphere. |
10 |
|
|
% 6: use stretched vertical coordinate. |
11 |
|
|
% If method is not specified then it is set to [3:5] by default. |
12 |
|
|
% |
13 |
|
|
% Example: addpath gcmfaces/sample_analysis/; example_display; |
14 |
|
|
|
15 |
|
|
gcmfaces_global; |
16 |
|
|
|
17 |
|
|
input_list_check('example_display',nargin); |
18 |
|
|
|
19 |
|
|
if isempty(whos('method')); method=[3:5]; end; |
20 |
|
|
|
21 |
|
|
if myenv.verbose>0; |
22 |
|
|
gcmfaces_msg('==============================================='); |
23 |
gforget |
1.3 |
gcmfaces_msg(['*** entering example_display: displays a gridded ' ... |
24 |
|
|
'field of ocean depth (gcmfaces object) in geographic coordinates ' ... |
25 |
|
|
'using pcolor, in various projections (if m_map is in Matlab path), ' ... |
26 |
|
|
'and on a sphere.'],''); |
27 |
gforget |
1.1 |
end; |
28 |
|
|
|
29 |
|
|
%%%%%%%%%%%%%%%%% |
30 |
|
|
%load grid: |
31 |
|
|
%%%%%%%%%%%%%%%%% |
32 |
|
|
|
33 |
|
|
if isempty(mygrid); |
34 |
|
|
grid_load; |
35 |
|
|
end; |
36 |
|
|
nF=mygrid.nFaces; |
37 |
|
|
|
38 |
|
|
%%%%%%%%%%% |
39 |
|
|
%get field: |
40 |
|
|
%%%%%%%%%%% |
41 |
|
|
|
42 |
|
|
fld=mygrid.Depth; fld(fld==0)=NaN; |
43 |
|
|
cc=[[0:0.05:0.5] [0.6 0.75 1 1.25]]*1e4; myCmap='gray'; |
44 |
|
|
|
45 |
|
|
%%%%%%%%%%%% |
46 |
|
|
%plot field: |
47 |
|
|
%%%%%%%%%%%% |
48 |
|
|
|
49 |
|
|
if sum(ismember(method,1)); |
50 |
|
|
if myenv.verbose>0; gcmfaces_msg('* gcmfaces format display -- face by face.'); end; |
51 |
|
|
if nF==1; |
52 |
|
|
figureL; imagescnan(fld{1}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
53 |
|
|
elseif nF==5; |
54 |
|
|
figureL; |
55 |
|
|
subplot(3,3,7); imagescnan(fld{1}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
56 |
|
|
tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'1','FontSize',32,'Color','r','Rotation',0); |
57 |
|
|
subplot(3,3,8); imagescnan(fld{2}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
58 |
|
|
tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'2','FontSize',32,'Color','r','Rotation',0); |
59 |
|
|
subplot(3,3,5); imagescnan(fld{3}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
60 |
|
|
tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'3','FontSize',32,'Color','r','Rotation',0); |
61 |
|
|
subplot(3,3,6); imagescnan(fld{4}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
62 |
|
|
tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'4','FontSize',32,'Color','r','Rotation',0); |
63 |
|
|
subplot(3,3,3); imagescnan(fld{5}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
64 |
|
|
tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'5','FontSize',32,'Color','r','Rotation',0); |
65 |
gforget |
1.4 |
title('display face by face'); |
66 |
gforget |
1.1 |
elseif nF==6; |
67 |
|
|
error('face by face plot for cude : not yet implemented'); |
68 |
|
|
end; |
69 |
|
|
end; |
70 |
|
|
|
71 |
|
|
if sum(ismember(method,2)); |
72 |
|
|
if myenv.verbose>0; gcmfaces_msg('* array format display -- all faces concatenated.'); end; |
73 |
|
|
figureL; qwckplot(fld); cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); %delete(cb); |
74 |
gforget |
1.4 |
title('display using qwckplot'); |
75 |
gforget |
1.1 |
for ff=1:mygrid.nFaces; |
76 |
|
|
tmp0=0*mygrid.XC; |
77 |
|
|
tmp1=round(size(tmp0{ff})/2); |
78 |
|
|
tmp0{ff}(tmp1(1),tmp1(2))=1; |
79 |
|
|
tmp0=convert2array(tmp0); [ii,jj]=find(tmp0==1); |
80 |
|
|
if ff==3; ang=90; elseif ff>3; ang=-90; else; ang=0; end; |
81 |
|
|
hold on; text(ii,jj,num2str(ff),'FontSize',32,'Color','r','Rotation',ang); |
82 |
|
|
end; |
83 |
|
|
end; |
84 |
|
|
|
85 |
|
|
if sum(ismember(method,3)); |
86 |
|
|
if myenv.verbose>0; gcmfaces_msg('* geographical display -- using pcolor directly.'); end; |
87 |
|
|
figureL; |
88 |
|
|
[X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld); pcolor(X,Y,FLD); |
89 |
|
|
if ~isempty(find(X>359)); axis([0 360 -90 90]); else; axis([-180 180 -90 90]); end; |
90 |
gforget |
1.4 |
shading flat; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); |
91 |
|
|
xlabel('longitude'); ylabel('latitude'); |
92 |
|
|
title('display using convert2pcol'); |
93 |
gforget |
1.1 |
end; |
94 |
|
|
|
95 |
|
|
if sum(ismember(method,4)); |
96 |
|
|
if myenv.verbose>0; gcmfaces_msg('* geographical display -- using m_map_gcmfaces.'); end; |
97 |
|
|
if ~isempty(which('m_proj')); |
98 |
|
|
figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'myCmap',myCmap}); |
99 |
gforget |
1.4 |
aa=get(gcf,'Children'); axes(aa(4)); |
100 |
|
|
title('display using m_map_gcmfaces','Interpreter','none'); |
101 |
gforget |
1.1 |
elseif myenv.verbose; |
102 |
gforget |
1.3 |
fprintf(' > To use m_map_gcmfaces, please add m_map to your Matlab path\n'); |
103 |
gforget |
1.1 |
end; |
104 |
|
|
end; |
105 |
|
|
|
106 |
|
|
if sum(ismember(method,5)); |
107 |
|
|
if myenv.verbose>0; gcmfaces_msg('* geographical display -- on a sphere.'); end; |
108 |
|
|
figureL; gcmfaces_sphere(fld,cc,[],'N',3); |
109 |
gforget |
1.4 |
title('display using gcmfaces_sphere','Interpreter','none'); |
110 |
gforget |
1.1 |
end; |
111 |
|
|
|
112 |
|
|
%test case for depthStretchPlot: |
113 |
|
|
if sum(ismember(method,6)); |
114 |
|
|
if myenv.verbose>0; gcmfaces_msg('* section display -- using strecthed vertical coord.'); end; |
115 |
|
|
x=ones(length(mygrid.RC),1)*[1:200]; z=mygrid.RC*ones(1,200); c=sin(z/2000*pi).*cos(x/50*pi); |
116 |
|
|
figureL; |
117 |
|
|
subplot(1,2,1); set(gca,'FontSize',16); |
118 |
|
|
pcolor(x,z,c); shading flat; title('standard depth display'); |
119 |
|
|
subplot(1,2,2); set(gca,'FontSize',16); |
120 |
gforget |
1.4 |
depthStretchPlot('pcolor',{x,z,c}); shading flat; |
121 |
|
|
title('stretched depth display'); |
122 |
gforget |
1.1 |
end; |
123 |
|
|
|
124 |
|
|
if myenv.verbose>0; |
125 |
|
|
gcmfaces_msg('*** leaving example_display'); |
126 |
|
|
gcmfaces_msg('==============================================='); |
127 |
|
|
end; |
128 |
|
|
|