Re: colormaps and file formats

From: David Ian Brown (dbrown AT ucar.edu)
Date: Wed Jan 12 2005 - 13:39:38 MST

  • Next message: Derrick Snowden: "Re: colormaps and file formats"

    Mark, Derrick,

    Actually, although it has never been properly documented, you can set
    an environment
    variable called 'NCARG_COLORMAP_PATH' with a colon-separated list of
    directories that
    will cause NCL/PyNGL to search for colormaps in these directories and
    load them. It will
    look for any files with extensions '.rgb', '.gp', or '.ncmap' and try
    to interpret them as colormaps
    when a workstation is first created. Note, however, that this path
    actually replaces the default path
    so it should always include $NCARG_ROOT/lib/ncarg/colormaps as one of
    its directories.

    Derrick, see below. I have tried to answer some of your questions.
      -dave

    On Jan 12, 2005, at 10:20 AM, Mark J. Stevens wrote:

    > Hi,
    >
    > I have written a function that is included in contributed.ncl that
    > allows you
    > to "roll your own" colormaps with your own rgb file. To use this
    > here is an example. The rgb file and a ncl script for viewing the
    > colors
    > are attached.
    >
    > example of use in ncl script:
    > .....
    > cmap = RGBtoCmap("blueyellowred.rgb")
    > gsn_define_colormap(wks,cmap)
    > ....
    >
    > I use to use GMT in grad school, I think you could easily modify those
    > rgb files to use with ncl.
    >
    > Mark Stevens
    >
    > On Wednesday 12 January 2005 07:51 am, Derrick Snowden wrote:
    >> Hi all,
    >>
    >> I'm interested in writing a conversion script to convert GMT style
    >> *.cpt
    >> colormap files to a file format useable by NCL and PyNGL. First of
    >> all,
    >> has anyone already done this? If so are you willing to share? There
    >> are
    >> some good default colormaps in GMT and there is a great site
    >> (cpt-city at
    >> http://craik.shef.ac.uk/cpt-city/index.html) with hundreds of user
    >> contributed extensions. A script to go between these different file
    >> formats would be very useful. I have a few questions as I'm getting
    >> started...
    >>
    >> 1. NCL/PyNGL ships with colormaps in the
    >> $NCARG_ROOT/lib/ncarg/colormaps
    >> directory. In my installation, I have *.ncmap, *.gp and *.rgb files.
    >> For
    >> some colormaps there are multiple file type versions of the same map.
    >> Which is the preferred file format and why? Is there a trick to the
    >> format
    >> or are they just rgb (0-255) triplets on each line?

    .ncmap files come from the ncview application. The .rgb and .gp files
    are originally from
    other applications, I forget which (IDL maybe is one).
    These formats are similar enough that NCL reads them all using a single
    routine.
    Basically, it ignores any line of the file where the first non-space
    character is anything other than a digit.
    There is no trick to the format. It is just, as you suggest, rgb
    triplets.
    The range can be either 0-255 or 0-65535.

    >>
    >> 2. If I remember correctly, the first entry in the colormap is the
    >> default
    >> background color, and the second entry is the default foreground
    >> color.
    >> Which index entry provides the default color for the various fill
    >> colors
    >> such as the land fill and the inland waters filll? I constantly
    >> screw that
    >> up. If one uses the resource gsnSpreadColors = True, are the
    >> foreground/background colors used or not?

    Up to 254 colors will be read from the colormap file. Indexes 0 and 1,
    background and foreground,
    must be defined separately, using wkBackgroundColor and
    wkForegroundColor. So the
    colors read from the colortable file are assigned indexes starting from
    2, and
    the gsnSpreadColors functionality ignores background and foreground.

    >>
    >> 3. Where, other than $NCARG_ROOT/lib/ncarg/colormaps, can these files
    >> be
    >> stored so they are available in scripts? If I'm using a network
    >> installation of ncl and don't have write permission in the directory
    >> above?
    >>

    See above.

    >> 4. What is a good rule of thumb for the length of a colormap, given
    >> that
    >> one can interpolate etc? (For this purpose I am talking about
    >> colormaps
    >> used for continuous variables not categorical variables.)
    >>

    For NCL, each color that you want in the colormap must be specified
    explicitly. There is
    currently no interpolation of colors such as GMT provides.
    Hope this helps.
      -dave

    >> Thanks for any help you can give...
    >>
    >> Best,
    >> Derrick
    >
    > --
    > Mark J. Stevens
    > Climate and Global Dynamics Division
    > NCAR Mesa Laboratory, Room 320c
    > ph: 303-497-1707 stevens@ucar.edu
    > http://www.cgd.ucar.edu/~stevens
    > <show_colors.ncl><blueyellowred.rgb>___________________________________
    > ____________
    > ncl-talk mailing list
    > ncl-talk@ucar.edu
    > http://mailman.ucar.edu/mailman/listinfo/ncl-talk

    _______________________________________________
    ncl-talk mailing list
    ncl-talk@ucar.edu
    http://mailman.ucar.edu/mailman/listinfo/ncl-talk



    This archive was generated by hypermail 2b29 : Thu Jan 13 2005 - 07:43:41 MST