Generic Mapping Tools (GMT)
Generic Mapping Tools (GMT)
Maps
In this example, the first 5 represents line width, the t signifies a texture follows, the 15_15 specifies the dash and space width, and the :0 specifies that a dash is used. Alternately, -W5,0,15_15:- does the same thing.
use both K and O when putting a large number of GMT call outputs together
GMT Defaults
There are about 100 parameters which can be
adjusted individually to modify the appearance of plots or affect the manipulation of data. Each as a default value.
%gmtdefaults L
To view the list of options for each default parameter
%man gmtdefaults
Plotting Defaults
example of start of .gmtdefaults4 # GMT-SYSTEM 4.2.1 Defaults file
#-------- Plot Media Parameters -PAGE_COLOR PAGE_ORIENTATION PAPER_MEDIA = 255/255/255 = landscape = letter
#--- Basemap Annotation Parameters -ANNOT_MIN_ANGLE ANNOT_MIN_SPACING ANNOT_FONT_PRIMARY ANNOT_FONT_SIZE ANNOT_OFFSET_PRIMARY = 20 =0 = Helvetica = 14p = 0.075i
List of standard command line options. The J option sets the projection One has to look at the man page for each one as different things vary
All gmt programs plot maps through the projection command line option or switch
(even the x-y plot).
All projections give you two selections for specifying the scale
(note GMT takes the mapmakers attitude that a map has to have a predetermined/known scale nicely filling the page does not cut it.)
-Jmparameters
(Mercator [C]). Specify one of: -Jmscale or -JMwidth Give scale along equator
(1:xxxx or UNIT/degree).
-Jmlon0/lat0/scale or -JMlon0/lat0/width
Mercator Projection: One way to address plotting sphere on a plane (which is whole nother subject) Conformal (maintains shapes) Cylindrical projection
pscoast -R-130/-70/24/52 -JB-100/35/33/45/6i -B10g5:."Conic\ Projection": -N1/2p -N2/0.25p A500 -G200 -W0.25p -P >! map.ps
, rivers.
pscoast -R-130/-70/24/52 -JB-100/35/33/45/6i -B10g5:."Conic\ Projection": -N1/2p -N2/0.25p A500 -G200 -W0.25p -P >! map.ps
-A to get rid of small water/island features Albers projection (b/B) need to know something (center and standard
pscoast -R-130/-70/24/52 -JB-100/35/33/45/6i -B10g5:."Conic\ Projection: -N1/2p -N2/0.25p A500 -G200 -W0.25p -P >! map.ps
-Jblon0/lat0/lat1/lat2/scale or -JBlon0/lat0/lat1/lat2/width
Albers - Give projection center, two standard parallels, and scale (1:xxxx or UNIT/degree).
Albers
Also conformal (maintains/conserves shape) Conical projection
pscoast -R0/360/-90/90 -JG280/30/6i -Bg30/g15 -Dc -A5000 \ -G255/255/255 -S150/50/150 -P >! map.ps
azimuthal Orthographic projection (g/G) mimics looking at earth from infinite distance.
pscoast -R0/360/-90/90 -JG280/30/6i -Bg30/g15 -Dc -A5000 \ -G255/255/255 -S150/50/150 -P >! map.ps
Example 2
gmtset: To change individual GMT default parameters pscoast: Plot coastlines, lled continents, rivers, and
political borders
psxy: Plot symbols, polygons, and lines in 2-D pstext: Plot text strings psmeca: Plot focal mechanisms on maps
#!/bin/sh ###Create a basemap for the Sumatra-Andaman Island region #Set global variables Plots=../BasicInfo CPT=/usr/local/GMT4.2.0/share/cpt LATMIN=-6.2 LATMAX=16 LONMIN=90 LONMAX=106 OUTFILE=$0.ps #What does the $0 signify on this line?
#Map # Create the basic basemap using GMT coastline data pscoast -JM15 -R$LONMIN/$LONMAX/$LATMIN/$LATMAX -Ba2f1WNes -Y5 -X3 -K -P \ -Dh -A100 -N1 -W1 -G155 > $OUTFILE -D Selects the resolution of the data set ((f)ull, (h)igh, (i)ntermediate, (l)ow, (c)rude) -A Features with an area smaller than min_area in km^2 -W and G Control the fill color and line color of the land regions -N Plots political boundaries. 1 is for national boundaries, 2 is for states in the Americas
#Plot basic tectonic information, including subduction zones and volcanoes psxy $Plots/trench.right.gmt -R -JM -M -W5/0 -Sf0.3i/0.08irt -G0 -O -K >> $OUTFILE psxy $Plots/trench.left.gmt -R -JM -M -W5/0 -Sf0.3i/0.08ilt -G0 -O -K >> $OUTFILE psxy $Plots/trench.other.gmt -R -JM -M -Wt30_30:1p5/0 -O -K >> $OUTFILE psxy $Plots/transform.gmt -R -JM -M -Wt10_10:1p5/0 -O -K >> $OUTFILE psxy $Plots/ridge.gmt -R -JM -M -W1/0 -O -K >> $OUTFILE psxy $Plots/volcanoes.simkin+siebert.gmt -R -JM -St.35 -W1/0 -G0 -O -K >> $OUTFILE -M Multiple segment file. Segments are separated by a record whose first character is flag. [Default is '>']. Example of trench.right.gmt > 92.278 6.948 91.903 7.663 >
#Information for the 2004 Sumatra event awk '{print $7, $6, $9/30}' $Plots/122604_032705.pde |\ #prints lat, lon,mag/30 psxy -R -JM -Sc -W1/0 -G255/255/100 -O -K >> $OUTFILE When no value is specified on the S flag (ie 0.20), then the size of the circle (denoted by the c) is controlled by the third column of info sent to the psxy command. So we are scaling the circle size by what earthquake parameter in this example? Example of 122604_032705.pde from http://neic.usgs.gov/neis/epic/epic_rect.html PDE-W 2004 12 26 005853.45 3.30 95.98 30 9.00 MwHRV 9C M STS...M PDE-W 2004 12 26 011710.33 4.94 94.27 30 5.50 mb GS .. . .......
psxy -R -JM -Sa.89 -W1/0 -G255/255/0 -: -O -K << END >> $OUTFILE 3.3 95.98 END -Sa creates a star -: indicates that the data is in y-x format rather than x-y format. This is useful because we speak of earthquakes in terms of latitude (y) and longitude (x) and therefore tend to write geographic coordinates in this order as well.
#Global CMT solutions for events above Mw ~6.6 psmeca -R -JM -Sm0.5 -G255/255/100 -T -O -K << END >> $OUTFILE #lon lat depth mrr mtt mpp mrt mrp mtp iexp name 94.26 3.09 29 1.04 -0.43 -0.61 2.98 -2.40 0.43 29 X Y 122604A 92.79 6.61 14 5.26 -0.84 -4.41 3.95 -2.91 2.10 26 X Y 122604B 92.45 8.58 12 0.94 -0.12 -0.81 0.02 -0.27 0.32 26 X Y 122604C 92.20 4.99 12 -0.02 -0.64 0.66 -0.11 -0.16 -0.80 26 X Y 010105A 95.38 2.84 12 0.26 -0.17 -0.09 0.90 -0.91 0.16 26 X Y 022605A END psmeca creates lower hemisphere projections, aka beachballs. It is a rather complicated little command. -S Selects the meaning of the columns in the data file. -Sa Focal mechanisms in Aki and Richard convention. -Sc Focal mechanisms in Harvard CMT convention. -Sm Seismic moment tensor (Harvard CMT, with zero trace). -Sd plot only the double couple part of moment tensor. -Sz plot anisotropic part of moment tensor (zero trace). http://www.globalcmt.org/CMTsearch.html -Sp Focal mechanisms given with partial data on both planes. -Sx Principal axis. -G Controls fill of the compressive quadrant of the moment tensor -T Plots the nodal planes
pstext -R -JM -: -O << END >> $OUTFILE -3.5 90.5 14 0 0 0 Yellow: 2004 Mw 9.2 series -5.75 90.5 14 0 0 0 CMT solutions for Mw >= 6.6 END format is x, y, size, angle, font#, justify, text %pstext L will tell you the font # and font name you can use [T|M|B][L|C|R] to specify justification (top/middle/bottom/left/center/right) gs $OUTFILE #gs indicates ghostscript
:!script.gmt will run the script, open the resulting file using gs, and you can see what you have done. If you dont like it, type quit, and continue editing the file.
You can put this into GMT several ways If this is the only file you want to plot this would work
nawk '{print $9, $8, $11}' EBH.HDF | pxsy
If you had a number of files that needed conversion you could do it this way (only need one psxy call)
psxy << END `nawk '{print $9, $8, $11}' EBH.HDF` END
Some other nawk tricks doing math and passing variables to nawk (quote heaven)
SCALE=`echo $STNDTMLON | \ nawk {print ($1>=0?$1:360+$1)/${jTRESCALE}_1*$FACTOR} `