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

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

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


Revision 1.1 - (hide annotations) (download)
Sun May 2 21:25:48 2010 UTC (15 years, 2 months ago) by gforget
Branch: MAIN
migration gcmfaces_maps

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

  ViewVC Help
Powered by ViewVC 1.1.22