/[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.12 - (hide annotations) (download)
Fri Aug 5 22:01:50 2011 UTC (15 years, 3 months ago) by gforget
Branch: MAIN
Changes since 1.11: +28 -18 lines
- replace gcmfaces_path and 'global mygrid' calls with gcmfaces_global calls
- replace plot of temperature with bathymetry in plot_one_field.m

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     %%%%%%%%%%%%%%%%%
14     %load parameters:
15     %%%%%%%%%%%%%%%%%
16 gforget 1.12 gcmfaces_global;
17     dir0=[myenv.gcmfaces_dir '/sample_input/'];
18 gforget 1.9 dirGrid=[dir0 '/GRID' choiceV3orV4 '/'];
19     dirIn=[dir0 '/SAMPLE' choiceV3orV4 '/'];
20     if strcmp(choiceV3orV4,'v4'); nF=5; fileFormat='compact'; else; nF=1; fileFormat='straight'; end;
21 gforget 1.12 mygrid=[]; grid_load(dirGrid,nF,fileFormat);
22 gforget 1.1
23     %%%%%%%%%%%
24     %get field:
25     %%%%%%%%%%%
26 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';
27 gforget 1.9
28 gforget 1.1 %%%%%%%%%%%%
29     %plot field:
30     %%%%%%%%%%%%
31 gforget 1.9
32     if plotMethod==0|plotMethod==1;
33     if nF==1;
34 gforget 1.12 figure; imagescnan(fld{1}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
35 gforget 1.9 elseif nF==5;
36     figure;
37 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);
38     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'1','FontSize',32,'Color','r','Rotation',0);
39     subplot(3,3,8); imagescnan(fld{2}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
40     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'2','FontSize',32,'Color','r','Rotation',0);
41     subplot(3,3,5); imagescnan(fld{3}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
42     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'3','FontSize',32,'Color','r','Rotation',0);
43     subplot(3,3,6); imagescnan(fld{4}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
44     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'4','FontSize',32,'Color','r','Rotation',0);
45     subplot(3,3,3); imagescnan(fld{5}','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb);
46     tmp1=axis; tmp2=text(tmp1(2)/2,tmp1(4)/2,'5','FontSize',32,'Color','r','Rotation',0);
47 gforget 1.9 elseif nF==6;
48     error('face by face plot for cude : not yet implemented');
49     end;
50     end;
51    
52     if plotMethod==0|plotMethod==2;
53     figure;
54     FLD=convert2array(fld);
55 gforget 1.12 imagescnan(FLD','nancolor',[1 1 1]*0.8); axis xy; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); %delete(cb);
56     for ff=1:mygrid.nFaces;
57     tmp0=0*mygrid.XC;
58     tmp1=round(size(tmp0{ff})/2);
59     tmp0{ff}(tmp1(1),tmp1(2))=1;
60     tmp0=convert2array(tmp0); [ii,jj]=find(tmp0==1);
61     if ff==3; ang=90; elseif ff>3; ang=-90; else; ang=0; end;
62     hold on; text(ii,jj,num2str(ff),'FontSize',32,'Color','r','Rotation',ang);
63     end;
64 gforget 1.9 end;
65    
66     if plotMethod==0|plotMethod==3;
67     figure;
68     [X,Y,FLD]=convert2pcol(mygrid.XC,mygrid.YC,fld); pcolor(X,Y,FLD);
69     if ~isempty(find(X>359)); axis([0 360 -90 90]); else; axis([-180 180 -90 90]); end;
70 gforget 1.12 shading flat; cb=gcmfaces_cmap_cbar(cc,{'myCmap',myCmap}); delete(cb); xlabel('longitude'); ylabel('latitude');
71 gforget 1.2 end;
72 gforget 1.1
73 gforget 1.9 if plotMethod==0|plotMethod==4;
74     if ~isempty(which('m_proj'));
75 gforget 1.12 figure; m_map_gcmfaces(fld,0,{'myCaxis',cc},{'myCmap',myCmap});
76     elseif myenv.verbose;
77 gforget 1.9 fprintf('if you want to use m_map_gcmfaces, you will need to have m_map in your path\n');
78     end;
79     end;
80    
81 gforget 1.11 %test case for depthStretchPlot:
82     if plotMethod==0|plotMethod==5;
83 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);
84 gforget 1.11 figure;
85     subplot(1,2,1); pcolor(x,z,c); shading flat; title('standard depth display');
86     subplot(1,2,2); depthStretchPlot('pcolor',{x,z,c}); shading flat; title('stretched depth display');
87     % subplot(1,2,1); plot(c(:,1),z(:,1)); title('standard depth display');
88     % subplot(1,2,2); depthStretchPlot('plot',{c(:,1),z(:,1)}); title('stretched depth display');
89     end;
90    
91 gforget 1.9

  ViewVC Help
Powered by ViewVC 1.1.22