New Mexico Tech
Earth and Environmental Science

ERTH 401 / GEOP 501 - Computational Methods & Tools

Lab 13: GMT Part 1

Today's lab will cover some of the introductory Generic Mapping Tools we discussed in lecture today. You will start with a sample script for a map of New Mexico, make simple maps for your research areas of study, and then move on to adding data to figures.

GMT is available on many operating systems, and there are a few versions floating around on the MSEC 345 computers. For the purposes of this class, we'll all log onto the same Linux machine so that we are all using the same version. If you need GMT for other purposes, please let us know and we can help you get access to the versions that you need on the other computers.

First, open up a terminal window on whatever machine you choose to use (doesn't matter Mac or Linux box). We'll then SSH into the Linux machine --- will give these instructions during the lab period, or email one of us for instructions. Once you are logged in, please change directories (cd) into the directory called your first name. This directory will be your operating space for the next two labs. Copy over the files that are currently held in /home/geop501/files as you'll use these in the exercises:

  $>cp /home/geop501/files/* . 
  

GMT has a fairly steep learning curve because of the vast number of command-line options you have to control figures. Even though you could build figures by typing the commands onto the command-line one by one, it is much easier (and much more reproducible) if you keep your figure-building commands in a script. Once you master scripts for a few figures, you can keep modifying scripts for new figures.

Because of the large number of command-line modules and options for each module in GMT, it is critical that you become familiar with the GMT help system. The GMT webpages are a great resource - these provide both manual pages for each command that list, in great detail, all the parameters that are possible for each command. The GMT webpages also have tutorial pages as well as a "cookbook" that provides a variety of example plots along with the commands and parameters required to reproduce them. Take advantage of these examples - it really is one of the best ways to learn how to use GMT, and you can then modify the commands to produce the variant of figure that you need.

GMT documentation pages: here

From that starting page, you can review the various commands/modules available under "Module Purpose". Clicking on each module will take you to the manual page for that module. The detailed manual pages provide a brief summary of the module and parameter flags available, a longer description of what the module actually does, followed by a list of the parameters/arguments available. The current documentation is nicely formatted in that it includes a list and explanation of each required parameter up front, followed by optional parameters. That way you know the minimum information needed to get output. Each entry also has an example near the end of the page.

Exercise 1: Sample GMT scripting

For this first section, review the sample script called "example_gmt_script.gmt" (you copied this over from /home/geop501/files). This file will generate a postscript file that contains a map of New Mexico, including elevation contours as well as national and state boundaries. As a starting point, look through the script and run it once to see what the output I generated looks like. Then comment out various lines in the script to explore what the various commands do.

Deliverable 1: Test of example script - explore the options

For all deliverables, please turn in your GMT scripts, any data files used, and the resulting plots. All files should be names with your last name and the deliverable number. For the first deliverable, turn in a map of New Mexico, with state outlines as green dashed lines, a 50 km scale, and 50 m contours.

Exercise 2: Create your own map script, part 1

For this part, you can take some of the basic structure from my example script and expand it to a figure that relates to your own research. In many cases, you will want to have a figure that shows the region in which your study area is. For example, if your study area is in North America, you should create a map of the continent and highlight with a box where in North America your field area is located. You can explore a variety of map projections, coloring, and other details, but the parameters required for the deliverable map are outlined below.

Deliverable 2: Regional map of research area

Create a map of the continent where your research area (or another spot if you are doing some sort of theoretical study) is located. Use Lambert projection, color land masses light brown, water white, any state/country borders in green, and include a map scale in the bottom right corner. Set the latitude and longitude tickmarks at a reasonable range and interval for your region and display them on the west and south portions of the map.

Exercise 3: Close up of study area

Here you can take your script from exercise 2 and modify it (changing region, scale, etc) to focus more closely on your specific study area, such as where you are collecting data on the ground. Play with various options to gain experience, but final parameters are listed within the deliverable section.

Deliverable 3: Research study area map

Create a map of your research area (or some other spot if you are doing some sort of theoretical study). Use Mercator projection, color land masses light brown, water colored blue, any state/country borders in green, and include a map scale in the bottom right corner. Set the latitude and longitude tickmarks at a reasonable range and interval for your region and display them on the west and south portions of the map.

Exercise 4: Adding data to a plot

Now that you are experts in creating simple maps, you will now gain experience adding additional information to them. The ability to add additional data to the plots is incredibly useful - you can think about this as layering more and more information to the underlying basemap that you already created. Examples of additional data layers include geographic locations of sample locations, stations, volcanoes, faults, etc.

We'll explore more complex plotting next week by adding in a wide range of data, but for this week, please work with a simple map, adding in locations of stations and earthquakes. I have already provided data files for use here, although these are raw data files that I've copied from Internet sources, with the original formatting. You'll need to recall previous tools in order to extract out the information that you need for plotting the data in GMT.

Deliverable 4: Map of OK seismicity and seismic stations

Create a Mercator projection map of recent earthquakes and seismic stations located in the state of OK. The files OK_eq.txt and OK_stations.txt contain the locations of earthquakes and stations. I recommend digging back into previously used UNIX scripting tools to find commands to manipulate the data as you need it. Color the land white, seismic stations as red triangles, and earthquakes as circles that have a size that scales with magnitude and color that changes with depth. Include a color bar representing the depth scale. Set the latitude and longitude tickmarks to plot every 0.25 degree and annotate every degree.

Exercise 5: Creating an x-y plot

GMT allows for more than just creation of maps. XY plots, for example, can be generated fairly easily once you have a script set up, and can be generated for a large number of data files using loops and other scripting tools. This can be much faster than opening a large number of Excel files to use their chart functions, and the GMT-created figures look much better than those generated in Excel.

Here you'll need to setup a basemap that defines your axes, and use the -JX projection, which you can then specify as linear, log10, exponential, and time.

Deliverable 5: X-Y plot using GMT

Here you will revisit data used before in Lab 5 - nast.neu. Remember that this file contains 4 columns of data: the decimal minute after 06:11:00 UTC, north, east, and vertical motion in cm following the 2015 M7.8 Gorkha earthquake. Make a plot of north motion vs. decimal minute using GMT. For the first version (deliverable 5a), plot this data as a blue line. For the final version (deliverable 5b), plot each data point as a small red circle. For both versions, add labels on the axes.

rg <at> nmt <dot> edu | Last modified: November 20 2017 18:41.