Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

GMT Tutorial Presentation

Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

GMT Tutorial

2012

Sebastian Rost
Setup to run GMT
Please check if your ~/.cshrc file contains the following line:

# for GMT4.1
set path = ( $path /nfs/see-fs-01_app1/GMT4.1/bin )‫‏‬

You can do this by opening this by opening this file using your favourite
editor. E.g.:

( earsro-see-gw-01.leeds.ac.uk)37% nedit ~/.cshrc

If you made any changes to your ~/.cshrc file you have to reread it, so that the
computer knows about the changes. This takes only affect in the current konsole
where you type the source command.

(earsro-see-gw-01.leeds.ac.uk)38% source ~/.cshrc


Global Seafloor Topography from Satellite Altimetry:
http://www.ngdc.noaa.gov/mgg/image/seafloor.html
DIGITAL GLOBEs (from UC San Diego):
http://topex.ucsd.edu/marine_topo/globe.html
Getting help

(1) DON'T ASK ME

(2) man gmtcommand (e.g. psxy)‫‏‬

(3) GMT home-page


http://gmt.soest.hawaii.edu/
Please copy the scripts for this tutorial from my webpage

http://homepages.see.leeds.ac.uk/~earsro/gmt_tutorial.html

and the contents of ~earsro/GMT_Tutorial/data to a directory in


your home directory:

(earsro-see-gw-01.leeds.ac.uk)39% cd

(earsro-see-gw-01.leeds.ac.uk)40% cp -r ~earsro/GMT_Tutorial/data .
map_basic.csh

#!/bin/csh
pscoast -R-180/180/-70/70 –JM0/14/7 -Ba60g30f15/a30g30f15WSen \
-X0.5 -Y2.0 -Dc -S100/100/200 -G100/205/100 -W1/0/255/0 \
-P -K >! map1.ps

awk '{print $7,$6}' < data/world_EQ.dat >! eq.xy

psxy eq.xy -R -JM -Sc0.075i -G255/0/0 -W2 -O >> map1.ps

gs -sDEVICE=x11 map1.ps
The general GMT command structure is:

gmt_command (options) > outputfile

-Rwest/east/south/north specifies the region of interest


-Jparameters selects the map projection
-Btickinfo specifies the tick marks on the map
-X shifts plot in X direction
-Y shifts plot in Y direction
-Dresolution defines the map resolution
-Sfill sets painting of 'wet' areas
-Gfill set painting of 'dry' areas
-Wpen defines which pen to use for drawing
-P selects portrait mode (default landscape)‫‏‬
-O tells GMT to add output to the same plot
-K tells GMT that more PS is koming
Adding lines

psxy -R -JX -G255/0/0 -W3/255/255/0 \


-L -O -K << END >> $outfile
-12.0 49.0
3.0 49.0
3.0 59.0
-12.0 59.0
END
Adding text to GMT

pstext -R -JM -N -G0/0/255 -D-0.5/0 -O << stopit >> $outfile


-19 50 20 90 4 CM Latitude
5 26 20 0 4 CM Longitude
5 67 10 0 4 CM Groovy Map
stopit

There are 3 lines of text instruction, and they are of the format:
x y s a f j text string
where

x = x location of the text string


y = y location of the text string
s = size of text in points
a = angle of text, in degrees counter clock wise
f = font number (type in a terminal window "pstext -L" to see the font options)
j = justification (BL = bottom left, TR= top right, CM=center middle, etc)
text string = the text to be displayed.
Adding more information

Making colorscales

makecpt -Crainbow -T0/700/50 -Z >! color.cpt


# cpt file created by: makecpt -Crainbow -T0/700/50 -Z
#COLOR_MODEL = RGB
#
0 255 0 255 50 164 0 255
50 164 0 255 100 73 0 255
100 73 0 255 150 0 18 255
150 0 18 255 200 0 109 255
200 0 109 255 250 0 201 255
250 0 201 255 300 0 255 219
300 0 255 219 350 0 255 127
350 0 255 127 400 0 255 36
400 0 255 36 450 54 255 0
450 54 255 0 500 146 255 0
500 146 255 0 550 237 255 0
550 237 255 0 600 255 182 0
600 255 182 0 650 255 91 0
650 255 91 0 700 255 0 0
B 0 0 0
F 255 255 255
N 128 128 128
The color scale will be written to the file color.cpt and can then be used to
color the depth of the earthquakes:

awk '{print $7,$6,$8}' < data/world_EQ.dat >! eq.xy

psxy eq.xy -R -JM -Sc0.075i -Ccolor.cpt -W2 -O >> map1.ps


Multiple Plots
Orthographic Projection -Jg

#! /bin/csh
set output = globe.ps
#-------------------------------------------------------------
# run the GMT program "pscoast" to make coastlines, and do it
# on a globe and let's center it on lat=-10.5 lon=-81 deg, and
# the size: R=1.0 inch.
#-------------------------------------------------------------

pscoast -R0/360/-90/90 -Jg-80/-10/1.8/0 -G60/210/160 \


-S225/250/225 -Dc -Bg30 -W3/0/0/0 -Y8.0 -P >! $output
#--------------------------------------------------------------
# run ghostscript to plot our postscript output file
#-------------------------------------------------------------

gs -sDEVICE=x11 $output
Adding the new plot

#-------------------------------------------------------------
# NEW PLOT!!!!
# run pscoast to make the zoom cartesian map, off to the
# lower right
#-------------------------------------------------------------

pscoast -R-100/-60/-10/20 –JM0/14/7 -G60/210/160 -Dc \


-Ba10f10g10WSen -W4/0/0/100 -O -X2.0 -Y-2.0 >> $output
Contouring
#!/bin/csh
# FILE: c.contour0
# Purpose: Make a contour map based on the data in the file
# osu91a1f_16.grd
# GMT progs: pscoast, grdcontour
#
# this is a stripped down version of the GMT example 1 on
# the web

# define the output filename


set outfile = contour0.ps

# plot the coast, color the land (-G) w/ light gray


pscoast -R-180/180/-90/90 -JH0/6i -X1.25i -Y5.5i -Bg30 \
-Dc -G200 -P -K >!$outfile

# contour the geoid data set. The -C flag is for contour


# interval
grdcontour data/osu91a1f_16.grd -R -JH -C10 -O >> $outfile

# plot the output file


gs -sDEVICE=x11 $outfile

You might also like