/[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.13 - (hide annotations) (download)
Thu Oct 20 21:01:10 2011 UTC (15 years ago) by gforget
Branch: MAIN
Changes since 1.12: +18 -1 lines
- add calls to gcmfaces_msg for verbose>0 mode (demo/tutorial mode).
- change tabs.

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.12 dir0=[myenv.gcmfaces_dir '/sample_input/'];
26 gforget 1.9 dirGrid=[dir0 '/GRID' choiceV3orV4 '/'];
27     dirIn=[dir0 '/SAMPLE' choiceV3orV4 '/'];
28     if strcmp(choiceV3orV4,'v4'); nF=5; fileFormat='compact'; else; nF=1; fileFormat='straight'; end;
29 gforget 1.12 mygrid=[]; grid_load(dirGrid,nF,fileFormat);
30 gforget 1.1
31     %%%%%%%%%%%
32     %get field:
33     %%%%%%%%%%%
34 gforget 1.12 fld=mygrid.mskC(:,:,1).*mygrid.Depth; cc=[[0:0.05:0.5] [0.6 0.75 1 1.25]]*1e4; myCmap='gray';
35 gforget 1.9
36 gforget 1.1 %%%%%%%%%%%%
37     %plot field:
38     %%%%%%%%%%%%
39 gforget 1.9
40     if plotMethod==0|plotMethod==1;
41 gforget 1.13 if myenv.verbose>0; gcmfaces_msg('* gcmfaces format display -- face by face.'); end;
42 gforget 1.9 if nF==1;
43 gforget 1.12 figure; imagescnan(fld{1}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
44 gforget 1.9 elseif nF==5;
45     figure;
46 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);
47     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'1','FontSize',32,'Color','r','Rotation',0);
48     subplot(3,3,8); imagescnan(fld{2}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
49     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'2','FontSize',32,'Color','r','Rotation',0);
50     subplot(3,3,5); imagescnan(fld{3}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
51     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'3','FontSize',32,'Color','r','Rotation',0);
52     subplot(3,3,6); imagescnan(fld{4}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
53     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'4','FontSize',32,'Color','r','Rotation',0);
54     subplot(3,3,3); imagescnan(fld{5}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
55     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'5','FontSize',32,'Color','r','Rotation',0);
56 gforget 1.9 elseif nF==6;
57     error('face by face plot for cude : not yet implemented');
58     end;
59     end;
60    
61     if plotMethod==0|plotMethod==2;
62 gforget 1.13 if myenv.verbose>0; gcmfaces_msg('* array format display -- all faces concatenated somehow.'); end;
63 gforget 1.9 figure;
64     FLD=convert2array(fld);
65 gforget 1.12 imagescnan(FLD','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); %delete(cb);
66     for ff=1:mygrid.nFaces;
67     tmp0=0*mygrid.XC;
68     tmp1=round(size(tmp0{ff})/2);
69     tmp0{ff}(tmp1(1),tmp1(2))=1;
70     tmp0=convert2array(tmp0); [ii,jj]=find(tmp0==1);
71     if ff==3; ang=90; elseif ff>3; ang=-90; else; ang=0; end;
72     hold on; text(ii,jj,num2str(ff),'FontSize',32,'Color','r','Rotation',ang);
73     end;
74 gforget 1.9 end;
75    
76     if plotMethod==0|plotMethod==3;
77 gforget 1.13 if myenv.verbose>0; gcmfaces_msg('* geographical display -- using pcolor.'); end;
78 gforget 1.9 figure;
79     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld); pcolor(X,Y,FLD);
80     if ~isempty(find(X>359)); axis([0 360 -90 90]); else; axis([-180 180 -90 90]); end;
81 gforget 1.12 shading flat; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); xlabel('longitude'); ylabel('latitude');
82 gforget 1.2 end;
83 gforget 1.1
84 gforget 1.9 if plotMethod==0|plotMethod==4;
85 gforget 1.13 if myenv.verbose>0; gcmfaces_msg('* geographical display -- using m_map.'); end;
86 gforget 1.9 if ~isempty(which('m_proj'));
87 gforget 1.12 figure; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'myCmap',myCmap});
88     elseif myenv.verbose;
89 gforget 1.9 fprintf('if you want to use m_map_gcmfaces, you will need to have m_map in your path\n');
90     end;
91     end;
92    
93 gforget 1.11 %test case for depthStretchPlot:
94     if plotMethod==0|plotMethod==5;
95 gforget 1.13 if myenv.verbose>0; gcmfaces_msg('* section display -- using strecthed vertical coord.'); end;
96 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);
97 gforget 1.11 figure;
98     subplot(1,2,1); pcolor(x,z,c); shading flat; title('standard depth display');
99     subplot(1,2,2); depthStretchPlot('pcolor',{x,z,c}); shading flat; title('stretched depth display');
100     % subplot(1,2,1); plot(c(:,1),z(:,1)); title('standard depth display');
101     % subplot(1,2,2); depthStretchPlot('plot',{c(:,1),z(:,1)}); title('stretched depth display');
102     end;
103    
104 gforget 1.13 if myenv.verbose>0;
105     gcmfaces_msg('*** leaving plot_one_field');
106     gcmfaces_msg('===============================================');
107     end;
108 gforget 1.9

  ViewVC Help
Powered by ViewVC 1.1.22