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

Contents 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.19 - (show annotations) (download)
Sun Jan 24 13:29:46 2016 UTC (10 years, 9 months ago) by gforget
Branch: MAIN
CVS Tags: HEAD
Changes since 1.18: +0 -0 lines
FILE REMOVED
- rename plot_one_field and plot_std_field as example_display and example_IO

1 function []=plot_one_field(plotMethod);
2 %object: illustrate several methods to plot fields within gcmfaces.
3 %inputs: plotMethod selects the plotting method
4 % 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 % 4) use m_map_gcmfaces front end to m_map.
9 % 5) use gcmfaces_sphere.
10 % 6) use stretched vertical coordinate.
11 %
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
19 input_list_check('plot_one_field',nargin);
20
21 if isempty(whos('plotMethod')); plotMethod=0; end;
22
23 if myenv.verbose>0;
24 gcmfaces_msg('===============================================');
25 gcmfaces_msg(['*** entering plot_one_field that displays ' ...
26 'a gridded field of ocean depth, first ' ...
27 '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 %%%%%%%%%%%%%%%%%
32 %load grid:
33 %%%%%%%%%%%%%%%%%
34
35 global mygrid;
36 if isempty(mygrid);
37 grid_load;
38 end;
39 nF=mygrid.nFaces;
40
41 %%%%%%%%%%%
42 %get field:
43 %%%%%%%%%%%
44
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
48 %%%%%%%%%%%%
49 %plot field:
50 %%%%%%%%%%%%
51
52 if plotMethod==0|plotMethod==1;
53 if myenv.verbose>0; gcmfaces_msg('* gcmfaces format display -- face by face.'); end;
54 if nF==1;
55 figureL; imagescnan(fld{1}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
56 elseif nF==5;
57 figureL;
58 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 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 if myenv.verbose>0; gcmfaces_msg('* array format display -- all faces concatenated.'); end;
75 figureL;
76 FLD=convert2array(fld);
77 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 tmp0=0*mygrid.XC;
80 tmp1=round(size(tmp0{ff})/2);
81 tmp0{ff}(tmp1(1),tmp1(2))=1;
82 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 end;
87
88 if plotMethod==0|plotMethod==3;
89 if myenv.verbose>0; gcmfaces_msg('* geographical display -- using pcolor.'); end;
90 figureL;
91 [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 shading flat; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); xlabel('longitude'); ylabel('latitude');
94 end;
95
96 if plotMethod==0|plotMethod==4;
97 if myenv.verbose>0; gcmfaces_msg('* geographical display -- using m_map.'); end;
98 if ~isempty(which('m_proj'));
99 figureL; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'myCmap',myCmap});
100 elseif myenv.verbose;
101 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 if plotMethod==0|plotMethod==5;
106 if myenv.verbose>0; gcmfaces_msg('* geographical display -- on a sphere.'); end;
107 figureL; gcmfaces_sphere(fld,cc,[],'N',3);
108 end;
109
110 %test case for depthStretchPlot:
111 if plotMethod==0|plotMethod==6;
112 if myenv.verbose>0; gcmfaces_msg('* section display -- using strecthed vertical coord.'); end;
113 x=ones(length(mygrid.RC),1)*[1:200]; z=mygrid.RC*ones(1,200); c=sin(z/2000*pi).*cos(x/50*pi);
114 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 end;
120
121 if myenv.verbose>0;
122 gcmfaces_msg('*** leaving plot_one_field');
123 gcmfaces_msg('===============================================');
124 end;
125

  ViewVC Help
Powered by ViewVC 1.1.22