;+
; NAME: sotsp_getcolors
;
; PURPOSE: Returns color table (and optionally loads it) as described by the
;          particular switch that is set. If multiple switches are set, or no
;          switches are set, the result is a grayscale color map. 
;
; CALLING SEQUENCE: sotsp_getcolors,rgb_table=rgb_table[,/load],[/cyclic|/hmi]
;
; INPUTS: (none)
;
; OUTPUTS: rgb_table - a variable in which to return the red, green, and blue
;                      indices of the desired color table as a 256x3-byte
;                      array, analogous to the same keyword for IDL's loadct
;
; KEYWORD PARAMETERS: load - if set, will load the color table
;                     cyclic - if set, will load an unsaturated cyclic color
;                              table appropriate for plotting azimuth angles
;                              (this is the CET_C2 table from
;                              https://colorcet.holoviz.org/user_guide)
;                     hmi - if set, will load the HMI team's color table for
;                           plotting line-of-sight or radial magnetic fields,
;                           works best if the field is scaled between
;                           +/-1500 Mx/cm^2), more info at:
;                           http://jsoc.stanford.edu/data/hmi/HMI_M.ColorTable.pdf
;
; EXAMPLE: sotsp_getcolors,rgb_table=rgb,/cyclic
;                will return RGB color table for azimuth angle in the
;                rgb variable)
;          sotsp_getcolors,/load,/cyclic
;                will make the RGB color table for the azimuth angle active
;
; MODIFICATION HISTORY:
;    2021 Jan  7 - M.DeRosa - created
;
;-

