API Reference

gmt


The main API for GMT/Python.

Functions and classes from gmt package offer access to GMT with input and output of Python data types. All plotting is handled through the gmt.Figure class.

All of GMT/Python is operated on a “modern mode session” (new to GMT6). When you import the gmt library, a new session will be started automatically. The session will be closed when the current Python process terminates. Thus, the Python API does not expose the gmt begin and gmt end commands.

Classes

Figure() A GMT figure to handle all plotting.

Functions

info(fname, **kwargs) Get information about data tables.
test([doctest, verbose, coverage, figures]) Run the test suite.
which(fname, **kwargs) Find the full path to specified files.

gmt.datasets


Load sample data included with GMT (downloaded from the GMT cache server).

Functions

load_earth_relief([resolution]) Load Earth relief grids (topography and bathymetry) in various resolutions.
load_japan_quakes() Load a table of earthquakes around Japan as a pandas.Dataframe.

gmt.exceptions


Custom exception types used throughout the library.

All exceptions derive from the GMTError class.

Exceptions

GMTCLibError Error encountered when running a function from the GMT shared library.
GMTCLibNoSessionError Tried to access GMT API without a currently open GMT session.
GMTCLibNotFoundError Could not find the GMT shared library.
GMTError Base class for all GMT related errors.
GMTInvalidInput Raised when the input of a function/method is invalid.
GMTOSError Unsupported operating system.

gmt.clib


Low-level wrapper for the GMT C API.

The gmt.clib.LibGMT class wraps the GMT C shared library (libgmt) with a pythonic interface. Access to the C library is done through ctypes.

Classes

LibGMT([libname]) Load and access the GMT shared library (libgmt).

gmt.helpers


Functions, classes, decorators, and context managers to help wrap GMT modules.

Classes

GMTTempFile([prefix, suffix]) Context manager for creating closed temporary files.

Functions

build_arg_string(kwargs) Transform keyword arguments into a GMT argument string.
data_kind(data, x, y) Check what kind of data is provided to a module.
dummy_context(arg) Dummy context manager.
fmt_docstring(module_func) Decorator to insert common text into module docstrings.
is_nonstr_iter(value) Check if the value is not a string but is iterable (list, tuple, array)
kwargs_to_strings([convert_bools]) Decorator to convert given keyword arguments to strings.
launch_external_viewer(fname) Open a file in an external viewer program.
unique_name() Generate a unique name with the prefix ‘gmt-python-‘.
use_alias(**aliases) Decorator to add aliases to keyword arguments of a function.
worldwind_show(image, width, region, …) Create the HTML and Javascript to view an image in WorldWind Web