/[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.12 - (hide annotations) (download)
Wed Jun 10 15:41:21 2015 UTC (10 years, 1 month ago) by gforget
Branch: MAIN
CVS Tags: checkpoint65p
Changes since 1.11: +2 -2 lines
- add print statements wrt tex compilation on LINUX machines.

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.3 set(cbar,'Position',[0.92 0.15 0.02 0.75]);
145     elseif choicePlot==-1;
146     set(cbar,'Position',[0.92 0.35 0.02 0.3]);
147 gforget 1.7 elseif choicePlot==1;
148 gforget 1.3 set(cbar,'Position',[0.92 0.34 0.02 0.35]);
149     else;
150 gforget 1.12 % set(cbar,'Position',[0.92 0.23 0.02 0.55]);
151     pos=get(cbar,'Position'); pos(1)=pos(1)-0.1; set(cbar,'Position',pos);
152 gforget 1.7 end;
153     end;
154    
155 gforget 1.8 if doFit;
156     if doLabl&~doCbar;
157     set(gca,'LooseInset',[0.05 0.02 0.03 0.03]);
158     else;
159     set(gca,'LooseInset',[0.01 0 0.03 0.03]);
160     end;
161     tmp1=get(gca,'PlotBoxAspectRatio');
162     set(gcf,'PaperPosition',[0 4 8 8/tmp1(1)]);
163     end;
164 gforget 1.7
165 gforget 1.9 function []=do_my_plot(fld,param,proj,shad);
166 gforget 1.7
167     gcmfaces_global;
168    
169 gforget 1.8 %default m_grid params:
170     xloc='bottom'; xtic=[-180:60:180]; xticlab=1;
171     yloc='left'; ytic=[-60:30:60]; yticlab=1;
172    
173     %choice of projection:
174 gforget 1.7 if proj==-1;
175     %%m_proj('Miller Cylindrical','lat',[-90 90]);
176     %m_proj('Equidistant cylindrical','lat',[-90 90]);
177     %m_proj('mollweide','lon',[-180 180],'lat',[-80 80]);
178     m_proj('mollweide','lon',[-180 180],'lat',[-88 88]);
179 gforget 1.8 myConv='pcol'; xticlab=0; yticlab=0;
180 gforget 1.7 elseif proj==1;
181     m_proj('Mercator','lat',[-70 70]);
182 gforget 1.8 myConv='pcol';
183     elseif proj==1.1;
184     m_proj('Mercator','lat',[-70 70],'lon',[0 360]+20);
185     myConv='pcol';
186     xtic=[-360:60:360]; ytic=[-60:30:60];
187 gforget 1.11 elseif proj==1.2;
188     m_proj('Equidistant cylindrical','lat',[-90 90],'lon',[0 360]+20);
189     myConv='pcol';
190     xtic=[-360:60:360]; ytic=[-90:30:90];
191     elseif proj==1.3;
192     m_proj('Equidistant cylindrical','lat',[15 30],'lon',[190 210]);
193     myConv='pcol';
194     xtic=[190:5:220]; ytic=[15:3:30];
195 gforget 1.7 elseif proj==2;
196     m_proj('Stereographic','lon',0,'lat',90,'rad',40);
197 gforget 1.8 myConv='convert2arctic';
198     yloc='bottom'; ytic=[50:10:90];
199     elseif proj==2.1;
200     m_proj('Stereographic','lon',0,'lat',90,'rad',60);
201     myConv='convert2arctic';
202     yloc='bottom'; ytic=[30:10:90];
203 gforget 1.7 elseif proj==3;
204     m_proj('Stereographic','lon',0,'lat',-90,'rad',40);
205 gforget 1.8 myConv='convert2southern';
206     xloc='top'; ytic=[-90:10:-50];
207     elseif proj==3.1;
208     m_proj('Stereographic','lon',0,'lat',-90,'rad',60);
209     myConv='convert2southern';
210     xloc='top'; ytic=[-90:10:-30];
211     elseif proj==4.1;
212     m_proj('mollweide','lat',[25 75],'lon',[-100 30]);
213     myConv='pcol';
214     xtic=[-100:20:30]; ytic=[30:10:70];
215     elseif proj==4.2;
216     m_proj('mollweide','lat',[-30 30],'lon',[-65 20]);
217     myConv='pcol';
218     xtic=[-60:10:20]; ytic=[-30:10:30];
219     elseif proj==4.3;
220     m_proj('mollweide','lat',[-75 -25],'lon',[-75 25]);
221     myConv='pcol';
222     xtic=[-70:20:20]; ytic=[-70:10:-30]; xloc='top';
223     elseif proj==4.4;
224     m_proj('mollweide','lat',[25 75],'lon',[-240 -110]);
225     myConv='pcol';
226     xtic=[-240:20:-120]; ytic=[30:10:60];
227     elseif proj==4.5;
228     m_proj('mollweide','lat',[-30 30],'lon',[-240 -70]);
229     myConv='pcol';
230     xtic=[-240:20:-70]; ytic=[-30:10:30];
231     elseif proj==4.6;
232     m_proj('mollweide','lat',[-75 -25],'lon',[-215 -60]);
233     myConv='pcol';
234     xtic=[-210:20:-70]; ytic=[-70:10:-30]; xloc='top';
235     elseif proj==4.7;
236     m_proj('mollweide','lat',[-30 30],'lon',[15 155]);
237     myConv='pcol';
238     xtic=[10:20:160]; ytic=[-30:10:30]; xloc='top';
239     elseif proj==4.8;
240     m_proj('mollweide','lat',[-75 -25],'lon',[15 155]);
241     myConv='pcol';
242     xtic=[10:20:160]; ytic=[-70:10:-30]; xloc='top';
243     else;
244     error('undefined projection');
245 gforget 1.3 end;
246 gforget 1.1
247 gforget 1.8 if ~param.doLabl; xticlab=0; yticlab=0;end; %omit labels
248    
249     m_grid_opt=['''XaxisLocation'',xloc,''YaxisLocation'',yloc,''xtick'',xtic,''ytick'',ytic'];
250     if xticlab==0; m_grid_opt=[m_grid_opt ',''xticklabel'',[]']; end;
251     if yticlab==0; m_grid_opt=[m_grid_opt ',''yticklabel'',[]']; end;
252    
253 gforget 1.7 if strcmp(param.myPlot,'pcolor')|strcmp(param.myPlot,'contour');
254 gforget 1.8 x=mygrid.XC;
255     %mask out the XC padded zeros
256     if isfield(mygrid,'xtrct');
257     pt1=mygrid.xtrct.pt1face; pt2=mygrid.xtrct.pt2face;
258     if pt1~=pt2;
259     for iF=1:6; if iF~=pt1&iF~=pt2; x{iF}(:)=NaN; end; end;
260     end;
261     x(x<0)=x(x<0)+360;
262     end;
263     if strcmp(myConv,'pcol');
264     [xx,yy,z]=convert2pcol(x,mygrid.YC,fld{2});
265 gforget 1.7 else;
266 gforget 1.8 eval(['xx=' myConv '(x);']);
267     eval(['yy=' myConv '(mygrid.YC);']);
268     eval(['z=' myConv '(fld{2});']);
269 gforget 1.7 end;
270     [x,y]=m_ll2xy(xx,yy);
271     if strcmp(param.myPlot,'pcolor');
272 gforget 1.9 if sum(~isnan(x(:)))>0; pcolor(x,y,z); eval(['shading ' shad ';']); end;
273 gforget 1.8 if param.plotCBAR==0;
274     colormap(param.myCmap); if param.doCbar; colorbar; end;
275     elseif param.plotCBAR==1;
276     caxis(param.myCaxis); colormap(param.myCmap); if param.doCbar; colorbar; end;
277     else;
278     cbar=gcmfaces_cmap_cbar(param.myCaxis,{'myCmap',param.myCmap}); delete(cbar);
279 gforget 1.7 end;
280     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
281 gforget 1.8 eval(['m_grid(' m_grid_opt ');']);
282 gforget 1.7 elseif strcmp(param.myPlot,'contour');
283     if ~param.doHold;
284     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
285 gforget 1.8 eval(['m_grid(' m_grid_opt ');']);
286 gforget 1.7 end;
287     if length(fld)==2; fld{3}='k'; end;
288     hold on; contour(x,y,z,fld{3:end});
289     end;
290     elseif strcmp(param.myPlot,'plot');
291     if ~param.doHold;
292     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
293 gforget 1.8 eval(['m_grid(' m_grid_opt ');']);
294 gforget 1.7 end;
295     [x,y]=m_ll2xy(fld{2},fld{3});
296     hold on; plot(x,y,fld{4:end});
297 gforget 1.8 elseif strcmp(param.myPlot,'text');
298     if ~param.doHold;
299     if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end;
300     eval(['m_grid(' m_grid_opt ');']);
301     end;
302     [x,y]=m_ll2xy(fld{2},fld{3});
303     if length(fld)>4; cc=fld{5}; else; cc='k'; end;
304     hold on; hold on; text(x,y,fld{4},'Color',cc,'FontSize',16,'FontWeight','bold');
305 gforget 1.7 end;
306 gforget 1.1
307 gforget 1.8 %add tag spec. to map & proj generated with this routine
308     set(gca,'Tag',['gfMap' num2str(proj)]);
309    

  ViewVC Help
Powered by ViewVC 1.1.22