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

if nargin < 1
   nbase = size(get(gcf,'colormap'),1);
end
rgb = [ ...
        0,0,0, 0,0,0, 1,1,0, 2,1,0, 3,2,0, 4,2,0, 5,3,0, 6,4,0,  ...
        7,4,0, 7,5,0, 8,6,0, 9,6,0, 10,7,0, 10,8,0, 11,9,0, 12,10,0,  ...
        12,11,0, 13,11,0, 14,12,0, 14,13,0, 15,14,0, 15,15,0, 16,16,0, 16,17,0,  ...
        17,18,0, 17,19,0, 18,20,0, 18,21,0, 18,22,0, 19,23,0, 19,25,0, 19,26,0,  ...
        20,27,0, 20,28,0, 20,29,0, 20,30,0, 20,31,1, 21,33,1, 21,34,1, 21,35,1,  ...
        21,36,2, 21,37,2, 21,39,2, 21,40,2, 21,41,3, 21,42,3, 21,43,4, 21,44,4,  ...
        20,46,4, 20,47,5, 20,48,5, 20,49,6, 20,50,7, 19,52,7, 19,53,8, 19,54,8,  ...
        18,55,9, 18,56,10, 18,57,10, 17,58,11, 17,59,12, 17,60,13, 16,61,14, 16,62,15,  ...
        16,63,15, 15,64,16, 15,65,17, 14,66,18, 14,67,19, 13,68,21, 13,69,22, 12,70,23,  ...
        12,71,24, 11,72,25, 11,72,26, 10,73,28, 10,74,29, 9,75,30, 9,75,32, 8,76,33,  ...
        8,76,34, 7,77,36, 7,78,37, 6,78,39, 6,79,40, 5,79,42, 5,79,43, 4,80,45,  ...
        4,80,46, 4,80,48, 3,81,50, 3,81,51, 2,81,53, 2,81,55, 2,81,56, 1,81,58,  ...
        1,81,60, 1,81,62, 1,81,63, 0,81,65, 0,81,67, 0,81,69, 0,81,71, 0,81,73,  ...
        0,80,74, 0,80,76, 0,80,78, 0,79,80, 0,79,82, 0,79,84, 0,78,86, 0,77,88,  ...
        0,77,90, 0,76,91, 0,76,93, 1,75,95, 1,74,97, 1,74,99, 2,73,101, 2,72,103,  ...
        3,71,105, 3,70,106, 4,69,108, 4,69,110, 5,68,112, 6,67,114, 6,66,115, 7,65,117,  ...
        8,64,119, 9,62,121, 10,61,122, 11,60,124, 12,59,126, 13,58,127, 14,57,129, 15,55,130,  ...
        16,54,132, 18,53,133, 19,52,135, 20,50,136, 22,49,138, 23,48,139, 25,47,140, 26,45,142,  ...
        28,44,143, 29,43,144, 31,41,145, 33,40,146, 34,39,147, 36,37,148, 38,36,149, 40,35,150,  ...
        42,33,151, 44,32,152, 46,31,153, 48,29,154, 50,28,154, 52,27,155, 54,25,156, 57,24,156,  ...
        59,23,157, 61,22,157, 63,20,158, 66,19,158, 68,18,158, 71,17,158, 73,16,159, 75,15,159,  ...
        78,14,159, 81,13,159, 83,12,159, 86,11,159, 88,10,159, 91,9,158, 94,8,158, 96,7,158,  ...
        99,6,157, 102,5,157, 104,5,156, 107,4,156, 110,3,155, 113,3,155, 115,2,154, 118,2,153,  ...
        121,1,152, 124,1,151, 127,1,150, 129,0,149, 132,0,148, 135,0,147, 138,0,146, 141,0,145,  ...
        143,0,143, 146,0,142, 149,0,141, 152,0,139, 155,0,138, 157,0,136, 160,1,135, 163,1,133,  ...
        165,1,132, 168,2,130, 171,3,128, 173,3,126, 176,4,125, 179,5,123, 181,6,121, 184,6,119,  ...
        186,7,117, 188,8,115, 191,10,113, 193,11,111, 196,12,109, 198,13,107, 200,15,105, 202,16,103, ... 
        204,18,100, 206,19,98, 209,21,96, 211,23,94, 212,24,92, 214,26,89, 216,28,87, 218,30,85,  ...
        220,32,83, 221,34,80, 223,37,78, 224,39,76, 226,41,73, 227,44,71, 229,46,69, 230,48,66,  ...
        231,51,64, 232,54,62, 233,56,60, 234,59,57, 235,62,55, 236,65,53, 237,68,51, 238,71,49,  ...
        238,74,46, 239,77,44, 240,80,42, 240,83,40, 240,86,38, 241,89,36, 241,93,34, 241,96,32,  ...
        241,99,30, 241,103,28, 241,106,27, 241,110,25, 240,113,23, 240,117,21, 239,120,20, 239,124,18];

rgb=reshape(rgb,3,prod(size(rgb))/3);
rgb=rgb/256.;
ncol=size(rgb,2);



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

   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(w0) ])
end
