You are on page 1of 64

Lecture 9: GMT

Asst. Prof. Deepa Mele Veedu

WL 226, 12 Sept. 2023, Tue. ES665A: Physics of earthquakes


Characteristics of an earthquake

• Seismic wave Arrival time,


Travel time, Earthquake
Origin time

• Epicenter location (lat, long)

• Hypocenter or focus (depth)

• Geometry of the fault:


• Strike, strike angle, dip angle

• Fault motion:
• Slip vector, slip angle

• Type of fault

• Magnitude

• Intensity
Learning outcomes

By the end of this lesson, you will be able to:


1. Know the basic informa on on Generic Mapping Tools (GMT)
2. Understand why we need to learn GMT, by going through examples
3. Download and install GMT; access documenta on
4. Know basic GMT commands and applica ons
5. Familiarize with some GMT exercises
6. Understand the u lity of GMT to plot loca on map, plate
boundaries, and earthquake data (loca on, depth, magnitude, etc).

3
ti
ti
ti
ti
ti
ti
GMT main page and versions
The main page of GMT: https://www.generic-mapping-tools.org

GMT version releases: https://www.generic-mapping-tools.org/download/

GMT 6 is the Modern version

4
Downloading GMT
Get GMT from GitHub: https://github.com/GenericMappingTools/gmt/releases/tag/6.4.0

5
Installing GMT
Installing GMT: https://github.com/GenericMappingTools/gmt/blob/master/INSTALL.md
Accessing GMT

After installing GMT software, you should be able to use


GMT from any folder.

So, the directory of the GMT executable les should be in your


PATH. Add the path in .bashrc or .bash_pro le if you have a
bash shell (use .zshrc if you have a Z shell). These shells
provide you with an interface to the Operating Software.

You need to set the PATH environment variable


PATH contains a string of directories separated by colons. Any
executable les in the directories listed in PATH can be
executed without specifying the full path to the le.

7
fi
fi
fi
fi
Accessing GMT

So, learn to set the PATH Environment in Windows (search how


to add PATH in Windows)

Once the PATH (directory of GMT executable les) added, then


type echo #PATH to check if it is added.

Example

8
fi
Type gmt to check if you can access it

9
Type gmt —version to check v6.4.0

10
Type gmt - - help to see GMT modules

11
Documentation on GMT
Documentation on GMT: https://www.generic-mapping-tools.org/documentation/
Learning outcomes
By the end of this lesson, you will be able to:
1. Know the basic informa on on Generic Mapping Tools (GMT)
2. Understand why we need to learn GMT, by going through examples
3. Download, install and access GMT; get help and documenta on
4. Know basic GMT commands and applica ons
5. Familiarize with some GMT exercises
6. Understand the u lity of GMT to plot loca on map, plate
boundaries, and earthquake data (loca on, depth, magnitude, etc).

13
ti
ti
ti
ti
ti
ti
GMT modules
Modules: https://docs.generic-mapping-tools.org/latest/modules.html

In computer software, a module has a speci c function and is an extension to a main program

98 core modules
main program; use this along with module name 51 supplementary modules
gmt -- help
for a list of all modules & description

gmt coast
gmt basemap

14
fi
GMT modules
Modules: https://docs.generic-mapping-tools.org/latest/modules.html

15
GMT modules
Modules: https://docs.generic-mapping-tools.org/latest/modules.html

16
Getting data into & out of GMT
cat data_ le | gmt psxy -Rw/e/s/n -Jxw/yh -Sa0.1 -P > le1.ps

Displays
redirection
piping Plot lines, polygons, and symbols in 2-D

main program for output

>> to append
fi
fi
Essential GMT Commands
syntax gmt coast -R -J -B

module name

module options
Essential GMT Commands
syntax gmt coast -R -J -B

module name

module options

gmt begin
gmt coast -R -J -B
gmt end
The common GMT Commands

-R Region: De nes the map region or


-R125/130/20/30 data domain of interest
-Rg
-More options

-J Projection: Map projection


-JM7i
-JH127.5/6c
-More options

-B Boundary annotation: Axes and Frame settings


-Ba10f1
-Ba5f.5g1:”x”:/a10f1:”y”::.”plot title”.WeSn
-More options
fi
Choose a projection based on your study area

Mercator
The common GMT Commands

-R Region: De nes the map region or gmt coast -R -J -B


-R125/130/20/30 data domain of interest
-Rg main program
-More options
module name
-J Projection: Map projection
-JM7i module options
-JH127.5/6c
-More options

-B Boundary annotation: Axes and Frame settings


-Ba10f1 gmt begin
-Ba5f.5g1:”x”:/a10f1:”y”::.”plot title”.WeSn
-More options gmt coast -R -J -B
gmt end
fi
General GMT Syntax
gmt modulename moduleoptions > myFile.ps
-R -J -B -P

