[AstroPy] DS9 color tables in Python

Peter Teuben teuben at astro.umd.edu
Tue Mar 31 09:01:00 EDT 2015


On 03/31/2015 08:25 AM, Thomas Robitaille wrote:
> On 31 March 2015 at 14:00, Peter Weilbacher <pweilbacher at aip.de> wrote:
>> Dear all,
>>
>> has anyone succeeded to set up DS9-like color tables for plotting in
>> Python? I'm specifically interested in "heat", "sls", "hsv", and "b".
>>
>> I know that matplotlib defines somewhat similar tables, but e.g.
>> "gist_heat" is just too different from DS9's (and skycat's) heat...
> If this doesn't exist, this might be a good addition to
> astropy.visualization or pyds9!
>
> Tom


Since I had done something similar in a long ago past, I had a quick peek
at the source distro of ds9.   I was surprised to see this part documented
very lightly (if at all), but the "obvious" code to look at is in
    saods9/saotk/colorbar/default.C
where a series of

  red.append(new LIColor(0,0));
  red.append(new LIColor(1,1));

  green.append(new LIColor(0,0));
  green.append(new LIColor(1,1));

  blue.append(new LIColor(0,0));
  blue.append(new LIColor(1,1));

create a colortable.   The SLS color scheme, which happens to
be my favorite, does this in RGB space:

  colors.append(new RGBColor(0.000000, 0.000000, 0.000000));
  colors.append(new RGBColor(0.043442, 0.000000, 0.052883));
  colors.append(new RGBColor(0.086883, 0.000000, 0.105767));
  colors.append(new RGBColor(0.130325, 0.000000, 0.158650));
...
  colors.append(new RGBColor(1.000000, 1.000000, 1.000000));
  colors.append(new RGBColor(1.000000, 1.000000, 1.000000));
  colors.append(new RGBColor(1.000000, 1.000000, 1.000000));

others are done programmatically (check out HSV )

I NEMO and GIPSY these live as ascii tables with 256 entries of RGB
scaled 0..1, and I checked a few and the ds9 ones seem to match
the ones I see in GIPSY or NEMO. (NEMO/data/lut or GIPSY/dat/lut)

The ds9 codebase also has some yacc & lex parsing, i'm not clear
if that's still used. Clearly the distribution doesn't contain these
LUT ascii type files. If we're interested in persuing this, we should
check with Bill Joye about the best approach to scrape it the right
way.

My old notes from 2003 tell me that ds9 can read my LUT/RGB ascii tables,
but I cannot find this in the current ds9 (7.3.x)
http://carma.astro.umd.edu/nemo/man_html/lut.5.html

peter








More information about the AstroPy mailing list