/[MITgcm]/MITgcm_contrib/gael/matlab_class/sample_analysis/example_display.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/sample_analysis/example_display.m

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


Revision 1.2 - (hide annotations) (download)
Sun Jan 24 16:25:51 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
Changes since 1.1: +0 -4 lines
- gcmfaces_demo.m: improve help section, add comments wrt gcmfaces_global etc
- example*.m: homogeneize treatment of mygrid (don't reload if not needed)
  and path (use just gcmfaces_global)

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     gcmfaces_msg(['*** entering example_display that displays ' ...
24     'a gridded field of ocean depth, first ' ...
25     'in gcmfaces and array formats. Then in geographic coordinates ' ...
26     'using pcolor and in various projections using m_map (if avail. in path). '],'');
27     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     elseif nF==6;
66     error('face by face plot for cude : not yet implemented');
67     end;
68     end;
69    
70     if sum(ismember(method,2));
71     if myenv.verbose>0; gcmfaces_msg('* array format display -- all faces concatenated.'); end;
72     figureL; qwckplot(fld); cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); %delete(cb);
73     for ff=1:mygrid.nFaces;
74     tmp0=0*mygrid.XC;
75     tmp1=round(size(tmp0{ff})/2);
76     tmp0{ff}(tmp1(1),tmp1(2))=1;
77     tmp0=convert2array(tmp0); [ii,jj]=find(tmp0==1);
78     if ff==3; ang=90; elseif ff>3; ang=-90; else; ang=0; end;
79     hold on; text(ii,jj,num2str(ff),'FontSize',32,'Color','r','Rotation',ang);
80     end;
81     end;
82    
83     if sum(ismember(method,3));
84     if myenv.verbose>0; gcmfaces_msg('* geographical display -- using pcolor directly.'); end;
85     figureL;
86     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld); pcolor(X,Y,FLD);
87     if ~isempty(find(X>359)); axis([0 360 -90 90]); else; axis([-180 180 -90 90]); end;
88     shading flat; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); xlabel('longitude'); ylabel('latitude');
89     end;
90    
91     if sum(ismember(method,4));
92     if myenv.verbose>0; gcmfaces_msg('* geographical display -- using m_map_gcmfaces.'); end;
93     if ~isempty(which('m_proj'));
94     figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'myCmap',myCmap});
95     elseif myenv.verbose;
96     fprintf('if you want to use m_map_gcmfaces, you will need to have m_map in your path\n');
97     end;
98     end;
99    
100     if sum(ismember(method,5));
101     if myenv.verbose>0; gcmfaces_msg('* geographical display -- on a sphere.'); end;
102     figureL; gcmfaces_sphere(fld,cc,[],'N',3);
103     end;
104    
105     %test case for depthStretchPlot:
106     if sum(ismember(method,6));
107     if myenv.verbose>0; gcmfaces_msg('* section display -- using strecthed vertical coord.'); end;
108     x=ones(length(mygrid.RC),1)*[1:200]; z=mygrid.RC*ones(1,200); c=sin(z/2000*pi).*cos(x/50*pi);
109     figureL;
110     subplot(1,2,1); set(gca,'FontSize',16);
111     pcolor(x,z,c); shading flat; title('standard depth display');
112     subplot(1,2,2); set(gca,'FontSize',16);
113     depthStretchPlot('pcolor',{x,z,c}); shading flat; title('stretched depth display');
114     end;
115    
116     if myenv.verbose>0;
117     gcmfaces_msg('*** leaving example_display');
118     gcmfaces_msg('===============================================');
119     end;
120    

  ViewVC Help
Powered by ViewVC 1.1.22