polartoolkit.maps#

add_box(fig, box, pen='2p,black')[source]#

Plot a GMT region as a box.

Parameters:
  • fig (pygmt.Figure) – Figure to plot on

  • box (tuple[float, float, float, float]) – region in EPSG3031 in format [e,w,n,s] in meters

  • pen (str, optional) – GMT pen string used for the box, by default β€œ2p,black”

Return type:

None

add_coast(fig, region=None, projection=None, no_coast=False, pen=None, version='depoorter-2013')[source]#

add coastline and groundingline to figure.

Parameters:
  • fig (pygmt.Figure)

  • region (tuple[float, float, float, float], optional) – region for the figure, by default is last used by PyGMT

  • projection (str, optional) – GMT projection string, by default is last used by PyGMT

  • no_coast (bool) – If True, only plot groundingline, not coastline, by default is False

  • pen (None) – GMT pen string, by default β€œ0.6p,black”

  • version (str)

Return type:

None

add_colorbar(fig, hist=False, cpt_lims=None, cbar_frame=None, **kwargs)[source]#

Add a colorbar and optionally a histogram based on the last cmap used by PyGMT.

Parameters:
  • fig (pygmt.Figure) – pygmt figure instance to add to

  • hist (bool, optional) – choose whether to add a colorbar histogram, by default False

  • cpt_lims (tuple[float, float], optional) – cpt lims to use for the colorbar histogram, must match those used to create the colormap. If not supplied, will attempt to get values from kwargs grid, by default None

  • cbar_frame (list[str] | str | None)

  • kwargs (Any)

Return type:

None

add_faults(fig, region=None, projection=None, fault_activity=None, fault_motion=None, fault_exposure=None, pen=None, style=None, label=None)[source]#

