nc5ng.gmt GMT Wrapper API

PyPi Package: nc5ng-common

GMT Wrapper Library and Convenience Methods for nc5ng

GMT Options

GMTOptions form a loose wrapper on the GMT command line arguments and GMT/Python shorthands

It is a subtype of dict but has additional properties for creating appropirate GMT arguments

class nc5ng.gmt.GMTOptions(projection='M10.0i', region=[240, 190, 30, 80], frame=True, insert=None, border=None, scale=None, dir_rose=None, mag_rose=None, logo=False, area_thresh=None, lakes=None, resolution='c', land=None, rivers=None, borders=None, water=None, shorelines=1, linear_lines=False, cpt=None, offset=None, errors=None, color=None, symbol=None, pen=None, basemap=None, coast=None, plot=None, **kwargs)[source]

GMTOptions are decorated dictionaries to wrap GMT/Python Keyword options

GMTOptions takes keywords or other dictionary to construct gmt plot options for basemap, coast, plot via properties GMTOptions.basemap, .coast .plot

GMT Options can be combined (copy-combine) by calling one with the other

p1 = GMTOptions(lakes=0) p2 = GMTOptions(**PLOT_OPTS[‘default’])

p3 = p2(p1) # override default by turning off lakes


GMTOptions do not track single letter GMT Arguments, because ambiguous double-mappings exist (e.g. -A means different things to coast vs plot).

Instead, single letter options can be overriden as keyword arguments to GMTPlotter

GMT Plotter

GMTPlotter forms a loose wrapper around gmt.Figure object, that constructs plots from embedded gmt options inside nc5ng objects (meta-api, object.gmt_meta)

class nc5ng.gmt.plotter.GMTPlotter(base_plot_options={'__class__': <class 'nc5ng.gmt.options.GMTOptions'>, 'area_thresh': 1200, 'basemap': None, 'border': None, 'borders': ['1', '2'], 'coast': None, 'color': None, 'cpt': None, 'dir_rose': None, 'errors': None, 'frame': True, 'insert': None, 'kwargs': {}, 'lakes': None, 'land': None, 'linear_lines': False, 'logo': False, 'mag_rose': None, 'offset': None, 'pen': None, 'plot': None, 'projection': 'M10.0i', 'region': [240, 190, 30, 80], 'resolution': 'fine', 'rivers': None, 'scale': None, 'self': {'linear_lines': False, 'water': 'lightblue', 'basemap': None, 'rivers': None, 'cpt': None, 'kwargs': {}, 'borders': ['1', '2'], 'mag_rose': None, 'coast': None, '__class__': <class 'nc5ng.gmt.options.GMTOptions'>, 'region': [240, 190, 30, 80], 'logo': False, 'area_thresh': 1200, 'dir_rose': None, 'plot': None, 'scale': None, 'lakes': None, 'insert': None, 'symbol': None, 'border': None, 'color': None, 'frame': True, 'pen': None, 'projection': 'M10.0i', 'self': {...}, 'shorelines': 1, 'offset': None, 'errors': None, 'resolution': 'fine', 'land': None}, 'shorelines': 1, 'symbol': None, 'water': 'lightblue'})[source]

Wrapper for GMT/Python Plotter

static plot_conversion(conversion, coverage='all', vector='all', plotter=None, **kwargs)[source]

Static Method to Plot an nc5ng.nc5data.Conversion

Plotting options are Applied in the order

  1. GMTPlotter configured or default options
  2. Conversion configured options Conversion.gmt_meta
  3. Data Set Options PointData.gmt_meta
  4. Keyword overrides (full option name)
  5. Keyowrd overrides (single letter GMT Style arguments)
  • conversion – Conversion data
  • coverage – Coverage files (no file extension), to plot. Can be list of names (coverage = ['cvacdlat','cvacdlon',]), single file name (coverage = 'cvacdlat'), None, or 'all'
  • vector – Vector files (no file extension) to plot. Can be list of names, single file name, None, or 'all'.
  • plotter – plotter to use, if None one will be created and returned