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.3 |
% |
14 |
gforget |
1.4 |
%notes: - for proj==0 (i.e. the default) three panels will be plotted : |
15 |
|
|
% a mercator projection over mid-latitude, and two polar |
16 |
gforget |
1.7 |
% stereographic projections. The other predefined proj are |
17 |
gforget |
1.3 |
% -1 mollweide or cylindrical projection |
18 |
|
|
% 1 mercator projection only |
19 |
|
|
% 2 arctic stereographic projection only |
20 |
|
|
% 3 antarctic stereographic projection only |
21 |
gforget |
1.7 |
% 1.1 and 1.2 are atlantic mercator projections |
22 |
gforget |
1.4 |
% - myTitle is currently not used; it will take the form |
23 |
|
|
% {'myTitle',myTitle} is the title (none by default) |
24 |
gforget |
1.7 |
% - myCaxis can be specified with more than 2 values, in which |
25 |
|
|
% case gcmfaces_cb will be used. |
26 |
|
|
% - if fld is a 2D field we use pcolor to display it |
27 |
|
|
% - if fld is a cell one can specify the plotting tool. |
28 |
|
|
% The cell must then have the form {plotType,FLD,varargin} |
29 |
|
|
% where plotType is e.g. 'pcolor' or 'contour', FLD is |
30 |
|
|
% the 2D field to be plotted, and varargin are options |
31 |
|
|
% to pass over to the contour command. |
32 |
|
|
% - Hence .e.g. fld={'contour',mygrid.Depth,'r'} will draw |
33 |
|
|
% red contours, while fld=mygrid.Depth will color shade. |
34 |
gforget |
1.1 |
|
35 |
gforget |
1.2 |
%check that m_map is in the path |
36 |
|
|
aa=which('m_proj'); if isempty(aa); error('this function requires m_map that is missing'); end; |
37 |
|
|
|
38 |
gforget |
1.1 |
global mygrid; |
39 |
|
|
|
40 |
gforget |
1.4 |
%get optional parameters |
41 |
|
|
if nargin>1; proj=varargin{1}; else; proj=0; end; |
42 |
gforget |
1.7 |
if iscell(proj); |
43 |
|
|
error('not yet implemented'); |
44 |
gforget |
1.4 |
else; |
45 |
|
|
choicePlot=proj; |
46 |
|
|
end; |
47 |
gforget |
1.7 |
%determine the type of plot |
48 |
|
|
if iscell(fld); myPlot=fld{1}; else; myPlot='pcolor'; fld={'pcolor',fld}; end; |
49 |
gforget |
1.4 |
%set more optional paramaters to default values |
50 |
gforget |
1.7 |
myCaxis=[]; myTitle=''; do_m_coast=1; myCmap='jet'; doHold=0; |
51 |
gforget |
1.4 |
%set more optional paramaters to user defined values |
52 |
|
|
for ii=2:nargin-1; |
53 |
|
|
if ~iscell(varargin{ii}); |
54 |
|
|
warning('inputCheck:m_map_gcmfaces_1',... |
55 |
|
|
['As of june 2011, m_map_gcmfaces expects \n'... |
56 |
|
|
' its optional parameters as cell arrays. \n'... |
57 |
|
|
' Argument no. ' num2str(ii+1) ' was ignored \n'... |
58 |
|
|
' Type ''help m_map_gcmfaces'' for details.']); |
59 |
|
|
elseif ~ischar(varargin{ii}{1}); |
60 |
|
|
warning('inputCheck:m_map_gcmfaces_2',... |
61 |
|
|
['As of june 2011, m_map_gcmfaces expects \n'... |
62 |
|
|
' its optional parameters cell arrays \n'... |
63 |
|
|
' to start with character string. \n'... |
64 |
|
|
' Argument no. ' num2str(ii+1) ' was ignored \n'... |
65 |
|
|
' Type ''help m_map_gcmfaces'' for details.']); |
66 |
|
|
else; |
67 |
|
|
if strcmp(varargin{ii}{1},'myCaxis')|... |
68 |
gforget |
1.6 |
strcmp(varargin{ii}{1},'myCmap')|... |
69 |
gforget |
1.7 |
strcmp(varargin{ii}{1},'doHold')|... |
70 |
gforget |
1.4 |
strcmp(varargin{ii}{1},'do_m_coast')|... |
71 |
|
|
strcmp(varargin{ii}{1},'myTitle'); |
72 |
|
|
eval([varargin{ii}{1} '=varargin{ii}{2};']); |
73 |
|
|
else; |
74 |
|
|
warning('inputCheck:m_map_gcmfaces_3',... |
75 |
|
|
['unknown option ''' varargin{ii}{1} ''' was ignored']); |
76 |
|
|
end; |
77 |
|
|
end; |
78 |
|
|
end; |
79 |
gforget |
1.7 |
|
80 |
gforget |
1.4 |
%make parameter inferences |
81 |
gforget |
1.7 |
if length(myCaxis)==0; |
82 |
|
|
plotCBAR=0; |
83 |
|
|
elseif length(myCaxis)==2; |
84 |
|
|
plotCBAR=1; |
85 |
|
|
else; |
86 |
|
|
plotCBAR=2; |
87 |
|
|
end; |
88 |
|
|
% |
89 |
|
|
if choicePlot==0&~doHold; |
90 |
|
|
clf; |
91 |
|
|
elseif ~doHold; |
92 |
|
|
cla; |
93 |
|
|
else; |
94 |
|
|
hold on; |
95 |
|
|
end; |
96 |
|
|
|
97 |
|
|
%re-group param: |
98 |
|
|
param.plotCBAR=plotCBAR; |
99 |
|
|
param.myCmap=myCmap; |
100 |
|
|
param.myCaxis=myCaxis; |
101 |
|
|
param.do_m_coast=do_m_coast; |
102 |
|
|
param.doHold=doHold; |
103 |
|
|
param.myPlot=myPlot; |
104 |
|
|
|
105 |
|
|
%do the plotting: |
106 |
|
|
if (choicePlot~=0&choicePlot~=1&choicePlot~=2&choicePlot~=3); |
107 |
|
|
do_my_plot(fld,param,choicePlot); |
108 |
|
|
end;%if choicePlot==0|choicePlot==1; |
109 |
gforget |
1.1 |
|
110 |
|
|
if choicePlot==0; subplot(2,1,1); end; |
111 |
gforget |
1.7 |
if choicePlot==0|choicePlot==1; |
112 |
|
|
do_my_plot(fld,param,1); |
113 |
|
|
end;%if choicePlot==0|choicePlot==1; |
114 |
gforget |
1.3 |
|
115 |
gforget |
1.1 |
if choicePlot==0; subplot(2,2,3); end; |
116 |
gforget |
1.7 |
if choicePlot==0|choicePlot==2; |
117 |
|
|
do_my_plot(fld,param,2); |
118 |
|
|
end;%if choicePlot==0|choicePlot==1; |
119 |
gforget |
1.1 |
|
120 |
|
|
if choicePlot==0; subplot(2,2,4); end; |
121 |
gforget |
1.7 |
if choicePlot==0|choicePlot==3; |
122 |
|
|
do_my_plot(fld,param,3); |
123 |
|
|
end;%if choicePlot==0|choicePlot==1; |
124 |
gforget |
1.1 |
|
125 |
gforget |
1.7 |
if plotCBAR==2&strcmp(myPlot,'pcolor'); |
126 |
gforget |
1.6 |
cbar=gcmfaces_cmap_cbar(myCaxis,{'myCmap',myCmap}); |
127 |
gforget |
1.7 |
if choicePlot==0; |
128 |
gforget |
1.3 |
set(cbar,'Position',[0.92 0.15 0.02 0.75]); |
129 |
|
|
elseif choicePlot==-1; |
130 |
|
|
set(cbar,'Position',[0.92 0.35 0.02 0.3]); |
131 |
gforget |
1.7 |
elseif choicePlot==1; |
132 |
gforget |
1.3 |
set(cbar,'Position',[0.92 0.34 0.02 0.35]); |
133 |
|
|
else; |
134 |
|
|
set(cbar,'Position',[0.92 0.23 0.02 0.55]); |
135 |
gforget |
1.7 |
end; |
136 |
|
|
end; |
137 |
|
|
|
138 |
|
|
|
139 |
|
|
function []=do_my_plot(fld,param,proj); |
140 |
|
|
|
141 |
|
|
gcmfaces_global; |
142 |
|
|
|
143 |
|
|
if proj==-1; |
144 |
|
|
%%m_proj('Miller Cylindrical','lat',[-90 90]); |
145 |
|
|
%m_proj('Equidistant cylindrical','lat',[-90 90]); |
146 |
|
|
%m_proj('mollweide','lon',[-180 180],'lat',[-80 80]); |
147 |
|
|
m_proj('mollweide','lon',[-180 180],'lat',[-88 88]); |
148 |
|
|
conv='pcol'; |
149 |
|
|
elseif proj==1; |
150 |
|
|
m_proj('Mercator','lat',[-70 70]); |
151 |
|
|
conv='pcol'; |
152 |
|
|
elseif proj==2; |
153 |
|
|
m_proj('Stereographic','lon',0,'lat',90,'rad',40); |
154 |
|
|
conv='convert2arctic'; |
155 |
|
|
elseif proj==3; |
156 |
|
|
m_proj('Stereographic','lon',0,'lat',-90,'rad',40); |
157 |
|
|
conv='convert2southern'; |
158 |
|
|
elseif proj==1.1; |
159 |
|
|
m_proj('Mercator','lat',[20 60],'lon',[-100 -30]); |
160 |
|
|
conv='pcol'; |
161 |
|
|
elseif proj==1.2; |
162 |
|
|
m_proj('Mercator','lat',[10 60],'lon',[-100 30]); |
163 |
|
|
conv='pcol'; |
164 |
gforget |
1.3 |
end; |
165 |
gforget |
1.1 |
|
166 |
gforget |
1.7 |
if strcmp(param.myPlot,'pcolor')|strcmp(param.myPlot,'contour'); |
167 |
|
|
if strcmp(conv,'pcol'); |
168 |
|
|
[xx,yy,z]=convert2pcol(mygrid.XC,mygrid.YC,fld{2}); |
169 |
|
|
else; |
170 |
|
|
eval(['xx=' conv '(mygrid.XC);']); |
171 |
|
|
eval(['yy=' conv '(mygrid.YC);']); |
172 |
|
|
eval(['z=' conv '(fld{2});']); |
173 |
|
|
end; |
174 |
|
|
[x,y]=m_ll2xy(xx,yy); |
175 |
|
|
if strcmp(param.myPlot,'pcolor'); |
176 |
|
|
if sum(~isnan(x(:)))>0; pcolor(x,y,z); shading interp; end; |
177 |
|
|
if param.plotCBAR==0; colormap(param.myCmap); colorbar; |
178 |
|
|
elseif param.plotCBAR==1; caxis(param.myCaxis); colormap(param.myCmap); colorbar; |
179 |
|
|
else; cbar=gcmfaces_cmap_cbar(param.myCaxis,{'myCmap',param.myCmap}); delete(cbar); |
180 |
|
|
end; |
181 |
|
|
if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end; |
182 |
|
|
m_grid('XaxisLocation','bottom'); |
183 |
|
|
elseif strcmp(param.myPlot,'contour'); |
184 |
|
|
if ~param.doHold; |
185 |
|
|
if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end; |
186 |
|
|
m_grid('XaxisLocation','bottom'); |
187 |
|
|
end; |
188 |
|
|
if length(fld)==2; fld{3}='k'; end; |
189 |
|
|
hold on; contour(x,y,z,fld{3:end}); |
190 |
|
|
end; |
191 |
|
|
elseif strcmp(param.myPlot,'plot'); |
192 |
|
|
if ~param.doHold; |
193 |
|
|
if param.do_m_coast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end; |
194 |
|
|
m_grid('XaxisLocation','bottom'); |
195 |
|
|
end; |
196 |
|
|
[x,y]=m_ll2xy(fld{2},fld{3}); |
197 |
|
|
hold on; plot(x,y,fld{4:end}); |
198 |
|
|
end; |
199 |
gforget |
1.1 |
|