Skip to content
Snippets Groups Projects
setcolortable.pro 5.69 KiB
pro wab_color,red,green,blue
 red = [  0, 70,140,121,102, 82, 63, 47, 31, 15, $
          0, 43, 86,130,173,216,255,255,255,255, $
        255,216,201,186,170,155,140,163,186,209, $
        232,245,255]
 green =[255,255,255,216,178,140,102,140,178,216,$
         255,255,255,255,255,255,255,235,216,197,$
         178,140,132,124,117,109,102, 81, 61, 40,$
          20, 10,  0]
 blue = [  0,  0,  0, 63,127,191,255,255,255,255,$
         255,255,255,255,255,255,127, 95, 63, 31,$
           0,  0, 12, 25, 38, 51, 63, 51, 38, 25,$
          12,  6, 0]

 x     = (n_elements(red)-1)*findgen(!d.table_size)/(!d.table_size-1)
 red   = interpolate(red,x)
 green = interpolate(green,x)
 blue  = interpolate(blue,x)

end


pro ddt_color,r,g,b

  r = [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3, 15,$
      29, 42, 56, 69, 82, 96,109,123,136,149,153,153,153,153,153,153,$
     153,156,165,174,183,192,200,209,218,227,236,245,254,255,255,255,$
     255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,$
     255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,$
     255,255,255,255,255,255,255,255,255,254,252,249,246,243,240,237,$
     234,231,229,226,223,222,222,222,222,222,222,222,221,220,220,219,$
     219,219,218,218,217,217,216,216,216,216,216,216,216,216,216,214,$
     210,207,204,201,197,194,190,187,184,181,178,178,178,178,178,178,$
     178,178,176,173,170,167,164,161,159,156,153,150,161,170,200]

  g = [0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  5, 16, 27, 38, 49, 60, 71, 82, 93,104,115,127,127,$
     127,127,127,127,127,127,131,138,145,151,158,165,171,178,185,191,$
     198,204,204,204,204,204,204,204,204,204,204,204,204,204,204,204,$
     204,204,204,204,204,204,204,204,204,204,204,203,200,199,196,194,$
     192,189,187,185,182,180,178,178,178,178,178,178,178,178,179,186,$
     193,199,206,213,219,226,233,240,246,253,255,255,255,255,255,255,$
     255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,$
     255,255,255,255,250,243,237,230,223,217,211,204,198,191,184,180,$
     180,180,180,180,180,180,180,172,162,153,144,134,125,116,107, 97,$
      88, 79, 74, 74, 74, 74, 74, 74, 74, 73, 67, 60, 53, 47, 41, 34,$
      27, 21, 15,  8,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0, 32,  0,  0]

  b =[50,130,150,150,150,150,150,150,150,150,150,150,150,150,$
     151,157,164,171,177,184,190,197,203,210,217,223,225,225,225,225,$
     225,225,225,225,228,231,233,235,238,241,244,246,249,252,255,255,$
     255,255,255,255,255,255,251,246,242,238,233,229,224,220,215,211,$
     207,204,204,204,204,204,204,204,204,193,182,171,160,148,138,126,$
     115,104, 93, 82, 76, 76, 76, 76, 76, 76, 76, 75, 68, 62, 55, 48,$
      41, 35, 28, 21, 15,  8,  2,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,$
       0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  0,  3, 22, 41, 59,$
      78, 97,115,134,154,172,191,210,216,216,216,216,216,216,216,214,$
     210,207,204,201,197,194,190,187,184,181,178,178,178,178,178,178,$
     178,178,176,173,170,167,164,161,159,156,153,150,161,170,200]

   x     = (n_elements(r)-1)*findgen(!d.table_size)/(!d.table_size-1)
   r   = interpolate(r,x)
   g = interpolate(g,x)
   b  = interpolate(b,x)
end



pro wind_direction,red,green,blue
  ;         S    W    N     E    S
  red   = [255, 225,   0,    0, 255]
  green = [  0, 255,   0,  255,   0]
  blue  = [  0,   0, 255,    0,   0]

  x = (n_elements(red)-1)*findgen(!d.table_size)/(!d.table_size-1)
  red = interpolate(red,x)
  green = interpolate(green,x)
  blue = interpolate(blue,x)

end


pro get_predefined_ct,n,r,g,b
  loadct, (n > 0)
  TVLCT,r,g,b,/GET
end



pro SetColorTable,CTNumber,ncolors=ncolors
  case CTNumber of
    41: wab_color,r,g,b
    42: ddt_color,r,g,b
    51: wind_direction,r,g,b
    else: get_predefined_ct,CTNumber,r,g,b
  endcase

  n = !d.table_size-2
  x = 1.0+n*findgen(n)/(n-1)
  r = interpolate(r,x)
  g = interpolate(g,x)
  b = interpolate(b,x)
  if (keyword_set(ncolors)) then begin
    if ((ncolors gt 0) and (ncolors lt n)) then begin
      xmax = max(x,min=xmin)
      dx1 = (xmax-xmin)/ncolors
      x1 = xmin + dx1*findgen(ncolors) + dx1/2.0
      x2 = xmin + (xmax-xmin)*findgen(ncolors)/(ncolors-1)
      r2 = interpolate(r,x2)
      g2 = interpolate(g,x2)
      b2 = interpolate(b,x2)
      for i=0,ncolors-1 do begin
        index = where(abs(x1[i]-x) le dx1/2.0,count)
        if (count ne 0) then begin
          r[index] = r2[i]
          g[index] = g2[i]
          b[index] = b2[i]
        endif
      endfor
    endif
  endif
  r = [0,r,!d.table_size-1]
  g = [0,g,!d.table_size-1]
  b = [0,b,!d.table_size-1]
  TVLCT,r,g,b
  !P.COLOR = 0
  !P.BACKGROUND = !d.table_size-1
end