Monthly Archives: December 2014

Installing the Generic Mapping Tools 5 (GMT 5.1.x) on Ubuntu Linux

The Generic Mapping Tools (GMT) are a suite of tools for making maps. The graphics generated with default settings in GMT exceed in many ways those which would come out of most users’ ArcGIS work. Admittedly, GMT does come with a steep learning curve, not excluding the installation process. For earlier versions of GMT (4.x.x) installation is more simple and direct, as you can just install from the Ubuntu Software Center (or other package managers), however, these managers typically don’t have the most recent versions — in this case GMT version 5.1.x.

Without further adieu, in the following steps, we will collect the necessary components of the GMT install, compile, and install. Most of the guide comes from the GMT website, but is supplemented with some of what I think are helpful details for new users to GMT.

READ: This guide uses the terminal and a file explorer, but the entire install can be done from the terminal; in some steps incomplete commands to do operations via terminal are listed in square brackets […] where items in carrot brackets must be replaced with system/your-install specific items <…>. All terminal commands listed without brackets are required for successful install.

1) Begin by installing several dependency packages. Running the following command will be sufficient, as any already installed packages will be skipped.
sudo apt-get install subversion ghostscript build-essential cmake libnetcdf-dev libgdal1-dev libfftw3-dev libpcre3-dev

2) Download the latest stable version of GMT using
svn checkout svn:// gmt5-dev

3) Visit the GMT download page and download the latest versions of the packages titled “gshhg-gmt-x.x.x.tar.gz” and “dcw-gmt-x.x.x.tar.gz”.

4) Copy each compressed folder into the directory downloaded via subversion — this should be located at ~/gmt5-dev by default. Uncompress the folders here.
[cd ~/gmt5-dev]
[cp ./ && cp ./]
[tar -zxvf gshhg-gmt-x.x.x.tar.gz]

5) In the ~/gmt5-dev folder, enter the cmake folder, make a copy of the ConfigUserTemplate.cmake file and rename the copy to ConfigUser.cmake. Open this file in an editor.
[cp ConfigUserTemplate.cmake ./ConfigUser.cmake]
[gedit ConfigUser.cmake]

6) You need to edit the following lines of this file:
a. enable (uncomment) line 107 (set (GSHHG_ROOT…) and replace the path name with the absolute path to the gshhg-gmt-x.x.x folder.
b. enable copy in line 110
c. enable line 113 and replace the path nae with the absolute path to the dcw-gmt-x.x.x folder.
d. enable copy in line 116
Save the file and return to the terminal. NOTE: the line numbers may change with updates by the GMT devs to the .cmake file. Thanks @jerrodwalker for the most recent file lines.

7) cd into the ~/gmt5-dev folder and execute the following commands, waiting to finish each time.
mkdir build
cd build
cmake ..
sudo make install

That should complete your install of GMT 5.1.x! To test the install, try the following command into a new terminal window
gmt pscoast -R-130/-30/-50/50 -Jm0.025i -B30g30:.Mercator: -Di -W >

Check out the first article of my series on making maps with GMT here!

UPDATE: These instructions were tested on 08/25/16 on Ubuntu 16.04 LTS and remain successful when followed correctly (thanks Luis M.).

Pint glass short-pours

Have you ever gotten a short pour in your pint glass at the bar but not said anything? Well, after reading this, you may decide you want to say something next time. I’m not the first one to look at the point I’m making here, but I didn’t like the way others have presented it, and wanted to run the numbers myself anyway. The problem is to determine how much beer you are really missing out on, by missing that top bit of the pour.

For a theoretical pint glass, the volume of the glass increases with increasing h non-linearly from the base of the glass to the top. This is because the area of a circle is defined by πr2, where r changes linearly along h from rb to rt. L represents the vertical length of glass not filled with beer, measured down from the top of the glass.

schematic for terms used in problem.

I approached this problem two ways. First, I set up some simple relations in Matlab, and then numerically estimated the integral to a high spatial resolution, to determine how the volume of liquid in the glass changes with increasing h. I defined the glass geometry by crudely measuring a pint glass, and then fudging the measurements such that volume obtained for the full glass was 16 oz (one pint). Second, I actually filled my glass with 1 oz. slugs of water, and measured the height of the liquid in the glass.

Figure 1 shows the modeled and experimental results.

Figure 1: modeled and experimental results for the pint glass problem.

Figure 1: modeled and experimental results for the pint glass problem.

Since the experimental results closely overlay the model results, it is valid to assume the model calculations are accurate and reflect an actual pint glass, so I will proceed only considering the modeled results.

It’s immediately clear (and consistent with our expectation) that the top of the glass is where most of the liquid is held. This is seen in the data with the line slope; a shallow slope in the bottom of the glass means that an increase in the height of liquid equals a small percentage of total volume, whereas at the top of the glass, the same increase in height accounts for a much larger percentage of total volume. This has everything to do with the fact that the cross sectional area of the glass increases with increasing height (Ah = πrh2).

But, to address the question at hand, how much does a short pour really cheat you, lets look at Figure 2.

Figure 2: manipulated model results to demonstrate volume lost for small loss in total pour height.

Figure 2: manipulated model results to demonstrate volume lost for small loss in total pour height.

You can see that for a pour in which the top 1/2 inch (1.27 cm) is left empty, the drinker missed out on about 15% of the total volume of the pint-sized beer he paid for! If you are a regular at a hypothetical bar that short pours, every 7 beers you buy, you would be paying for a beer you never got to drink. Now, maybe your bartender isn’t leaving 1/2 inch of empty space at the top of your glass (although I have had it happen), but I do hope that you may think twice about not saying anything if you’re given a bad pour in the future.



Following a suggestion from /u/myu42996: fraction per fraction