Saturday, May 3, 2014

Script: Colormaps.gs; very easily create elegant color scales for your plots using GrADS

 NEW VERSION AVAILABLE HERE:
Version 2

If you are a frequent visitor to this site you probably know that I focus a lot of my effort into color scales.  I often reference the color.gs script as a must have script in ones script library.  I have additionally added the script colorset.gs to the script library for use with common remote sensing color scales.  This script here is similar to colorset.gs, but different in the sense that it gives the user control as to what number scale the color map will be set to.  colormap.gs currently includes 21 color scales (with the option of reversing them).  These scales are shown below.

Colorscales included in colormaps.gs

Optional Arguments for colormaps.gs
  • -demo             - Pulls up Demo page
  •  -flipped          - Reverses direction of color scale
  •  -name/map     - chooses colormap
  •  -levels/l          - sets scale: max min int
  • -help                - Pulls up help page (includes full list of color maps)

Example: Open WRF data and plot the 2 meter dew point using the  reversed "ocean" color map

  'sdfopen
http://nomads.ncep.noaa.gov:9090/dods/hiresw/hiresw20140503/hiresw_eastarw_00z'
  'set gxout shaded'
  'clear'
  'set mpdset hires'
  ' colormaps -flipped -l 265 310 1 -map ocean'
  'd dpt2m'

  'cbar'

This series of commands will produce the following image.

2m Dew Point using "Ocean" colormap

This is the first version, so check for bugs and please report any you find!
Enjoy!




5 comments:

  1. gorgeous! it make grads more matplotlib-style

    ReplyDelete
  2. It'd be nice if I can specify individual color levels, in addition to min/max/int.

    ReplyDelete
  3. I need your hepl when I run colorsmap.gs. I get a trouble in GrADS, the problem is:
    "Unable to locate ENDIF statement for the IF statement at line 11
    In file colormaps.gs"

    ReplyDelete
    Replies
    1. How are your calling the script? I am interested to find out if this is a bug. I am currently working on a newer version that includes more color scales and options to specify levels. Also there appears to be an issue with setting the color levels that I am working out. It would be nice to know if there is another bug I need to check out.

      Delete