/[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.15 - (hide annotations) (download)
Wed Dec 3 14:21:56 2014 UTC (11 years, 11 months ago) by gforget
Branch: MAIN
Changes since 1.14: +11 -9 lines
- retire basic_diags_*.m and replace with example_transports.m
  and example_transports_disp.m using nctiles_climatology
- bring gcmfaces_demo.m and subroutines up to date.

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

  ViewVC Help
Powered by ViewVC 1.1.22