Example:
gmt basemap -R0/1/0/1 -JX8.5i/11i -Ba1f1/a1f1NSEW -P >myFile.ps

This will create a new le myFile.ps to plot a map over the Region 0-1 in the x and 0-1 in the y
with an X-Y projection over 8.5inches in x and 11 inches in y in Portrait mode
fi
The common GMT Commands
Learning outcomes

By the end of this lesson, you will be able to:


1. Know the basic informa on on Generic Mapping Tools (GMT)
2. Understand why we need to learn GMT, by going through examples
3. Download and install the GMT; access documenta on
4. Know basic GMT commands and applica ons
5. Learning GMT and familiarizing with some GMT exercises
6. Understand the u lity of GMT to plot loca on map, plate
boundaries, and earthquake data (loca on, depth, magnitude, etc).

25
ti
ti
ti
ti
ti
ti
GMT learning tips
1. Use command line (PowerShell or Visual Studio Code) to familiarize GMT syntax
2. Test the GMT Tutorial scripts on your command line and visualize the output
Example scripts are readily available at
https://docs.generic-mapping-tools.org/latest/tutorial/
3. Later use shell script along with GMT commands to automate instead of copy-paste
GMT Tutorial Sessions 1- 4
Scripts are available at: https://docs.generic-mapping-tools.org/latest/tutorial/session-1.html
These exercises are for GMT 6 modern version only

1-4
Preparations before running the rst script
1. GMT should be properly and fully installed.
2. GMT executables should be in the executable path (in .bashrc or similar shell le)
3. You should be able to type gmt in your terminal and it should display the GMT splash screen with version
number and the top-level command options.

fi
fi
To run the rst script
• Create a sub-directory called ES665A_exercises, cd into that directory, and run the commands there.
• It is recommended that you place all the GMT (and UNIX) commands in a shell script le and make it
executable.
• Start the script with the line #!/usr/bin/env bash or #!/usr/bin/env csh, depending on the shell.
• All the examples in the GMT Tutorial session assumes you are running the Bourne Again shell, bash.
• Making a script executable is accomplished using the chmod command, e.g., the script gure_1.sh is
made executable with “chmod +x gure_1.sh”.
• Please cd into the directory exercise.

The +x parameter is used to add the x permission which is the symbol for the execute or run (./)permission.
fi
fi
fi
fi
A few essential commands
1. Redirection

Most GMT modules read their input from the terminal (called stdin) or from les, and write their output
to the terminal (called stdout). To use les instead one can use redirection:

gmt module input- le > output- le # Read a le and redirect output


gmt module input- le >> output- le # Append output to existing le

2. Piping (|)

Sometimes we want to use the output from one module as input to another module. This is achieved with
pipes:

Someprogram | gmt module1 > OutputFile


fi
fi
fi
fi
fi
fi
fi
fi
A few essential commands
3. File name expansion or “wild cards”

Several ways to select groups of les based on name patterns:

Examples:
gmt module data_*.txt operates on all les starting with “data_” and ending in “.txt”.
gmt module line_?.txt works on all les starting with “line_” followed by any single character and ending in
“.txt”.
fi
fi
fi
Some GMT exercises

• To make some simple plots and coastline basemaps.


• We will do this in order to introduce the all-important common options -R, -J, -B
• This is to familiarize ourselves with a few selected GMT projections.
• The GMT modules we will utilize are basemap, coast, and plot
• Please consult their manual pages for reference.
Some GMT exercises
Exercise1: Linear plot
• We start by making the basemap frame for a linear x-y plot.
• We want it to go from 10 to 70 in x and from -3 to 8 in y, with automatic annotation intervals.
• Finally, we let the canvas be painted light red and have Region dimensions of 4 by 3 inches.

Exercise1a:
gmt begin GMT_exe_1a
gmt basemap -R10/70/-3/8 -JX4i/3i -B -B+glightred+t“ES665A_LP_ g1a”
gmt end show

fi
Some GMT exercises
Exercise1a:
gmt begin GMT_exe_1a
gmt basemap -R10/70/-3/8 -JX4i/3i -B -B+glightred+t“ES665A_LP_ g1a”
gmt end show

Exercise1b: Change color


gmt begin GMT_exe_1b
gmt basemap -R10/70/-3/8 -JX4i/3i -B -B+gdarkblue+t"ES665A_LP_ g1b"
gmt end show

fi
fi
Some GMT exercises
Exercise1b:
gmt begin GMT_exe_1b
gmt basemap -R10/70/-3/8 -JX4i/3i -B -B+gdarkblue+t"ES665A_LP_ g1b"
gmt end show

Exercise1c: Change -JX values


gmt begin GMT_exe_1c
gmt basemap -R10/70/-3/8 -JX7i/1i -B -B+gdarkblue+t"ES665A_LP_ g1c"
gmt end show

