function J=earthc(nbase)
%function J=ssec(nbase)
% ssec color table
%
% Nicked from ncview
%

if nargin < 1
   nbase = size(get(gcf,'colormap'),1);
end
rgb =[ ...
   0.0000000e+00   0.0000000e+00   2.2527473e-01 ...
   0.0000000e+00   1.5065580e-02   2.3484580e-01 ...
   0.0000000e+00   3.0131159e-02   2.4441687e-01 ...
   0.0000000e+00   4.5196739e-02   2.5398795e-01 ...
   0.0000000e+00   6.0262318e-02   2.6355902e-01 ...
   0.0000000e+00   7.5327898e-02   2.7313010e-01 ...
   0.0000000e+00   9.0393477e-02   2.8270117e-01 ...
   0.0000000e+00   1.0545906e-01   2.9227224e-01 ...
   0.0000000e+00   1.2052464e-01   3.0184332e-01 ...
   0.0000000e+00   1.3559022e-01   3.1141439e-01 ...
   0.0000000e+00   1.5065580e-01   3.2098547e-01 ...
   0.0000000e+00   1.6572138e-01   3.3055654e-01 ...
   0.0000000e+00   1.8078695e-01   3.4012761e-01 ...
   0.0000000e+00   1.9585253e-01   3.4969869e-01 ...
   0.0000000e+00   2.1091811e-01   3.5926976e-01 ...
   0.0000000e+00   2.2598369e-01   3.6884084e-01 ...
   0.0000000e+00   2.4104927e-01   3.7841191e-01 ...
   0.0000000e+00   2.5611485e-01   3.8798298e-01 ...
   0.0000000e+00   2.7118043e-01   3.9755406e-01 ...
   0.0000000e+00   2.8624601e-01   4.0712513e-01 ...
   0.0000000e+00   3.0131159e-01   4.1669621e-01 ...
   0.0000000e+00   3.1637717e-01   4.2626728e-01 ...
   0.0000000e+00   3.3144275e-01   4.3583836e-01 ...
   0.0000000e+00   3.4650833e-01   4.4540943e-01 ...
   0.0000000e+00   3.6157391e-01   4.5498050e-01 ...
   0.0000000e+00   3.7663949e-01   4.6455158e-01 ...
   0.0000000e+00   3.9170507e-01   4.7412265e-01 ...
   0.0000000e+00   4.0677065e-01   4.8369373e-01 ...
   0.0000000e+00   4.2183623e-01   4.9326480e-01 ...
   0.0000000e+00   4.3690181e-01   5.0283587e-01 ...
   0.0000000e+00   4.5196739e-01   5.1240695e-01 ...
   2.5617284e-02   7.3223443e-01   0.0000000e+00 ...
   5.1234568e-02   7.0000000e-01   0.0000000e+00 ...
   7.6851852e-02   6.6776557e-01   0.0000000e+00 ...
   1.0246914e-01   6.3553114e-01   0.0000000e+00 ...
   1.2808642e-01   6.0329670e-01   0.0000000e+00 ...
   1.5370370e-01   5.7106227e-01   0.0000000e+00 ...
   1.7932099e-01   5.3882784e-01   0.0000000e+00 ...
   2.0493827e-01   5.0659341e-01   0.0000000e+00 ...
   2.3055556e-01   4.7435897e-01   0.0000000e+00 ...
   2.5617284e-01   4.4212454e-01   0.0000000e+00 ...
   2.8179012e-01   4.0989011e-01   0.0000000e+00 ...
   3.0740741e-01   3.7765568e-01   0.0000000e+00 ...
   3.3302469e-01   3.4542125e-01   0.0000000e+00 ...
   3.5864198e-01   3.1318681e-01   0.0000000e+00 ...
   3.8425926e-01   2.9476406e-01   0.0000000e+00 ...
   4.0987654e-01   2.7634131e-01   0.0000000e+00 ...
   4.3549383e-01   2.5791855e-01   0.0000000e+00 ...
   4.6111111e-01   2.3949580e-01   0.0000000e+00 ...
   4.2564103e-01   2.2107304e-01   0.0000000e+00 ...
   3.9017094e-01   2.0265029e-01   0.0000000e+00 ...
   3.5470085e-01   1.8422754e-01   0.0000000e+00 ...
   3.1923077e-01   1.6580478e-01   0.0000000e+00 ...
   2.8376068e-01   1.4738203e-01   0.0000000e+00 ...
   2.4829060e-01   1.2895928e-01   0.0000000e+00 ...
   2.1282051e-01   1.1053652e-01   0.0000000e+00 ...
   1.7735043e-01   9.2113769e-02   0.0000000e+00 ...
   1.4188034e-01   7.3691015e-02   0.0000000e+00 ...
   1.0641026e-01   5.5268261e-02   0.0000000e+00 ...
   7.0940171e-02   3.6845507e-02   0.0000000e+00 ...
   3.5470085e-02   1.8422754e-02   0.0000000e+00 ...
   0.0000000e+00   0.0000000e+00   0.0000000e+00 ...
] ;



rgb=reshape(rgb,3,prod(size(rgb))/3);
ncol=size(rgb,2);
ncol2=ncol-2;



J=[];
for i=1:nbase
   rind=1+(ncol2)*(i-1)/(nbase-1);
   l0=max(1,min(floor(rind),ncol-1));
   l1=max(1,min(l0+1       ,ncol-1));
   w0=l1-rind;
   w1=1.-w0;
	if (l1>=32) 
		l0=l0+1;
		l1=l1+1;
	end

   r=w0*rgb(1,l0)+w1*rgb(1,l1);
   g=w0*rgb(2,l0)+w1*rgb(2,l1);
   b=w0*rgb(3,l0)+w1*rgb(3,l1);
   J=[J ; r g b];
   %disp([num2str(i) ' '  num2str(rind) ' '  num2str(l0) ' ' num2str(l1) ' '  num2str(w0) ' ' num2str(w1)])
end
