Presentation is loading. Please wait.

Presentation is loading. Please wait.

Generic Mapping Tools (GMT)

Similar presentations

Presentation on theme: "Generic Mapping Tools (GMT)"— Presentation transcript:

1 Generic Mapping Tools (GMT)

2 Final script for Example 1
#!/bin/bash psbasemap -R0/100/0/10 -JX5i/3i -Ba20g10/a2f1g2WSne \ -X2 -Y14 -K -P > sample1d -I1 << END |\ nawk '{print $1, sqrt($1)}' > input.dat 100 END psxy input.dat -R -JX -W5t15_15:0 -K -O >> sample1d input.dat -I10 |\ psxy -R -JX -St0.5 -G255/0/0 -W5/0/255/0 -O >> gs

3 Correction on the –W flag
psxy input.dat –R –JX -W5t15_15:0 -K –O >> The –W command can be quite complicated and is specified in order –W[width],[color],[texture] 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.

4 Common command options on first, and possibly subsequent, calls
Need on all calls -R Define region for plot – will need on first call and at least “–R” on subsequent -J Define projection for plot – will need this on all calls if need to define region

5 Common command options on first, and possibly subsequent, calls
(Generally) Need on first call only -B Borders -- annotation, frame, grid. Only need on first (or a single) call. -P Switch between landscape and portrait modes -X Shift X axis -Y Shift Y axis

6 Common command options on first, and possibly subsequent, calls.
Need when needed. -K Don’t close PostScript (showpage), use when more will follow need on all but last GMT call -O Don’t initialize PostScript, use when appending to pre-existing file need on all but first GMT call use both –K and –O when putting a large number of GMT call outputs together

7 Common command options on first, and possibly subsequent, calls.
Need when needed. -V Verbose (prints out stuff to standard error for user). -H Header records (tells GMT to skip first H lines of ascii input file)

8 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. GMT defaults are kept in a file called ~/.gmtdefaults4. There are tons of them and you can find out what they are and what the mean reading the man page for gmtdefaults.

9 When a program is run, it initializes all parameters to the GMT defaults, then tries to open the file .gmtdefaults4 in the current directory. If not found, it will look for that file in a sub-directory ~/.gmt, and finally in your home directory itself. If successful, the program will read the contents and set the default values to those provided in the file. To view your current gmtdefault settings %gmtdefaults –L To view the list of options for each default parameter %man gmtdefaults

10 Plotting Defaults example of start of .gmtdefaults4
# GMT-SYSTEM Defaults file # Plot Media Parameters -- PAGE_COLOR = 255/255/255 PAGE_ORIENTATION = landscape PAPER_MEDIA = letter #--- Basemap Annotation Parameters -- ANNOT_MIN_ANGLE = 20 ANNOT_MIN_SPACING = 0 ANNOT_FONT_PRIMARY = Helvetica ANNOT_FONT_SIZE = 14p ANNOT_OFFSET_PRIMARY = 0.075i

11 Changing the defaults You can edit your local copy of .gmtdefaults4 using nedit or vim You can explicitly reset a default within a script using the command gmtset #!/bin/sh gmtset PAPER_MEDIA letter MEASURE_UNIT cm gmtset OUTPUT_DEGREE_FORMAT +D gmtset PLOT_DEGREE_FORMAT +D

12 How about making pretty MAPS?

13 Map projections available in GMT

14 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”

15 pscoast -R-90/-70/0/20 -JM6i -P -B5g5 -G180/120/60 >
“All” gmt programs plot “maps” through the projection command line option or switch (even the x-y plot).

16 All projections give you two selections for specifying the scale
pscoast -R-90/-70/0/20 -JM6i -P -B5g5 -G180/120/60 > 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.)

17 Give scale along equator
pscoast -R-90/-70/0/20 -JM6i -P -B5g5 -G180/120/60 > -Jmparameters (Mercator [C]). Specify one of: -Jmscale or -JMwidth Give scale along equator (1:xxxx or UNIT/degree).

