polartoolkit.maps#
- 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:
- 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
kwargs (
Any
)
- Return type:
- 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:
- 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:
- 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:
- 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:
- 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:
- 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:
- geoviews_points(points, points_z=None, points_color='red', points_cmap='viridis', **kwargs)[source]#
_summary_
- Parameters:
- 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
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()