/[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.1 - (hide annotations) (download)
Sun Jan 24 13:29:46 2016 UTC (9 years, 6 months ago) by gforget
Branch: MAIN
- rename plot_one_field and plot_std_field as example_display and example_IO

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     p = genpath('gcmfaces/'); addpath(p);
16     p = genpath('MITprof/'); addpath(p);
17    
18     gcmfaces_global;
19    
20     input_list_check('example_display',nargin);
21    
22     if isempty(whos('method')); method=[3:5]; end;
23    
24     if myenv.verbose>0;
25     gcmfaces_msg('===============================================');
26     gcmfaces_msg(['*** entering example_display that displays ' ...
27     'a gridded field of ocean depth, first ' ...
28     'in gcmfaces and array formats. Then in geographic coordinates ' ...
29     'using pcolor and in various projections using m_map (if avail. in path). '],'');
30     end;
31    
32     %%%%%%%%%%%%%%%%%
33     %load grid:
34     %%%%%%%%%%%%%%%%%
35    
36     global mygrid;
37     if isempty(mygrid);
38     grid_load;
39     end;
40     nF=mygrid.nFaces;
41    
42     %%%%%%%%%%%
43     %get field:
44     %%%%%%%%%%%
45    
46     fld=mygrid.Depth; fld(fld==0)=NaN;
47     cc=[[0:0.05:0.5] [0.6 0.75 1 1.25]]*1e4; myCmap='gray';
48    
49     %%%%%%%%%%%%
50     %plot field:
51     %%%%%%%%%%%%
52    
53     if sum(ismember(method,1));
54     if myenv.verbose>0; gcmfaces_msg('* gcmfaces format display -- face by face.'); end;
55     if nF==1;
56     figureL; imagescnan(fld{1}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
57     elseif nF==5;
58     figureL;
59     subplot(3,3,7); imagescnan(fld{1}','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,'1','FontSize',32,'Color','r','Rotation',0);
61     subplot(3,3,8); imagescnan(fld{2}','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,'2','FontSize',32,'Color','r','Rotation',0);
63     subplot(3,3,5); imagescnan(fld{3}','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,'3','FontSize',32,'Color','r','Rotation',0);
65     subplot(3,3,6); imagescnan(fld{4}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
66     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'4','FontSize',32,'Color','r','Rotation',0);
67     subplot(3,3,3); imagescnan(fld{5}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
68     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'5','FontSize',32,'Color','r','Rotation',0);
69     elseif nF==6;
70     error('face by face plot for cude : not yet implemented');
71     end;
72     end;
73    
74     if sum(ismember(method,2));
75     if myenv.verbose>0; gcmfaces_msg('* array format display -- all faces concatenated.'); end;
76     figureL; qwckplot(fld); cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); %delete(cb);
77     for ff=1:mygrid.nFaces;
78     tmp0=0*mygrid.XC;
79     tmp1=round(size(tmp0{ff})/2);
80     tmp0{ff}(tmp1(1),tmp1(2))=1;
81     tmp0=convert2array(tmp0); [ii,jj]=find(tmp0==1);
82     if ff==3; ang=90; elseif ff>3; ang=-90; else; ang=0; end;
83     hold on; text(ii,jj,num2str(ff),'FontSize',32,'Color','r','Rotation',ang);
84     end;
85     end;
86    
87     if sum(ismember(method,3));
88     if myenv.verbose>0; gcmfaces_msg('* geographical display -- using pcolor directly.'); end;
89     figureL;
90     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld); pcolor(X,Y,FLD);
91     if ~isempty(find(X>359)); axis([0 360 -90 90]); else; axis([-180 180 -90 90]); end;
92     shading flat; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); xlabel('longitude'); ylabel('latitude');
93     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     elseif myenv.verbose;
100     fprintf('if you want to use m_map_gcmfaces, you will need to have m_map in your path\n');
101     end;
102     end;
103    
104     if sum(ismember(method,5));
105     if myenv.verbose>0; gcmfaces_msg('* geographical display -- on a sphere.'); end;
106     figureL; gcmfaces_sphere(fld,cc,[],'N',3);
107     end;
108    
109     %test case for depthStretchPlot:
110     if sum(ismember(method,6));
111     if myenv.verbose>0; gcmfaces_msg('* section display -- using strecthed vertical coord.'); end;
112     x=ones(length(mygrid.RC),1)*[1:200]; z=mygrid.RC*ones(1,200); c=sin(z/2000*pi).*cos(x/50*pi);
113     figureL;
114     subplot(1,2,1); set(gca,'FontSize',16);
115     pcolor(x,z,c); shading flat; title('standard depth display');
116     subplot(1,2,2); set(gca,'FontSize',16);
117     depthStretchPlot('pcolor',{x,z,c}); shading flat; title('stretched depth display');
118     end;
119    
120     if myenv.verbose>0;
121     gcmfaces_msg('*** leaving example_display');
122     gcmfaces_msg('===============================================');
123     end;
124    

  ViewVC Help
Powered by ViewVC 1.1.22