Global Index (all files) (short | long) | Local Index (files in subdir) (short | long)
hout=landmask(lc,oc,kc,le,oe,ke,lwdth,lgrd,grdx,grdy)
function hout=landmask(lc,oc,kc,le,oe,ke,lwdth,lgrd,grdx,grdy)
This function calls | |
---|---|
function hout=landmask(lc,oc,kc,le,oe,ke,lwdth,lgrd,grdx,grdy) % added sorting of x/y-ticks, because matlab 5 requires them to be % monotonically increasing global COASTWIDTH coastn coastx2 coasty global GRDX_SPACING GRDY_SPACING SKIP_GRID COASTGRID global POLAR_MAP POLAR_LAT %---------------------------------------------------------- % [ land ocean lake ] fill color if nargin<1; lc=''; end; if nargin<2; oc=''; end; if nargin<3; kc=''; end; % [ land ocean lake ] edge color if nargin<4; le=''; end; if nargin<5; oe=''; end; if nargin<6; ke=''; end; if nargin<7; lwdth=''; end; if nargin<8; lgrd=''; end; if nargin<9; grdx=''; end; if nargin<10;grdy=''; end; %---------------------------------------------------------- % [ land ocean lake ] fill color % default land is gray if isempty(lc); lc = [0.80 0.80 0.80]; end % default ocean is transparent if isempty(oc); oc = ''; end; % default lake is white if isempty(kc); kc = 'white'; end; % [ land ocean lake ] edge color if isempty(le); le = lc; end; if isempty(oe); oe = 'none'; end; if isempty(ke); ke = kc; end; if isempty(lwdth); lwdth = COASTWIDTH; end if isempty(lgrd); lgrd = COASTGRID; end if isempty(grdx); grdx = GRDX_SPACING; end if isempty(grdy); grdy = GRDY_SPACING; end %---------------------------------------------------------- if strcmp(lc,le); lw=0; else; lw=lwdth; end; if strcmp(kc,ke); kw=0; else; kw=lwdth; end; if length(coastn)==277; load coasts.mat; end n2=cumsum(coastn); n1=[1;n2+1]; hh = []; % make sure plotting in the preset frame if POLAR_MAP polar_frame(POLAR_LAT); else frame; end fx=get(gca,'xlim'); fy=get(gca,'ylim'); % map is superimposed, will not affect existing display push_hold; % frame box and grid lines if POLAR_MAP h = polar_grid(grdx,grdy,'k-','k:',POLAR_LAT,80); hh = [ hh; h(:) ]; else xticks = sort([ 0:-grdx:fx(1) grdx:grdx:fx(2) ]); yticks = sort([ 0:-grdy:fy(1) grdy:grdy:fy(2) ]); manual_ticks('x',xticks,label_eastwest(xticks)); manual_ticks('y',yticks,label_northsouth(yticks)); if ~isempty(lgrd); vline(xticks,lgrd); hline(yticks,lgrd); end; end % continents % [ Antartica Americas Greenland Eurasia Australia ] m2 = [ 3 6 ; 17 31 ; 112 113; 117 137; 218 220]; % islands m1 = [ 7:16 43:111 114:116 278 150:217 221:277]; % inland lakes m0 = [ 32:42 138:149 ]; % fill the background with Ocean color lvl = -10; if ~isempty(oc); h = fill3(fx([1 2 2 1 1]),fy([1 1 2 2 1]),lvl*ones(1,5),oc); set(h,'edgecolor',oe); hh = [ hh; h ]; end % determine how many repeat cycle if POLAR_MAP nt1 = 0; nt2 = 0; tmpx = coastx2; tmpy = coasty; [coastx2,coasty] = latlng2stereo(sign(POLAR_MAP)*coastx2,sign(POLAR_MAP)*coasty); % [coastx2,coasty] = latlng2stereo(coastx2,sign(POLAR_MAP)*coasty); % skip Antartica for northern hemisphere, otherwise fill everything if POLAR_MAP==1; coastx2(n1(m2(1,1)))=nan; end else nt1 = floor((fx(1)+180)/360); nt2 = floor((fx(2)+180-1.e-9)/360); end % plot the mask for it = nt1:nt2; tt=it*360; % fill the continents [mlen,dummy] = size(m2); for i = 1 : mlen nn = [ n1(m2(i,1)):n2(m2(i,2)) n1(m2(i,1)) ]; h=fill3(coastx2(nn)+tt,coasty(nn),lvl*ones(size(nn)),lc); if lw; set(h,'edgecolor',le,'linewidth',lw); else; set(h,'edgecolor','none'); end hh = [ hh; h ]; end % fill the islands for i = 1 : length(m1) nn = [ n1(m1(i)) : n2(m1(i)) ]; h=fill3(coastx2(nn)+tt,coasty(nn),lvl*ones(size(nn)),lc); if lw; set(h,'edgecolor',le,'linewidth',lw); else; set(h,'edgecolor','none'); end hh = [ hh; h ]; end % fill the lakes for i = 1 : length(m0) nn = [ n1(m0(i)) : n2(m0(i)) ]; h=fill3(coastx2(nn)+tt,coasty(nn),lvl*ones(size(nn)),kc); if kw; set(h,'edgecolor',ke,'linewidth',kw); else; set(h,'edgecolor','none'); end hh = [ hh; h ]; end end if strcmp(oe,'none'); plot(fx([1 2 2 1 1]),fy([1 1 2 2 1]),'k'); else plot(fx([1 2 2 1 1]),fy([1 1 2 2 1]),oe); end % restore initial conditions if POLAR_MAP polar_clip; coastx2 = tmpx; coasty= tmpy; end pop_hold if nargout==1; hout=hh; end;