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

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

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


Revision 1.17 - (hide annotations) (download)
Mon Jan 11 17:29:58 2016 UTC (10 years, 10 months ago) by gforget
Branch: MAIN
Changes since 1.16: +14 -13 lines
- revise handing of path, grid and input files, warnings and messages:

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

  ViewVC Help
Powered by ViewVC 1.1.22