Difference between revisions of "Color and graphics with GAMAP"

From Geos-chem
Jump to: navigation, search
(Non-uniform color scales in TVMAP)
Line 1: Line 1:
<span style="color:red"><big><strong>[https://geoschem.github.io/gamap-manual/GAMAP GAMAP] is now obsolete.  We recommend using [https://gcpy.readthedocs.io GCPy] for analyzing output from recent GEOS-Chem versions.  But we will preserve the GAMAP wiki documentation for reference.</strong></big></span>
On this page we list some general tips & tricks for manipulating color tables and saving to graphic file formats.  Please also see the following pages:
On this page we list some general tips & tricks for manipulating color tables and saving to graphic file formats.  Please also see the following pages:

Latest revision as of 19:07, 16 September 2022

GAMAP is now obsolete. We recommend using GCPy for analyzing output from recent GEOS-Chem versions. But we will preserve the GAMAP wiki documentation for reference.

On this page we list some general tips & tricks for manipulating color tables and saving to graphic file formats. Please also see the following pages:

--Bob Y. 16:08, 26 November 2008 (EST)



A good primer for creating and manipulating IDL color tables is: Working with color in IDL by Chris Holmes.

New color table options in GAMAP v2-12

In GAMAP v2-12 (and higher versions), the color table handling routine MYCT has been rewritten to allow you to do the following:

  • Use all of the standard IDL color tables
  • Use all of the ColorBrewer color tables
  • Use several customized color tables from previous GAMAP versions (e.g. DIAL, WhGrYlRd, etc.)

For more information, please see this document: GAMAP color tables and their basic usage.

--Bob Y. 10:38, 18 July 2008 (EDT)

Also, if you are using a monitor with a 16-bit color display, you may encounter problems when trying to create images via screengrab. Please see this post on our GAMAP bugs & fixes page for information about how to work around this.

Customizing a GAMAP color table

The best way to customize a color table is to

  1. Load a GAMAP color table with MYCT
  2. Obtain the R, G, B vectors from the color table
  3. Manipulate those as you like

Helen Wang wrote:

[I need to] change the color table in one of the figures to a discrete color bar. I looked at the Gamap color table. It seems that color table 117 could be the most useful. However, I would need to move the top two purple colors to the bottom before the two blues and exchange the positions of the two oranges and two reds. Basically, I'd like to follow the visible light spectra. Could you please tell me how to do this?

Philippe Le Sager replied:

The fastest way to do that is to get the RGB vectors and then to apply a shift on them. You could do it on the fly but this is prone to many mistake (the shift has to be applied to a limit set of indices). So I would use the last MyCt (you can get mine in ~phs/IDL/gamap2/colors/), it lets you define a user-defined color table.
To define yours, follow those steps:
   myct, 117, /no_std
   tvlct, r,g,b,/get
   print, ( transpose([[r],[g],[b]]) ) [*,0:9]
that will give you the numbers you need in three columns. Shift and put into the user-defined RGB vectors.

--Bob Y. 10:23, 6 November 2008 (EST)

Non-uniform color scales in TVMAP

Rynda Hudman wrote:

Is there a way to plot a map of values with a non-uniform scale in tvmap? I am trying to plot some gridded data of the U.S. with these intervals [0, 0.5, 1, 1.5, 2, 3, 4, 5, 6, 8, 11, 15, 20] or will I need to plot it as polyfill?

Philippe Le Sager replied:

You can just use the C_LEVELS keyword. Now it works with pixel plots too. I suggested to Eric Leibensperger to use VALUE_LOCATE, so MAP_IMAGE can still be used. Then any type of map projections can be used, unlike the POLYFILL option. He did a great job and his modifications are in the current-but-yet-to-be-released TVMAP. We will release this in a new GAMAP version soon.

--Bob Y. 16:07, 14 September 2009 (EDT)

Xterm settings for Mac OS

If you log into a Unix server from a Mac, then make sure that you set the number of colors in your Xterm to "Millions", as shown below:

Gamap xterm problem on Mac.png

If this is not set correctly, then the number of colors in the IDL color table (represented by system variable !D.TABLE_SIZE) will be less than 256, which will cause routine MYCT to halt with an error.

--Bob Y. 10:00, 13 April 2012 (EDT)

Graphics file formats

Creating PDF files


The current version of IDL (v7.x) cannot save directly to Adobe PDF format. The best way to create PDF files from IDL is to first create a PostScript file, and then use the utility ps2pdf to create a PDF file from the PostScript file. Most Unix or Linux distributions should come with a version of ps2pdf already installed.

For example:

IDL> open_device, /ps, bits=8, color, file='myplot.ps'
IDL> plot, findgen(100), color=!myct.black
IDL> close_device
IDL> spawn, 'ps2pdf myplot.ps'

This will create a file named myplot.pdf. The advantage of using PDF files is that they may be displayed from within a web page. Also, PDF files are generally smaller in size than the equivalent PostScript file.

NOTE: In GAMAP v2-15, we introduced the routine MAKE_PDF, which is a convenience wrapper for the Unix ps2pdf command. It can be used to convert several PS files in a directory to PDF.

--Bob Y. 15:07, 26 January 2012 (EST)

High-resolution PDF output

Dominick Spracklen wrote:

I am having some trouble with figures for a paper. The colour scheme in some 2D tvmap plots appears fine in my .ps file. I convert this to pdf using ps2pdf and the pdf file also looks fine. But when JGR converted it somehow it messes up. I am using a WhRd colour scheme but many of the colours come out greyish in the JGR proof.
Is there any way that I can increase the resolution (or maybe it is the ps2pdf conversion that is causing the problem?).

Philippe Le Sager replied:

A couple of GAMAP versions back, I introduced a ScaleMI keyword for TVMAP. It is passed to the Scale kwrd of Map_Image (hence ScaleMI, to differentiate from the Map_Set Scale kwrd).
Scale MI has a default of 0.02 pixels/device coordinate. When plotting 2x2.5 data we got better results (ie image mapping) with 0.04. You should try increasing that kwrd to see if that solves your problem.
If you open your PS file in Illustrator you can get (set?) the resolution. If you do not have Illustrator and are using linux, Inkscape can do similar things with the PDF.
Finally, the ps2pdf program has several options, one is /prepress for high quality printing; you could try that as well.

--Bob Y. 11:03, 9 July 2009 (EDT)

Making movies from GAMAP output

The best way to make movies with GAMAP is to save out individual frames as GIF images, and then use a 3rd-party GIF utility to concatenate those into an animated GIF.


You can obtain the GIFsicle distribution from http://www.lcdf.org/gifsicle/. When you build gifsicle, the following executables will be created:

Utility to concatenate individual GIFs into an animated GIF. Can also be used to extract individual frames from an animated GIF image.
A lightweight GIF viewer for X. It can display animated GIFs as slideshows, one frame at a time, or as animations.
Compares two GIF images for identical visual appearance

Using GIFsicle to create an animated GIF from individual GIF's:

gifsicle --delay=10 --loop *.gif > anim.gif 


You can obtain WhirlGIF from http://hpux.connect.org.uk/hppd/hpux/Networking/WWW/whirlgif-3.04

Using WhirlGIF to create an animated GIF from individual GIFs:

whirlgif -loop -time 10 -o anim.gif *.gif


  • -loop specifies that you want continually cycle between frames in an endless loop
  • -time specifies a delay between frames in units of 1/100 second
  • -o specifies the name of the output file


Philippe Le Sager wrote:

You can also use "convert" at the command line to get animated GIF. This is a powerful command line, but the basic for animated gif is:
     convert -delay 20 image.* image.gif
You need to be in the proper directory. The input images are numbered like image.01, image.02, and so on. If the image file names differ too much you will have to explicitly type them, before the output file name, which is last). The delay is the time interval. I think it is in ms.
You can get more info and tips at:

NOTE: GIFsicle, WhirlGIF, and ImageMagick have already been installed on the Harvard Linux machines.

Z-Buffer Device

Jenny Fisher wrote:

I'm having some trouble with screen2gif.pro, which in turn seems to be having trouble with tvread.pro. I am logging in remotely over the VPN, and when I try to use screen2gif.pro to do a screen capture of an image, it gets stuck and just sits there until I manually close the window, re-login, and restart IDL. Any thoughts?

Bob Yantosca replied:

I think this has got to be due to the VPN. Maybe the VPN is encrypting the network packets when trying to send the image over the network.
Instead of using the IDL X graphics device, you could try to create the image in the IDL Z-buffer. The Z buffer is like a "fake" graphics window. Instead of printing the graphics to the screen, when IDL prints something to the Z-buffer it is writing it directly to memory. Therefore you can use the Z-buffer when you are logging in remotely or when you are running an IDL job in the background or in a script.

Here is a test. This should create a GIF file.

   open_device, /z, winparam=[0,800,600]
   myct, /whrd
   tvmap, dist(20,20), /cbar
   screen2gif, 'jenny.gif'

--Bob Y. 15:09, 16 December 2008 (EST)