pro sotsp_getcolors,rgb_table=rgb_table,load=load,cyclic=cyclic,hmi=hmi

  ;  which switches are set?
  qnum=[keyword_set(cyclic),keyword_set(hmi)]

  ;  grayscale is the default color table returned
  rgb_table=rebin(reform(bindgen(256),[256,1]),[256,3])

  ;  change to new color table if it's one of the recognized quantities
  if total(qnum) eq 1 then case 1 of

    keyword_set(cyclic): begin  ;  cyclic table for azimuth angles
      rgb_table=byte([[239,241,242,243,245,246,246,247,248,249,249,250,250,250,251,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,251,251,251,251,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,251,251,251,250,250,249,248,247,245,244,242,241,239,237,234,232,230,227,225,222,219,216,214,211,208,205,202,199,196,193,190,187,184,181,178,175,172,169,166,163,160,157,154,151,148,145,141,138,135,132,129,125,122,119,115,112,108,105,101,98,94,90,86,83,79,75,72,68,65,62,59,56,54,52,51,50,50,50,50,51,53,54,56,57,59,60,62,63,64,65,66,67,68,68,69,69,69,69,69,69,68,68,67,66,65,64,63,62,60,59,57,56,54,52,51,49,48,47,45,44,43,42,42,41,40,39,39,38,38,37,37,36,36,37,37,38,40,41,44,46,49,52,55,59,62,66,69,73,77,80,84,87,90,94,97,100,103,106,109,112,115,117,120,123,126,128,131,134,137,140,143,145,148,152,155,158,161,164,167,171,174,177,181,184,187,191,194,197,200,203,207,210,213,216,219,221,224,227,229,231,233,236,237], $
                      [85,87,90,93,95,98,101,104,107,111,114,117,120,123,126,129,132,135,138,141,144,147,149,152,155,158,160,163,166,168,171,173,176,178,181,183,185,188,190,192,195,197,199,201,204,206,208,210,212,214,216,218,221,223,224,226,228,230,231,233,234,235,236,237,238,238,238,239,238,238,238,237,237,236,235,234,233,232,231,230,229,228,227,226,225,224,223,222,221,220,218,217,216,215,214,213,212,211,210,208,207,206,205,204,203,202,200,199,198,197,196,195,194,192,191,190,189,188,186,185,184,183,181,180,179,177,176,174,173,171,169,168,166,164,163,161,159,157,155,153,152,150,148,146,144,142,140,138,137,135,133,131,129,127,125,123,121,120,118,116,114,112,110,108,106,104,102,100,97,95,93,91,88,86,83,81,78,76,73,70,67,64,62,59,56,53,50,47,44,41,39,36,34,32,30,29,28,27,27,27,27,28,28,29,31,32,33,35,36,38,39,41,42,44,45,46,48,49,50,52,53,54,55,56,57,58,59,60,61,62,62,63,64,64,65,65,66,66,67,67,68,68,69,69,70,70,71,72,72,73,75,76,77,79,81,83], $
                      [242,240,239,237,235,233,231,229,226,224,222,219,217,214,211,209,206,203,201,198,195,192,190,187,184,181,179,176,173,170,167,165,162,159,156,153,150,147,144,141,138,135,132,129,126,123,120,117,113,110,107,103,100,96,92,88,85,81,77,73,69,65,61,57,53,50,46,43,40,37,35,33,31,29,27,26,25,24,24,23,22,22,21,21,21,20,20,19,19,19,18,18,18,17,17,17,16,16,16,15,15,15,14,14,14,13,13,13,13,12,12,12,12,12,12,12,13,14,15,16,18,20,22,25,27,30,33,37,40,44,47,51,55,59,63,66,70,74,78,82,86,89,93,97,100,104,107,111,114,118,121,125,128,132,135,138,142,145,148,151,155,158,161,164,167,170,173,176,179,182,185,187,190,193,195,198,200,203,205,208,210,213,215,217,219,222,224,226,228,229,231,233,234,236,237,238,239,240,241,242,242,243,243,244,244,245,245,246,246,246,247,247,247,248,248,248,249,249,249,250,250,250,250,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,250,250,250,250,250,249,249,249,248,248,247,246,245,244,243]])
    end

    keyword_set(hmi): begin  ;  HMI team's color table for Blos or Br
      rgb_table=byte([[137,140,142,144,149,151,154,158,161,163,167,170,172,175,179,182,184,188,191,193,195,200,202,205,209,212,214,218,221,223,226,230,232,235,239,242,244,248,251,255,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,199,181,154,95,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,200,197,194,191,189,186,183,181,178,175,173,170,167,165,162,159,157,154,151,148,146,143,140,138,135,132,130,127,124,122,119,116,114,111,108,105,103,100,97,95,92,89,87,84,81,79,76,73,71,68,65,63,60,56,52,49,45,42,38,35,31,28,24,21,17,14,10,7,3,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,1,2,4,4,7,8,10,11,14,14,17,17,20,20,23,23,26,28,28,31,31,33,35,35,38,40,42,42,45,45,47,49,51,52,54,56,56,59,61,63,65,67,70,72,75,77,80,82,85,87,90,92,95,97,99,101,104,106,108,111,113,115,117,120,122,124,127,129,131,134,136,138,140,143,145,147,150,152,154,157,159,161,163,166,168,170,173,175,177,179,182,184,186,189,191,193,196,198,200,202,205,207,209,212,214,216,219,103,111,120,129,138,147,156,165,174,183,192,201,210,219,228,237,246,255,200,181,154,129,120,127,135,143,151,159,167,175,183,191,199,207,215,223,231,239,247,255,200,198,196,194,192,190,188,186,184,183,181,179,177,175,173,171,169,168,166,164,162,160,158,156,154,152,151,149,147,145,143,141,139,137,136,134,132,130,128,126,124,122,120,119,117,115,113,111,109,107,105,104,101,98,96,93,90,88,85,82,80,77,74,72,69,66,64,61,58,56,54,52,51,49,47,45,42,42,40,38,35,35,33,31,28,28,26,23,23,20,20,17,17,14,13,11,10,8,4,4,2,1,0,0,0,0,0,0], $
                      [20,17,17,17,17,17,16,16,14,14,14,14,13,13,11,11,11,11,10,10,8,8,8,8,7,7,4,4,4,4,4,4,2,2,2,2,1,1,0,0,2,4,7,10,13,16,19,22,25,28,31,34,37,40,42,45,48,50,53,56,59,61,64,67,70,72,75,78,81,83,86,89,92,94,97,100,103,105,108,111,114,116,119,122,124,127,130,133,135,138,141,144,146,149,152,155,157,160,163,166,168,171,174,177,179,182,185,188,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,130,166,167,104,14,18,23,27,32,36,41,46,50,55,59,64,69,73,78,82,87,92,255,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,254,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,253,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,252,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,251,246,244,239,237,232,228,226,221,219,214,211,207,204,200,195,193,188,186,182,179,175,172,168,165,161,158,154,149,147,142,140,135,133,121,109,96,84,73]])
    end

    else: ;  do nothing and stick with grayscale
  endcase

  ;  load color table
  if keyword_set(load) then tvlct,rgb_table

end