18 Give central meridian, standard latitude and scale along parallel
pscoast -R-90/-70/0/20 -JM6i -P -B5g5 -G180/120/60 > -Jmlon0/lat0/scale or -JMlon0/lat0/width Give central meridian, standard latitude and scale along parallel (1:xxxx or UNIT/degree, UNIT = number inches or cms).

19 Conformal (maintains shapes) Cylindrical projection
Mercator Projection: One way to address plotting sphere on a plane (which is whole ‘nother subject) Conformal (maintains shapes) Cylindrical projection

20 Region is “rectangle” on the spherical earth.
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 >! Region is “rectangle” on the spherical earth. -N for boundaries (international, US/Canadian/Mexican state boundaries “built in”), rivers.

21 -A to get rid of small water/island features
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 >! -A to get rid of small water/island features Albers projection (b/B) – need to know something (center and standard parallels).

22 -Jblon0/lat0/lat1/lat2/scale or -JBlon0/lat0/lat1/lat2/width
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 >! -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).

23 Also conformal (maintains/conserves shape)
Albers Also conformal (maintains/conserves shape) Conical projection

24 pscoast -R0/360/-90/90 -JG280/30/6i -Bg30/g15 -Dc -A5000 \
-G255/255/255 -S150/50/150 -P >! azimuthal Orthographic projection (g/G) mimics looking at earth from infinite distance.

25 New option -Dc Controls resolution of coastline f full h high l low
pscoast -R0/360/-90/90 -JG280/30/6i -Bg30/g15 -Dc -A5000 \ -G255/255/255 -S150/50/150 -P >! New option -Dc Controls resolution of coastline f full h high l low c crude Helps manage file sizes.

26 Example 2 Simple location map with focal mechanisms

27 gmtset: To change individual GMT default parameters
pscoast: Plot coastlines, filled continents, rivers, and political borders psxy: Plot symbols, polygons, and lines in 2-D pstext: Plot text strings psmeca: Plot focal mechanisms on maps

28 ###Create a basemap for the Sumatra-Andaman Island region
#!/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=$ #What does the $0 signify on this line? #Explicitly set some GMT default values gmtset MEASURE_UNIT cm ANOT_FONT_SIZE LABEL_FONT_SIZE 12 gmtset BASEMAP_TYPE fancy

29 #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

30 #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 >

31 #Information for the 2004 Sumatra event
awk '{print $7, $6, $9/30}' $Plots/122604_ 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 _ pde from PDE-W MwHRV 9C M STS...M PDE-W mb GS

32 psxy -R -JM -Sa.89 -W1/0 -G255/255/0 -: -O -K << END >> $OUTFILE
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.

33 #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 X Y A X Y B X Y C X Y A X Y A 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). -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

34 pstext -R -JM -: -O << END >> $OUTFILE
Yellow: 2004 Mw 9.2 series 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 if you are using vim to edit this script :!script.gmt will run the script, open the resulting file using gs, and you can see what you have done. If you don’t like it, type quit, and continue editing the file.

35 nawk commands as input to GMT
nawk '{print $9, $8, $11}' EBH.HDF 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 …

36 Converting each file on the fly.
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 Converting each file on the fly.

37 If you want to do the same thing to a list of files
filelist=“$SAMDATA/eq-rupt-1995.dat $DEM/eq-rupt-1960.dat” for FILE in $filelist do psxy -R -$PROJ$SCALE -M$ -: $CONTINUE -W$LINETHICK/$PURPLE $FILE \ $VBSE >> $OUTPUTFILE done Other ways to make list (notice the different kinds of quotes: “,’ and `) filelist=`ls -1 $ROOT/dem/topocontours/andes_3000_*` contourlist=‘ ’

38 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’}’ `

Download ppt "Generic Mapping Tools (GMT)"

Similar presentations

Ads by Google