1 |
gforget |
1.2 |
function []=m_map_1face(fld,iFace,varargin); |
2 |
gforget |
1.1 |
%purpose: |
3 |
|
|
% use m_map to display one face in a chosen projection |
4 |
|
|
%synthax: |
5 |
gforget |
1.2 |
% m_map_1face(fld,iFace,choiceProj); |
6 |
gforget |
1.1 |
%inputs: |
7 |
|
|
% fld is a 2D field in gcmfaces format |
8 |
|
|
% iFace is the face number |
9 |
|
|
% choiceProj is the projection choice (0, 1, 2, or 3) |
10 |
|
|
% if it is not stated, the default is mollweide (0) |
11 |
|
|
|
12 |
|
|
%check that m_map is in the path |
13 |
|
|
aa=which('m_proj'); if isempty(aa); error('this function requires m_map that is missing'); end; |
14 |
|
|
|
15 |
|
|
%get parameters: |
16 |
gforget |
1.2 |
if nargin>2; choiceProj=varargin{1}; else; choiceProj=0; end; |
17 |
|
|
if nargin>3; cc=varargin{2}; else; cc=[]; end; |
18 |
|
|
if nargin>4; doPlotCoast=varargin{3}; else; doPlotCoast=1; end; |
19 |
gforget |
1.1 |
|
20 |
|
|
global mygrid; |
21 |
|
|
|
22 |
|
|
%extract face: |
23 |
|
|
x=mygrid.XC{iFace}(:,:); |
24 |
|
|
y=mygrid.YC{iFace}(:,:); |
25 |
|
|
z=fld{iFace}(:,:); |
26 |
|
|
m1=mygrid.mskC{iFace}(:,:,1); |
27 |
|
|
if length(size(z))~=2; error('input must be a 2D field in gcmfaces format'); end; |
28 |
|
|
|
29 |
|
|
%put mask on x and y: |
30 |
|
|
x(isnan(m1))=NaN; y(isnan(m1))=NaN; |
31 |
|
|
|
32 |
gforget |
1.2 |
%enforce [-180 180] longitude convention; |
33 |
|
|
x(find(x>180))=x(find(x>180))-360; |
34 |
gforget |
1.1 |
|
35 |
|
|
%select lat/lon range: |
36 |
|
|
ii=find(~isnan(m1)); |
37 |
|
|
ll=[min(x(ii)) max(x(ii))]; |
38 |
|
|
LL=[min(y(ii)) max(y(ii))]; |
39 |
|
|
|
40 |
|
|
if choiceProj==0; |
41 |
|
|
%%m_proj('Miller Cylindrical','lon',ll,'lat',LL); |
42 |
|
|
%%m_proj('Equidistant cylindrical','lon',ll,'lat',LL); |
43 |
|
|
m_proj('mollweide','lon',ll,'lat',LL); |
44 |
|
|
elseif choiceProj==1; |
45 |
|
|
m_proj('Mercator','lon',ll,'lat',LL); |
46 |
|
|
elseif choiceProj==2; |
47 |
|
|
m_proj('Stereographic','lon',0,'lat',90,'rad',90-LL(1)); |
48 |
|
|
elseif choiceProj==3; |
49 |
|
|
m_proj('Stereographic','lon',0,'lat',-90,'rad',90+LL(2) ); |
50 |
|
|
end; |
51 |
|
|
|
52 |
|
|
[x,y]=m_ll2xy(x,y); |
53 |
|
|
pcolor(x,y,z); shading flat; if ~isempty(cc); caxis(cc); end; colorbar; |
54 |
|
|
if doPlotCoast; m_coast('patch',[1 1 1]*.7,'edgecolor','none'); end; m_grid; |
55 |
|
|
|
56 |
|
|
|