/[MITgcm]/MITgcm/utils/matlab/cm_landwater.m
ViewVC logotype

Contents of /MITgcm/utils/matlab/cm_landwater.m

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


Revision 1.1 - (show annotations) (download)
Fri May 6 17:23:24 2005 UTC (19 years, 2 months ago) by adcroft
Branch: MAIN
CVS Tags: checkpoint58l_post, checkpoint57t_post, checkpoint57o_post, checkpoint58e_post, checkpoint57v_post, checkpoint58u_post, checkpoint57m_post, checkpoint57s_post, checkpoint57k_post, checkpoint58r_post, checkpoint57i_post, checkpoint57y_post, checkpoint58n_post, checkpoint58t_post, checkpoint58h_post, checkpoint57y_pre, checkpoint58q_post, checkpoint58j_post, checkpoint57r_post, checkpoint58, checkpoint57h_done, checkpoint58f_post, checkpoint57x_post, checkpoint57n_post, checkpoint58d_post, checkpoint58c_post, checkpoint57w_post, checkpoint57p_post, checkpint57u_post, checkpoint58a_post, checkpoint58i_post, checkpoint57q_post, checkpoint58g_post, checkpoint58o_post, checkpoint57z_post, checkpoint58k_post, checkpoint58v_post, checkpoint58s_post, checkpoint58p_post, checkpoint57j_post, checkpoint58b_post, checkpoint57h_pre, checkpoint58m_post, checkpoint57l_post, checkpoint57h_post
Two new scripts:
 fancycube    - plots cubed sphere data with continents on sphere
 cm_landwater - creates colormap for plotting bathymetry/orography

1 function [c] = cm_landwater(n,varargin)
2 % [c] = cm_landwater(n)
3 % [c] = cm_landwater(n,f)
4 %
5 % n - is size of color map
6 % f is scalar fraction that should be water (default=0.5)
7 % or vector [hmin hmax] from which f will be calculated
8 %
9 % e.g.
10 % >> cm_landwater(64,caxis);
11 %
12 % Green-yellor land/blue water colormap
13
14 if nargin==1
15 f=0.5;
16 else
17 f=varargin{1};
18 end
19
20 if prod(size(f))==2
21 hmin=f(1);hmax=f(2);
22 f=-hmin/(hmax-hmin);
23 f=max(0,f);f=min(1,f);
24 end
25
26 if mod(n,2)==0
27 nb=round(n*f(1));
28 ng=n-nb;
29 nw=0;
30 else
31 nb=floor(n*f(1));
32 nw=1;
33 ng=n-nb-nw;
34 end
35 b=bluewater(nb);
36 g=greenland(ng);
37 w=ones(nw,1)*[1 1 0.55];
38
39 c=[b' w' g']';
40 if nargout==0
41 colormap(c);
42 end
43
44 %subplot(211)
45 %plot((0:(n-1))/(n-1),c(:,3:-1:1))
46 %subplot(212)
47 %pcol([-1:.1/n:1])
48 %axis off
49
50 % ----------------------------------------------------
51 function [c] = bluewater(n)
52 % Blue colormap
53
54 x=(0:n-1)'/(n-1);
55 c=((.7-.7*x)*[1 1 0]+max(0,(1-.65*x))*[0 0 1]);
56 c=c(end:-1:1,:);
57 %colormap(c);
58 % ----------------------------------------------------
59 function [c] = greenland(n)
60 % Green land colormap
61
62 x=(0:n-1)'/(n-1);
63 r=max(0,(-.25+1.8*x));
64 g=.4*(1+2.5*x);
65 b=0.5*max(0,(-.25+2.0*x));
66 i=find(r>1);
67 r(i)=max( 1.7-1*x(i), b(i));
68 i=find(g>1);
69 g(i)=max( 1.5-1*x(i), b(i));
70 c=r*[1 0 0]+g*[0 1 0]+b*[0 0 1];
71 c=min(max(0,c),1);
72 %colormap(c);
73 % ----------------------------------------------------

  ViewVC Help
Powered by ViewVC 1.1.22