add various types of faults from GeoMap to a map, from Cox et al.[#coxcontinentwide2023]_ and Cox et al.[#coxgeomap2023]_

Parameters:
  • fig (pygmt.Figure instance)

  • region (tuple[float, float, float, float], optional) – region for the figure

  • projection (str, optional) – GMT projection string in lat lon, if your previous pygmt.Figure() call used a cartesian projection, you will need to provide a projection in lat/lon here, use utils.set_proj() to make this projection.

  • fault_activity (str, optional) – type of fault activity, options are active or inactive, by default both

  • fault_motion (str, optional) – type of fault motion, options are sinistral, dextral, normal, or reverse, by default all

  • fault_exposure (str, optional) – type of fault exposure, options are exposed or inferred, by default both

  • pen (str, optional) – GMT pen string, by default β€œ1p,magenta,-”

  • style (str, optional) – GMT style string, by default None

  • label (str, optional) – label to add to the legend, by default None

Return type:

None

add_gridlines(fig, region=None, projection=None, **kwargs)[source]#

add lat lon grid lines and annotations to a figure. Use kwargs x_spacing and y_spacing to customize the interval of gridlines and annotations.

Parameters:
  • fig (pygmt.Figure instance)

  • region (tuple[float, float, float, float], optional) – region for the figure

  • projection (str, optional) – GMT projection string in lat lon, if your previous pygmt.Figure() call used a cartesian projection, you will need to provide a projection in lat/lon here, use utils.set_proj() to make this projection.

  • kwargs (Any)

Return type:

None

add_inset(fig, region=None, inset_pos='TL', inset_width=0.25, inset_reg=(-2800000.0, 2800000.0, -2800000.0, 2800000.0), **kwargs)[source]#

add an inset map showing the figure region relative to the Antarctic continent.

Parameters:
  • fig (pygmt.Figure instance)

  • region (tuple[float, float, float, float], optional) – region for the figure

  • inset_pos (str, optional) – GMT location string for inset map, by default β€˜TL’ (top left)

  • inset_width (float, optional) – Inset width as percentage of the total figure width, by default is 25% (0.25)

  • inset_reg (tuple[float, float, float, float], optional) – Region of Antarctica to plot for the inset map, by default is whole continent

  • kwargs (Any)

Return type:

None

add_north_arrow(fig, region=None, projection=None, **kwargs)[source]#

add a north arrow to a figure

Parameters:
  • fig (pygmt.Figure instance)

  • region (tuple[float, float, float, float], optional) – region for the figure

  • projection (str, optional) – GMT projection string in lat lon, if your previous pygmt.Figure() call used a cartesian projection, you will need to provide a projection in lat/lon here, use utils.set_proj() to make this projection.

  • kwargs (Any)

Return type:

None

add_scalebar(fig, region=None, projection=None, **kwargs)[source]#

add a scalebar to a figure.

Parameters:
  • fig (pygmt.Figure instance)

  • region (tuple[float, float, float, float], optional) – region for the figure

  • projection (str, optional) – GMT projection string in lat lon, if your previous pygmt.Figure() call used a cartesian projection, you will need to provide a projection in lat/lon here, use utils.set_proj() to make this projection.

  • kwargs (Any)

Return type:

None

basemap(region=None, fig_height=15, fig_width=None, origin_shift='initialize', **kwargs)[source]#

create a blank basemap figure, or add a basemap to an existing figure / subplot.

Parameters:
  • region (tuple[float, float, float, float] | None, optional) – bounding region in GMT format, by default None

  • fig_height (float, optional) – height of figure, by default 15

  • fig_width (float | None, optional) – width of figure, by default None

  • origin_shift (str, optional) – choose to start new figure, or shift origin of existing figure to add a subplot, by default β€œinitialize”

  • kwargs (Any)

Returns:

a new or update figure instance with a basemap.

Return type:

pygmt.Figure

geoviews_points(points, points_z=None, points_color='red', points_cmap='viridis', **kwargs)[source]#

_summary_

Parameters:
  • points (pd.DataFrame) – _description_, by default None

  • points_z (str | None, optional) – _description_, by default None

  • points_color (str, optional) – _description_, by default β€œred”

  • points_cmap (str, optional) – _description_, by default β€œviridis”

Returns:

_description_

Return type:

gv.Points

interactive_data(coast=True, grid=None, grid_cmap='inferno', points=None, points_z=None, points_color='red', points_cmap='viridis', **kwargs)[source]#

plot points or grids on an interactive map using GeoViews

Parameters:
  • coast (bool, optional) – choose whether to plot Antarctic coastline data, by default True

  • grid (xr.DataArray, optional) – display a grid on the map, by default None

  • grid_cmap (str, optional) – colormap to use for the grid, by default β€˜inferno’

  • points (pd.DataFrame, optional) – points to display on the map, must have columns β€˜x’ and β€˜y’, by default None

  • points_z (str, optional) – name of column to color points by, by default None

  • points_color (str, optional) – if no points_z supplied, color to use for all points, by default β€˜red’

  • points_cmap (str, optional) – colormap to use for the points, by default β€˜viridis’

  • kwargs (Any)

Returns:

holoview/geoviews map instance

Return type:

holoviews.Overlay

interactive_map(center_yx=None, zoom=0, display_xy=True, show=True, points=None, basemap_type='BlueMarble', **kwargs)[source]#

Plot an interactive map with satellite imagery. Clicking gives the cursor location in EPSG:3031 [x,y]. Requires ipyleaflet

Parameters:
  • center_yx (list, optional) – choose center coordinates in EPSG3031 [y,x], by default [0,0]

  • zoom (float, optional) – choose zoom level, by default 0

  • display_xy (bool, optional) – choose if you want clicks to show the xy location, by default True

  • show (bool, optional) – choose whether to display the map, by default True

  • points (pd.DataFrame, optional) – choose to plot points supplied as columns x, y, in EPSG:3031 in a dataframe

  • basemap_type (str, optional) – choose what basemap to plot, options are β€˜BlueMarble’, β€˜Imagery’, and β€˜Basemap’, by default β€˜BlueMarble’

plot_3d(grids, cmaps, exaggeration, view=(170, 30), vlims=(-10000, 1000), region=None, shp_mask=None, polygon_mask=None, colorbar=True, grd2cpt=True, **kwargs)[source]#

create a 3D perspective plot of a list of grids

Parameters:
  • grids (list) – xarray DataArrays to be plotted in 3D

  • cmaps (list) – list of PyGMT colormap names to use for each grid

  • exaggeration (list) – list of vertical exaggeration factors to use for each grid

  • view (list, optional) – list of azimuth and elevation angles for the view, by default [170, 30]

  • vlims (list, optional) – list of vertical limits for the plot, by default [-10000, 1000]

  • region (tuple[float, float, float, float], optional) – region for the plot, by default None

  • shp_mask (Union[str or gpd.GeoDataFrame], optional) – shapefile or geodataframe to clip the grids with, by default None

  • cpt_lims (list, optional) – list of colorbar limits for each grid, by default None

  • colorbar (bool, optional) – whether to plot a colorbar, by default True

  • polygon_mask (list[float] | None)

  • grd2cpt (bool)

  • kwargs (Any)

Returns:

Returns a figure object, which can be used by other PyGMT plotting functions.

Return type:

PyGMT.Figure()

plot_grd(grid, cmap='viridis', region=None, coast=False, origin_shift='initialize', fig=None, **kwargs)[source]#

Helps easily create PyGMT maps, individually or as subplots.

Parameters:
  • grid (str or xr.DataArray) – grid file to plot, either loaded xr.DataArray or string of a filename

  • cmap (str or bool, optional) – GMT color scale to use, by default β€˜viridis’

  • region (tuple[float, float, float, float], optional) – region to plot, by default is extent of input grid

  • coast (bool, optional) – choose whether to plot Antarctic coastline and grounding line, by default False

  • origin_shift (str, optional) – automatically will create a new figure, set to β€˜xshift’ to instead add plot to right of previous plot, or β€˜yshift’ to add plot above previous plot, by default β€˜initialize’.

  • fig (pygmt.Figure(), optional) – supply figure instance for adding subplots or other PyGMT plotting methods, by default None

Keyword Arguments:
  • image (bool) – set to True if plotting imagery to correctly set colorscale.

  • grd2cpt (bool) – use GMT module grd2cpt to set color scale from grid values, by default is False

  • cmap_region (str or tuple[float, float, float, float]) – region to use to define color scale if grd2cpt is True, by default is region

  • cbar_label (str) – label to add to colorbar.

  • points (pd.DataFrame) – points to plot on map, must contain columns β€˜x’ and β€˜y’.

  • show_region (tuple[float, float, float, float]) – GMT-format region to use to plot a bounding regions.

  • cpt_lims (str or tuple]) – limits to use for color scale max and min, by default is max and min of data.

  • gridlines (bool) – choose to plot lat/long grid lines, by default is False

  • inset (bool) – choose to plot inset map showing figure location, by default is False

  • inset_pos (str) – position for inset map; either β€˜TL’, β€˜TR’, BL’, β€˜BR’, by default is β€˜TL’

  • fig_height (int or float) – height in cm for figures, by default is 15cm.

  • scalebar (bool) – choose to add a scalebar to the plot, by default is False. See maps.add_scalebar for additional kwargs.

  • colorbar (bool) – choose to add a colorbar to the plot, by default is True

Returns:

Returns a figure object, which can be passed to the fig kwarg to add subplots or other PyGMT plotting methods.

Return type:

PyGMT.Figure()

Example

>>> from polartoolkit import maps
...
>>> fig = maps.plot_grd('grid1.nc')
>>> fig = maps.plot_grd(
... 'grid2.nc',
... origin_shift = 'xshift',
... fig = fig,
... )
...
>>> fig.show()
Parameters:

kwargs (Any)

subplots(grids, region=None, dims=None, **kwargs)[source]#

Plot a series of grids as individual suplots. This will automatically configure the layout to be closest to a square. Add any parameters from plot_grd() here as keyword arguments for further customization.

Parameters:
  • grids (list) – list of xr.DataArray’s to be plotted

  • region (tuple[float, float, float, float], optional) – choose to subset the grids to a specified region, by default None

  • dims (tuple, optional) – customize the subplot dimensions (# rows, # columns), by default will use utils.square_subplots() to make a square(~ish) layout.

  • kwargs (Any)

Returns:

Returns a figure object, which can be used by other PyGMT plotting functions.

Return type:

PyGMT.Figure()