Table of Contents
GMT is a collection of programs developed by Wessel and Smith (1991) that facilitate the processing and plotting of scientific data. As the name suggests, the package is at it best when making maps, although familiarity with the package allows complex mathemtatical operations on large volumes of data. The GMT package is accessed using the UNIX computers, although it could be ported to PC's and Mac's (the command line interface is not very mac-like and would cause headaches in that port.).
For details, refer to the online manual pages on GMT and the manuals that are printed out and available in the Geoscience IO room. In particular, look through the "cookbook" section to get a feel for the potential of the package.
Give Credit to the Authors
If you use the package for calculations, you should cite:
Wessel, P. and W. H. F. Smith, New version of the Generic Mapping Tools released, EOS Trans. Am. Geophys. Union, 76, 329, 1995.
Wessel, P. and W. H. F. Smith, Free software helps map and display data, EOS Trans. Am. Geophys. Union, 72, 441, 445-446, 1991.
If you use it simply for drafting some figures, you should at least acknowledge Wessel and Smith's efforts since they helped you communicate your work.
Locating the Programs
The most recent version of GMT, 3.3.3, is installed in /usr/local/gmt3.3.3. Older versions are installed in other local directories under /usr/local. DO NOT COPY THE PROGRAMS! Copying the executables wastes disk space and it is stupid to copy widely-used programs tinto your home directory. If you access the "installed" or established codes, when the programs are updated, you will not fall behind because you are relying on private copies. The appropriate way to access the new versions of the programs is to add /usr/local/gmt3.3.3 to your $PATH variable. To make permanent changes to your $PATH variable, you must edit you .cshrc file, which is located in your home directory.
The output of GMT graphics programs is postscript. Postscript is a graphics programming that is the standard on modern, high-end graphics output devices. The department laser-printers and the HP color paintjet in the computer room all interpret postscript.
On the UNIX machines, postscript can be previewed using ghostscript, a commonly available, free program. Ghostscript is also available for IBM compatibles and Macintoshes. On the Mac's, any postscript can be improted into Adobe Illustrator using the Program Adobe Distiller - which is on the three Power Macintoshes in the Geoscience IO room. Tranfer the postscript to the Mac using Telnet of Fetch and drag and drop the postscript file icon onto the Distiller icon. Distiller launches and creates a file with a ".pdf" extension. Illustrator can parse this file and you can annotate the figure as well as edit any of the objects in the map.
The data format of GMT is the "netcdf" format that is one of several standard formats that scientists use to store numerical data. Before using the package to plot you own data, you must convert it to GMT format. However, to begin making maps, you can rely on the data that are available (and installed at slu) with GMT.
There are two easy ways to convert your data to "GMT" format. If you want to average a large amount of data using a nearest-neighbor gridding algorithm, use the command nearestneighbor. If you have evenly or unevenly spaced xyz triplets, store them in an ascii file, one entry per line, and use xyz2grd. If you have evenly spaced data, you can store them in ascii or binary and convert them directly using xyz2grd.
Making a Simple Map
TO run GMT, the most effective and flexible approach is to use shell scripts. Depending on your UNIX user profile, you can use either "sh" or "csh" to execute a sequence of commands, or run a sequence of programs. In general, it is best to use variables to set up the map window, since this allows easy modifification of the file for repeated use. You can look up the exact operation caused by specific command-line arguments in the GMT manual.
# # simple c-shell to generate a map of the United States # # First, define the geographic window # the specification format is w/e/s/n # set GWINDOW = "-R-130/-65/25/50" # # Next select the projection type # set PROJECTION = "-Jb-102.5/0/29.5/45.5/0.125 -V -P" # # Now I'll set the tick spacing for east-west and north-south # set ewtick = "10" set nstick = "10" # # Use the pscoast command to generate a plot of # the coastlines and state boundaries # pscoast $PROJECTION $GWINDOW -B$ewtick/$nstick -Na -Dcrude -V -K -W1 >! ps.map # # end of script #
In the end, we only executed one command to generate the postscript map. Here's what that figure looks like (after converting it to a crude bitmap, the postscript version produces very precise lines when printed):
Previewing Postscript with Ghostscript
The output of the shell script is a file called ps.map. To preview this file under X-Windows, use the command:
This command should open up a window and display a map of the United States. To exit ghostscript (gs), type "quit " at the GS> prompt in the window from which you executed the gs command. If you are using openwindows, you can also preview the file with pageview, which is often faster than ghostscript.
Important Note: For the new version of GMT you should be using a newer version of ghostscript - something like 5.5.1. Using an older version may cause gs to halt.
A More Complicated Example
Here is an example of how to combine images and line drawings, and plot a focal mechanism using a sequence of gmt commands. This script accesses a data base that right now only is available on Mantle; but that will change when Eric has time to install it is a more accessible location.
# # plot the topography, focal mechanism, and a symbol for an # earthquake # # bounds are for the grdcut (make wider than PROJ) # set BOUNDS = "-R-107/-84/11/24" set PROJ = "-Jm0.25 -R-106/-85/12/23" # # cut and filter the topographic data # grdcut /geo/GeoData/GLOBAL/global_topo.grd $BOUNDS -Gjunk.grd -V grdfilter junk.grd -D1 -Fb35 -N -V -Gxfile.grd # /bin/rm junk.grd # # compute the gradient of topography # grdgradient xfile.grd -A315 -Ggradient.grd -Nt -V # # plot the image using the shading and cpt file # us.cpt # grdimage xfile.grd -K -Cus.cpt -X2 -Y3 \ -Igradient.grd \ -B5 $PROJ -P -V >! eqtopo.ps # # draw the coast line # pscoast -Di $PROJ -W1 -O -K >> eqtopo.ps # # the focal mechanism # psvelomeca $PROJ -O -K -G255/0/0 -L -Sa0.3 -H1 -C <<EOF >> eqtopo.ps lon lat strike dip rake Mw -97.88 15.97 112 65 94 7.0 -102 15 EOF # # plot a symbol at the epicenter # psxy $PROJ -Sc -L -W1 -G255/0/0 -P -V -O <<EOF >> eqtopo.ps -97.88 15.97 0.1 EOF #
And here is the result, which can be previewed using "gs eqtopo.ps"
Top | CJA's Guide Index | Ammon's Home | Department of Geosciences
Prepared by: Charles J. Ammon,