/[MITgcm]/MITgcm_contrib/gael/matlab_class/gcmfaces_maps/m_map_gcmfaces.m
ViewVC logotype

Annotation of /MITgcm_contrib/gael/matlab_class/gcmfaces_maps/m_map_gcmfaces.m

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


Revision 1.14 - (hide annotations) (download)
Fri Feb 5 13:02:46 2016 UTC (9 years, 5 months ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65x, checkpoint65v, checkpoint65w, checkpoint65t, checkpoint65u, checkpoint66a
Changes since 1.13: +7 -6 lines
- add choicePlot==1.2 in m_map_gcmfaces.m
- revise treatment of colorbar positions and labels

1 gforget 1.1 function []=m_map_gcmfaces(fld,varargin);
2 gforget 1.3 %object: gcmfaces front end to m_map
3 gforget 1.7 %inputs: fld is the 2D field to be mapped, or a cell (see below).
4 gforget 1.4 %optional: proj is either the index (integer; 0 by default) of pre-defined
5     % projection(s) or parameters to pass to m_proj (cell)
6 gforget 1.7 %more so: other optional paramaters can be provided ONLY AFTER proj,
7 gforget 1.4 % and must take the following form {'name',param1,param2,...}
8 gforget 1.6 % those that are currently active are
9 gforget 1.4 % {'myCaxis',myCaxis} is the color axis ('auto' by default)
10     % {'do_m_coast',do_m_coast} adds call to m_coast (1; default) or not (0).
11 gforget 1.6 % {'myCmap',myCmap} is the colormap name ('jet' by default)
12 gforget 1.7 % {'doHold',1} indicates to 'hold on' and superimpose e.g. a contour
13 gforget 1.8 % {'doCbar',1} indicates to include the colorbar (1 by default)
14     % {'doLabl',1} indicates to include the axes labels (1 by default)
15     % {'doFit',1} indicates to exclude white space (0 by default)
16 gforget 1.9 % {'myShading','flat'} indicates to use flat shading instead of interp
17 gforget 1.3 %
18 gforget 1.4 %notes: - for proj==0 (i.e. the default) three panels will be plotted :
19     % a mercator projection over mid-latitude, and two polar
20 gforget 1.7 % stereographic projections. The other predefined proj are
21 gforget 1.3 % -1 mollweide or cylindrical projection
22     % 1 mercator projection only
23     % 2 arctic stereographic projection only
24     % 3 antarctic stereographic projection only
25 gforget 1.7 % 1.1 and 1.2 are atlantic mercator projections
26 gforget 1.4 % - myTitle is currently not used; it will take the form
27     % {'myTitle',myTitle} is the title (none by default)
28 gforget 1.7 % - myCaxis can be specified with more than 2 values, in which
29 gforget 1.8 % case gcmfaces_cb will be used.
30 gforget 1.7 % - if fld is a 2D field we use pcolor to display it
31     % - if fld is a cell one can specify the plotting tool.
32     % The cell must then have the form {plotType,FLD,varargin}
33 gforget 1.8 % where plotType is e.g. 'pcolor' or 'contour', FLD is
34     % the 2D field to be plotted, and varargin are options
35 gforget 1.7 % to pass over to the contour command.
36 gforget 1.8 % - Hence .e.g. fld={'contour',mygrid.Depth,'r'} will draw
37 gforget 1.7 % red contours, while fld=mygrid.Depth will color shade.
38 gforget 1.1
39 gforget 1.2 %check that m_map is in the path
40     aa=which('m_proj'); if isempty(aa); error('this function requires m_map that is missing'); end;
41    
42 gforget 1.1 global mygrid;
43    
44 gforget 1.4 %get optional parameters
45     if nargin>1; proj=varargin{1}; else; proj=0; end;
46 gforget 1.7 if iscell(proj);
47     error('not yet implemented');
48 gforget 1.4 else;
49     choicePlot=proj;
50     end;
51 gforget 1.7 %determine the type of plot
52     if iscell(fld); myPlot=fld{1}; else; myPlot='pcolor'; fld={'pcolor',fld}; end;
53 gforget 1.4 %set more optional paramaters to default values
54 gforget 1.10 myCaxis=[]; myTitle=''; myShading='interp'; myCmap='jet';
55 gforget 1.9 do_m_coast=1; doHold=0; doCbar=1; doLabl=1; doFit=0;
56 gforget 1.4 %set more optional paramaters to user defined values
57     for ii=2:nargin-1;
58     if ~iscell(varargin{ii});
59     warning('inputCheck:m_map_gcmfaces_1',...
60     ['As of june 2011, m_map_gcmfaces expects \n'...
61     ' its optional parameters as cell arrays. \n'...
62     ' Argument no. ' num2str(ii+1) ' was ignored \n'...
63     ' Type ''help m_map_gcmfaces'' for details.']);
64     elseif ~ischar(varargin{ii}{1});
65     warning('inputCheck:m_map_gcmfaces_2',...
66     ['As of june 2011, m_map_gcmfaces expects \n'...
67     ' its optional parameters cell arrays \n'...
68     ' to start with character string. \n'...
69     ' Argument no. ' num2str(ii+1) ' was ignored \n'...
70     ' Type ''help m_map_gcmfaces'' for details.']);
71     else;
72     if strcmp(varargin{ii}{1},'myCaxis')|...
73 gforget 1.6 strcmp(varargin{ii}{1},'myCmap')|...
74 gforget 1.9 strcmp(varargin{ii}{1},'myShading')|...
75     strcmp(varargin{ii}{1},'myTitle')|...
76 gforget 1.7 strcmp(varargin{ii}{1},'doHold')|...
77 gforget 1.8 strcmp(varargin{ii}{1},'doCbar')|...
78     strcmp(varargin{ii}{1},'doLabl')|...
79     strcmp(varargin{ii}{1},'doFit')|...
80 gforget 1.9 strcmp(varargin{ii}{1},'do_m_coast');
81 gforget 1.4 eval([varargin{ii}{1} '=varargin{ii}{2};']);
82     else;
83     warning('inputCheck:m_map_gcmfaces_3',...
84     ['unknown option ''' varargin{ii}{1} ''' was ignored']);
85     end;
86     end;
87     end;
88 gforget 1.7
89 gforget 1.4 %make parameter inferences
90 gforget 1.7 if length(myCaxis)==0;
91     plotCBAR=0;
92     elseif length(myCaxis)==2;
93     plotCBAR=1;
94     else;
95     plotCBAR=2;
96     end;
97     %
98     if choicePlot==0&~doHold;
99     clf;
100     elseif ~doHold;
101     cla;
102     else;
103     hold on;
104     end;
105    
106     %re-group param:
107     param.plotCBAR=plotCBAR;
108     param.myCmap=myCmap;
109     param.myCaxis=myCaxis;
110     param.do_m_coast=do_m_coast;
111     param.doHold=doHold;
112 gforget 1.8 param.doCbar=doCbar;
113     param.doLabl=doLabl;
114     param.doFit=doFit;
115 gforget 1.7 param.myPlot=myPlot;
116    
117     %do the plotting:
118     if (choicePlot~=0&choicePlot~=1&choicePlot~=2&choicePlot~=3);
119 gforget 1.9 do_my_plot(fld,param,choicePlot,myShading);
120 gforget 1.7 end;%if choicePlot==0|choicePlot==1;
121 gforget 1.1
122     if choicePlot==0; subplot(2,1,1); end;
123 gforget 1.7 if choicePlot==0|choicePlot==1;
124 gforget 1.8 if mygrid.nFaces~=5&mygrid.nFaces~=6;
125 gforget 1.9 do_my_plot(fld,param,1,myShading);
126 gforget 1.8 else;
127 gforget 1.9 do_my_plot(fld,param,1.1,myShading);
128 gforget 1.8 end;
129 gforget 1.7 end;%if choicePlot==0|choicePlot==1;
130 gforget 1.3
131 gforget 1.1 if choicePlot==0; subplot(2,2,3); end;
132 gforget 1.7 if choicePlot==0|choicePlot==2;
133 gforget 1.9 do_my_plot(fld,param,2,myShading);
134 gforget 1.7 end;%if choicePlot==0|choicePlot==1;
135 gforget 1.1
136     if choicePlot==0; subplot(2,2,4); end;
137 gforget 1.7 if choicePlot==0|choicePlot==3;
138 gforget 1.9 do_my_plot(fld,param,3,myShading);
139 gforget 1.7 end;%if choicePlot==0|choicePlot==1;
140 gforget 1.1
141 gforget 1.8 if plotCBAR==2&strcmp(myPlot,'pcolor')&doCbar;
142 gforget 1.6 cbar=gcmfaces_cmap_cbar(myCaxis,{'myCmap',myCmap});
143 gforget 1.7 if choicePlot==0;
144 gforget 1.14 set(cbar,'Position',[0.88 0.15 0.02 0.75]);
145 gforget 1.3 elseif choicePlot==-1;
146 gforget 1.14 set(cbar,'Position',[0.88 0.35 0.02 0.3]);
147 gforget 1.7 elseif choicePlot==1;
148 gforget 1.14 set(cbar,'Position',[0.88 0.34 0.02 0.35]);
149     elseif choicePlot==1.2;
150     set(cbar,'Position',[0.88 0.34 0.02 0.35]);
151     else;
152     set(cbar,'Position',[0.88 0.3 0.02 0.4]);
153 gforget 1.7 end;
154     end;
155    
156 gforget 1.8 if doFit;
157     if doLabl&~doCbar;
158     set(gca,'LooseInset',[0.05 0.02 0.03 0.03]);
159     else;
160     set(gca,'LooseInset',[0.01 0 0.03 0.03]);
161     end;
162     tmp1=get(gca,'PlotBoxAspectRatio');
163     set(gcf,'PaperPosition',[0 4 8 8/tmp1(1)]);
164     end;
165 gforget 1.7
166 gforget 1.9 function []=do_my_plot(fld,param,proj,shad);
167 gforget 1.7
168     gcmfaces_global;
169    
170 gforget 1.8 %default m_grid params:
171     xloc='bottom'; xtic=[-180:60:180]; xticlab=1;
172     yloc='left'; ytic=[-60:30:60]; yticlab=1;
173    
174     %choice of projection:
175 gforget 1.7 if proj==-1;
176     %%m_proj('Miller Cylindrical','lat',[-90 90]);
177     %m_proj('Equidistant cylindrical','lat',[-90 90]);
178     %m_proj('mollweide','lon',[-180 180],'lat',[-80 80]);
179     m_proj('mollweide','lon',[-180 180],'lat',[-88 88]);
180 gforget 1.8 myConv='pcol'; xticlab=0; yticlab=0;
181 gforget 1.7 elseif proj==1;
182     m_proj('Mercator','lat',[-70 70]);
183 gforget 1.8 myConv='pcol';
184     elseif proj==1.1;
185     m_proj('Mercator','lat',[-70 70],'lon',[0 360]+20);
186     myConv='pcol';
187     xtic=[-360:60:360]; ytic=[-60:30:60];
188 gforget 1.11 elseif proj==1.2;
189     m_proj('Equidistant cylindrical','lat',[-90 90],'lon',[0 360]+20);
190     myConv='pcol';
191     xtic=[-360:60:360]; ytic=[-90:30:90];
192     elseif proj==1.3;
193     m_proj('Equidistant cylindrical','lat',[15 30],'lon',[190 210]);
194     myConv='pcol';
195     xtic=[190:5:220]; ytic=[15:3:30];
196 gforget 1.7 elseif proj==2;
197     m_proj('Stereographic','lon',0,'lat',90,'rad',40);
198 gforget 1.8 myConv='convert2arctic';
199     yloc='bottom'; ytic=[50:10:90];
200     elseif proj==2.1;
201     m_proj('Stereographic','lon',0,'lat',90,'rad',60);
202     myConv='convert2arctic';
203     yloc='bottom'; ytic=[30:10:90];
204 gforget 1.7 elseif proj==3;
205     m_proj('Stereographic','lon',0,'lat',-90,'rad',40);
206 gforget 1.8 myConv='convert2southern';
207     xloc='top'; ytic=[-90:10:-50];
208     elseif proj==3.1;
209     m_proj('Stereographic','lon',0,'lat',-90,'rad',60);
210     myConv='convert2southern';
211     xloc='top'; ytic=[-90:10:-30];
212     elseif proj==4.1;
213     m_proj('mollweide','lat',[25 75],'lon',[-100 30]);
214     myConv='pcol';
215     xtic=[-100:20:30]; ytic=[30:10:70];
216     elseif proj==4.2;
217     m_proj('mollweide','lat',[-30 30],'lon',[-65 20]);
218     myConv='pcol';
219     xtic=[-60:10:20]; ytic=[-30:10:30];
220     elseif proj==4.3;
221     m_proj('mollweide','lat',[-75 -25],'lon',[-75 25]);
222     myConv='pcol';
223     xtic=[-70:20:20]; ytic=[-70:10:-30]; xloc='top';
224     elseif proj==4.4;
225     m_proj('mollweide','lat',[25 75],'lon',[-240 -110]);
226     myConv='pcol';
227     xtic=[-240:20:-120]; ytic=[30:10:60];
228     elseif proj==4.5;
229     m_proj('mollweide','lat',[-30 30],'lon',[-240 -70]);
230     myConv='pcol';
231     xtic=[-240:20:-70]; ytic=[-30:10:30];
232     elseif proj==4.6;
233     m_proj('mollweide','lat',[-75 -25],'lon',[-215 -60]);
234     myConv='pcol';
235     xtic=[-210:20:-70]; ytic=[-70:10:-30]; xloc='top';
236     elseif proj==4.7;
237     m_proj('mollweide','lat',[-30 30],'lon',[15 155]);
238     myConv='pcol';
239     xtic=[10:20:160]; ytic=[-30:10:30]; xloc='top';
240     elseif proj==4.8;
241     m_proj('mollweide','lat',[-75 -25],'lon',[15 155]);
242     myConv='pcol';
243     xtic=[10:20:160]; ytic=[-70:10:-30]; xloc='top';
244     else;
245     error('undefined projection');
246 gforget 1.3 end;
247 gforget 1.1
248 gforget 1.8 if ~param.doLabl; xticlab=0; yticlab=0;end; %omit labels
249    
250     m_grid_opt=['''XaxisLocation'',xloc,''YaxisLocation'',yloc,''xtick'',xtic,''ytick'',ytic'];
251     if xticlab==0; m_grid_opt=[m_grid_opt ',''xticklabel'',[]']; end;
252     if yticlab==0; m_grid_opt=[m_grid_opt ',''yticklabel'',[]']; end;
253    
254 gforget 1.7 if strcmp(param.myPlot,'pcolor')|strcmp(param.myPlot,'contour');
255 gforget 1.8 x=mygrid.XC;
256     %mask out the XC padded zeros
257     if isfield(mygrid,'xtrct');
258     pt1=mygrid.xtrct.pt1face; pt2=mygrid.xtrct.pt2face;
259     if pt1~=pt2;
260     for iF=1:6; if iF~=pt1&iF~=pt2; x{iF}(:)=NaN; end; end;
261     end;
262     x(x<0)=x(x<0)+360;
263     end;
264     if strcmp(myConv,'pcol');
265     [xx,yy,z]=convert2pcol(x,mygrid.YC,fld{2});
266 gforget 1.7 else;
267 gforget 1.8 eval(['xx=' myConv '(x);']);
268     eval(['yy=' myConv '(mygrid.YC);']);
269     eval(['z=' myConv '(fld{2});']);
270 gforget 1.7 end;
271     [x,y]=m_ll2xy(xx,yy);
272     if strcmp(param.myPlot,'pcolor');
273 gforget 1.9 if sum(~isnan(x(:)))>0; pcolor(x,y,z); eval(['shading ' shad ';']); end;
274 gforget 1.8 if param.plotCBAR==0;
275     colormap(param.myCmap); if param.doCbar; colorbar; end;
276     elseif param.plotCBAR==1;
277     caxis(param.myCaxis); colormap(param.myCmap); if param.doCbar; colorbar; end;
278     else;
279     cbar=gcmfaces_cmap_cbar(param.myCaxis,{'myCmap',param.myCmap}); delete(cbar);
280 gforget 1.7 end;
281     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
282 gforget 1.8 eval(['m_grid(' m_grid_opt ');']);
283 gforget 1.7 elseif strcmp(param.myPlot,'contour');
284     if ~param.doHold;
285     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
286 gforget 1.8 eval(['m_grid(' m_grid_opt ');']);
287 gforget 1.7 end;
288     if length(fld)==2; fld{3}='k'; end;
289     hold on; contour(x,y,z,fld{3:end});
290     end;
291     elseif strcmp(param.myPlot,'plot');
292     if ~param.doHold;
293     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
294 gforget 1.8 eval(['m_grid(' m_grid_opt ');']);
295 gforget 1.7 end;
296     [x,y]=m_ll2xy(fld{2},fld{3});
297     hold on; plot(x,y,fld{4:end});
298 gforget 1.8 elseif strcmp(param.myPlot,'text');
299     if ~param.doHold;
300     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
301     eval(['m_grid(' m_grid_opt ');']);
302     end;
303     [x,y]=m_ll2xy(fld{2},fld{3});
304     if length(fld)>4; cc=fld{5}; else; cc='k'; end;
305     hold on; hold on; text(x,y,fld{4},'Color',cc,'FontSize',16,'FontWeight','bold');
306 gforget 1.7 end;
307 gforget 1.1
308 gforget 1.8 %add tag spec. to map & proj generated with this routine
309     set(gca,'Tag',['gfMap' num2str(proj)]);
310    

  ViewVC Help
Powered by ViewVC 1.1.22