Poster: A modern Python interface for the Generic Mapping Tools

2017-12-05T23:17:56Z (GMT) by Leonardo Uieda Paul Wessel
Poster presentation at the AGU Fall Meeting 2017.<br><br>Abstract: <a href="https://agu.confex.com/agu/fm17/meetingapp.cgi/Paper/233450" rel="nofollow">IN51B-0018</a><br><br>Inkscape source files for the poster and a Jupyter notebook with the demo are on the Github repository: <a href="https://github.com/leouieda/agu2017">github.com/leouieda/agu2017</a> <br><br>The demo notebook can be run online using the MyBinder service: <a href="http://agu2017demo.gmtpython.xyz">agu2017demo.gmtpython.xyz</a><br><br><br>Abstract<br><br>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: <a href="https://github.com/emolch/gmtpy">gmtpy</a>, <a href="https://github.com/ian-r-rose/pygmt">pygmt</a>, and <a href="https://github.com/glimmer-cism/PyGMT">PyGMT</a>. 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 (<a href="https://github.com/GenericMappingTools/gmt-python">GenericMappingTools/gmt-python</a>) and is in early stages of development. A first release will accompany the release of GMT 6, which is expected for early 2018.