pygmi.maps#

A collection of functions for maps.

Classes#

CustomToolbar

Custom toolbar.

CanvasModule

Canvas Module.

MapSettings

Data Layer Stack GUI.

Functions#

dd2txt(dd[, islon])

Divides a decimal degree range into neat minute/degree intervals.

discrete_colorbar(axes, csp, cdat[, lbls])

Plot colour bar using discrete colours for a small range of values.

get_neat_intervals(start_dd, end_dd, num_intervals[, ...])

Divides a decimal degree range into neat minute/degree intervals.

set_axes(ax, crs[, showdegrees, showmetres, xticks, ...])

Set the axes.

xlabels_dd(ax, crs, y[, pad, num])

Generate labels for x axis in degrees.

xlabels_m(ax[, pad, num])

Generate labels for x axis in metres.

ylabels_dd(ax, crs, x[, pad, num])

Generate labels for y axis in degrees.

ylabels_m(ax[, pad, num])

Generate labels for y axis in metres.

set_northscale(ax, crs[, showlog])

Set the north arrow and the scale bar.

set_north(ax, crs[, showlog])

Set the north arrow and the scale bar.

set_scale(ax, crs[, showlog])

Set the north arrow and the scale bar.

tick_formatter(x, pos)

Format thousands separator in ticks for plots.

Module Contents#

class pygmi.maps.CustomToolbar(canvas, parent)#

Bases: matplotlib.backends.backend_qt.NavigationToolbar2QT

Custom toolbar.

add_map_btn(update, crs)#

Add map button.

Parameters:
  • update (collections.abc.Callable) – Function which will update the map.

  • crs (pyproj.crs.CRS) – PyProj crs of data

change_map()#

Refresh plot.

class pygmi.maps.CanvasModule(parent=None)#

Bases: matplotlib.backends.backend_qtagg.FigureCanvasQTAgg

Canvas Module.

resizeEvent(event)#

Override Qt’s default resize event to suppress immediate rendering.

Parameters:

event – Event variable, used to estimate size.

set_map_axes(axes, crs)#

Set the map axes and north arrow.

Parameters:
  • axes (matplotlib.axes.Axes) – Primary Matplotlib axes.

  • crs (pyproj.crs.CRS) – PyProj crs of data.

class pygmi.maps.MapSettings(parent=None)#

Bases: pygmi.misc.BasicModule

Data Layer Stack GUI.

This class merges datasets which have different rows and columns. It resamples them so that they have the same rows and columns.

Parameters:

parent – Reference to the parent routine. The default is None.

setupui()#

Set up UI.

settings(nodialog=False)#

Entry point into item.

Parameters:

nodialog (bool) – Run settings without a dialog. The default is False.

Returns:

True if successful, False otherwise.

Return type:

bool

pygmi.maps.dd2txt(dd, islon=True)#

Divides a decimal degree range into neat minute/degree intervals.

Parameters:
  • start_dd – Minimum coordinate in decimal degrees.

  • end_dd – Maximum coordinate in decimal degrees.

  • num_intervals – Number of intervals

  • islon (bool) – Coordinates are longitudes, by default True

  • dd (float)

Returns:

  • intervals (ndarray) – Tick coordinates.

  • txt (list of str) – List of coordinates in degrees and minutes.

Return type:

str

pygmi.maps.discrete_colorbar(axes, csp, cdat, lbls=None)#

Plot colour bar using discrete colours for a small range of values.

Parameters:
  • axes (matplotlib.axes.Axes) – Current axes.

  • csp – Handle to Matplotlib plotting routine.

  • cdat (numpy.ma.MaskedArray | numpy.typing.NDArray) – Array of values.

  • lbls (list[str] | None) – y tick labels, by default None

pygmi.maps.get_neat_intervals(start_dd, end_dd, num_intervals, islon=True)#

Divides a decimal degree range into neat minute/degree intervals.

Parameters:
  • start_dd (float) – Minimum coordinate in decimal degrees.

  • end_dd (float) – Maximum coordinate in decimal degrees.

  • num_intervals (int) – Maximum number of intervals

  • islon (bool) – Coordinates are longitudes, by default True

Returns:

  • intervals (ndarray) – Tick coordinates.

  • txt (list of str) – List of coordinates in degrees and minutes.

Return type:

tuple[numpy.typing.NDArray, list[str]]

pygmi.maps.set_axes(ax, crs, showdegrees=True, showmetres=True, xticks=10, yticks=10)#

Set the axes.

Parameters:
  • ax (matplotlib.axes.Axes) – Primary Matplotlib axes.

  • crs (pyproj.crs.CRS | None) – PyProj crs of data.

  • showdegrees (bool) – Show degrees on the map border.

  • showmetres (bool) – Show metres on the map border.

  • xticks (int) – Maximum number of x-ticks, by default 10.

  • yticks (int) – Maximum number of y-ticks, by default 10.

pygmi.maps.xlabels_dd(ax, crs, y, pad=15, num=10)#

Generate labels for x axis in degrees.

pygmi.maps.xlabels_m(ax, pad=15, num=10)#

Generate labels for x axis in metres.

pygmi.maps.ylabels_dd(ax, crs, x, pad=20, num=10)#

Generate labels for y axis in degrees.

pygmi.maps.ylabels_m(ax, pad=15, num=10)#

Generate labels for y axis in metres.

pygmi.maps.set_northscale(ax, crs, showlog=print)#

Set the north arrow and the scale bar.

Parameters:
  • ax (matplotlib.axes.Axes) – Primary Matplotlib axes.

  • crs (pyproj.crs.CRS | None) – PyProj crs of data

  • showlog (collections.abc.Callable[..., None]) – Show information using a function, by default print

pygmi.maps.set_north(ax, crs, showlog=print)#

Set the north arrow and the scale bar.

Parameters:
  • ax (matplotlib.axes.Axes) – Primary Matplotlib axes.

  • crs (pyproj.crs.CRS | None) – PyProj crs of data

  • showlog (collections.abc.Callable[..., None]) – Show information using a function, by default print

pygmi.maps.set_scale(ax, crs, showlog=print)#

Set the north arrow and the scale bar.

Parameters:
  • ax (matplotlib.axes.Axes) – Primary Matplotlib axes.

  • crs (pyproj.crs.CRS | None) – PyProj crs of data

  • showlog (collections.abc.Callable[..., None]) – Show information using a function, by default print

pygmi.maps.tick_formatter(x, pos)#

Format thousands separator in ticks for plots.

Parameters:
  • x (float) – Number to be formatted.

  • pos (int) – Position of tick.

Returns:

Formatted coordinate.

Return type:

str