Figures generated by The Generic Mapping Tools (GMT) are present in countless
publications across the Earth sciences. The command-line interface of GMT lends
the tool its flexibility but also creates a barrier to entry for beginners.
Meanwhile, adoption of the Python programming language has grown across the
scientific community. This growth is largely due to the simplicity and low
barrier to entry of the language and its ecosystem of tools. Thus, it is not
surprising that there have been at least three attempts to create Python
interfaces for GMT: gmtpy,
pygmt, and
PyGMT. None of these projects are
currently active and, with the exception of pygmt, they do not use the GMT
Application Programming Interface (API) introduced in GMT 5. The two main
Python libraries for plotting data on maps are the matplotlib Basemap toolkit
(matplotlib.org/basemap) and Cartopy (scitools.org.uk/cartopy), both of which
rely on matplotlib (matplotlib.org) as the backend for generating the figures.
Basemap is known to have limitations and is being discontinued. Cartopy is an
improvement over Basemap but is still bound by the speed and memory constraints
of matplotlib. We present a new Python interface for GMT (GMT/Python) that
makes use of the GMT API and of new features being developed for the upcoming
GMT 6 release. The GMT/Python library is designed according to the norms and
styles of the Python community. The library integrates with the scientific
Python ecosystem by using the “virtual files” from the GMT API to implement
input and output of Python data types (numpy “ndarray” for tabular data and
xarray “Dataset” for grids). Other features include an object-oriented
interface for creating figures, the ability to display figures in the Jupyter
notebook, and descriptive aliases for GMT arguments (e.g., “region” instead of
“R” and “projection” instead of “J”). GMT/Python can also serve as a backend
for developing new high-level interfaces, which can help make GMT more
accessible to beginners and more intuitive for Python users. GMT/Python is an
open-source project hosted on Github
(GenericMappingTools/gmt-python)
and is in early stages of development. A first release will accompany the
release of GMT 6, which is expected for early 2018.