fi
fi
Some GMT exercises
Exercise2: Logarithmic plot
• Try to create a basemap for a log–log plot.
• We have no data set yet but we will imagine that the raw x data range from 5 to 9600 and that y ranges
from 10^20 to 10^24.

gmt begin GMT_exe_2a


gmt basemap -R1/10000/1e20/1e25 -JX9il/6il -Bxa2+l"Wavelength (m)" -Bya1pf3+l"Power (W)"
gmt end show

Notice the frame


Some GMT exercises
Exercise2: Logarithmic plot
• Try to create a basemap for a log–log plot.
• We have no data set yet but we will imagine that the raw x data range from 5 to 9600 and that y ranges
from 10^20 to 10^24.

gmt begin GMT_exe_2b


gmt basemap -R1/10000/1e20/1e25 -JX9il/6il -Bxa2+l"Wavelength (m)" -Bya1pf3+l"Power (W)" -BWS
gmt end show

Remove frame using -BWS


Some GMT exercises
Exercise3: Mercator projection
• The Mercator projection (-JM) can be used for location maps.
• It is one of several cylindrical projections offered by GMT.
• The complete syntax is simply -JMwidth

One of -W, -G, -S must be selected. Our rst coastline example is from Central America:

gmt begin GMT_exe_3a


gmt coast -R-90/-70/0/20 -JM6i -B -Gchocolate
gmt end show
fi
Some GMT exercises
gmt begin GMT_exe_3a
gmt coast -R-90/-70/0/20 -JM6i -B -Gchocolate
gmt end show

gmt begin GMT_exe_3b


gmt coast -R-90/-70/0/20 -JM6i -B -Ggrey
gmt end show
Some GMT exercises
gmt begin GMT_exe_3b
gmt coast -R-90/-70/0/20 -JM6i -B -Ggrey
gmt end show

Change the region (-R values)


gmt begin GMT_exe_3c
gmt coast -R60/100/0/30 -JM6i -B -Gbrown
gmt end show
GMT exercises
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

3 modules are used: makecpt, coast, plot


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

3 modules are used: makecpt, coast, plot

What is makecpt module and how to use it? (syntax)

2 options of makecpt module are used: -C and -T


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

3 modules are used: makecpt, coast, plot


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

3 modules are used: makecpt, coast, plot Coast module is used to plot continents,
countries, shorelines, rivers and borders
What is coast module and how to use it? (syntax)

4 options of coast module are used: -R -JM -B -G


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-R speci es the min/max coordinates of your data region (longitudes, latitudes)


fi
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

gmt begin GMT_tut_9


gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R120/160/25/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

zoom out; cover larger region


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-J selects map projection; Mercator is a cylindrical projection; 6i is 6 inches of width


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-B speci es basemap frame settings and axes parameters


fi
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-G is used to color the area


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

Here the colors gray and black are used

gmt begin GMT_tut_9


gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Gblack
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

3 modules are used: makecpt, coast, plot

What is plot module and how to use it? (syntax)

Plot is used to draw lines, polygons, etc.

4 options of plot module are used: -W -i -S -C


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-W is used to choose pen attributes (color, thickness, style)


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-i is used to change the column order


(E.g., the data may be in lat, long and you want to switch the columns
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-S is used to select the symbol type and size


(E.g., c for circle, a for star etc.)
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show
column $4 is longitude
column $3 is latitude
column $5 is depth Please cross check
column $6 is magnitude

-C Assign symbol colors based on z-value (depth) in 3rd column


GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

-S is used to select the symbol type and size (E.g., c for circle, a for star etc.)
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show

gmt begin GMT_tut_9


gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Sac -C
gmt end show
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Scc -C
gmt end show
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Sac -C
gmt end show

gmt begin GMT_tut_9


gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wwide -i4,3,5,6+s0.1 -Sac -C
gmt end show
GMT exercises
gmt begin GMT_tut_9
gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wfaint -i4,3,5,6+s0.1 -Sac -C
gmt end show

gmt begin GMT_tut_9


gmt makecpt -Cred,green,blue -T0,100,300,10000
gmt coast -R130/150/35/50 -JM6i -B -Ggray
gmt plot @tut_quakes.ngdc -Wthin -i4,3,5,6+s0.1 -Sac -C
gmt end show
GMT exercises
Scripts are available at: https://docs.generic-mapping-tools.org/latest/tutorial/session-2.html
Learning outcomes

By the end of this lesson, you will be able to:


1. Know the basic informa on on Generic Mapping Tools (GMT)
2. Understand why we need to learn GMT, by going through examples
3. Download and install the GMT; access documenta on
4. Know basic GMT commands and applica ons
5. Familiarize with some GMT exercises
6. GMT to plot loca on map, plate boundaries, and earthquake data
(loca on, depth, magnitude, etc).

63
ti
ti
ti
ti
ti
Thank you!

You might also like