Either pulls login details from pre-set environment variables, or prompts user to
input username and password. Will persist the entered details within the python
session.
Requires an EarthData login, see Tutorials/Download Polar datasets for how to
configure this.
Parameters:
version (str,) – choose which file to retrieve from the following list:
“Coastline”, “Basins_Antarctica”, “Basins_IMBIE”, “IceBoundaries”, “IceShelf”,
“Mask”
version (str) – choose which version to load, either ‘w_b’ for basal melt rate, ‘w_b_interp’,
for basal melt rate with interpolated values, and ‘w_b_uncert’ for uncertainty
Referenced to the EIGEN-6C4 geoid. To convert to be ellipsoid-referenced, we add
the geoid grid. use reference=’ellipsoid’ to include this conversion in the
fetch call.
For Antarctica: Surface and ice thickness are in ice equivalents. Actual snow
surface is from REMA [5], and has had firn thickness
added(?) to it to get Bedmachine Surface.
To get snow surface: surface+firn
To get firn and ice thickness: thickness+firn
Here, icebase will return a grid of surface-thickness
This should be the same as snow-surface - (firn and ice thickness)
Requires an EarthData login, see Tutorials/Download Polar datasets for how to
configure this.
Parameters:
layer (str) – choose which layer to fetch:
‘bed’, ‘dataid’, ‘errbed’, ‘firn’, ‘geoid’, ‘mask’, ‘source’,
‘surface’, ‘ice_thickness’; ‘icebase’ will give results of surface-thickness
reference (str) – choose whether heights are referenced to ‘eigen-6c4’ geoid or the
‘ellipsoid’ (WGS84), by default is eigen-6c4’
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 500m. If spacing >=
5000m, will resample the grid to 5km, and save it as a preprocessed grid, so
future fetch calls are performed faster.
registration (str, optional) – change registration with either ‘p’ for pixel or ‘g’ for gridline registration,
by default is None.
hemisphere (str, optional) – choose which hemisphere to retrieve data for, “north” or “south”, by default
None
**kwargs (Any) – additional keyword arguments to pass to the resample_grid function
Returns:
Returns a loaded, and optional clip/resampled grid of Bedmachine.
All grids are by default referenced to the EIGEN-GL04C geoid. Use the
reference=’ellipsoid’ to convert to the WGS-84 ellipsoid or reference=’eigen-6c4’ to
convert to the EIGEN-6c4 geoid.
Unlike Bedmachine data, Bedmap2 surface and icethickness contain NaN’s over the
ocean, instead of 0’s. To fill these NaN’s with 0’s, set fill_nans=True.
Note, this only makes since if the reference is the geoid, therefore, if
reference=’ellipsoid and fill_nans=True, the nan’s will be filled before
converting the results to the geoid (just for surface, since thickness isn’t
relative to anything).
Parameters:
layer (str) – choose which layer to fetch:
“bed”, “coverage”, “grounded_bed_uncertainty”, “icemask_grounded_and_shelves”,
“lakemask_vostok”, “rockmask”, “surface”, “ice_thickness”,
“ice_thickness_uncertainty”, “gl04c_geiod_to_WGS84”, “icebase”,
“water_thickness”
reference (str) – choose whether heights are referenced to the ‘eigen-6c4’ geoid, the WGS84
ellipsoid, ‘ellipsoid’, or by default the ‘eigen-gl04c’ geoid.
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 1000m. If spacing >=
5000m, will resample the grid to 5km, and save it as a preprocessed grid, so
future fetch calls are performed faster.
registration (str, optional,) – choose between ‘g’ (gridline) or ‘p’ (pixel) registration types, by default is
the original type of the grid
fill_nans (bool, optional,) – choose whether to fill nans in ‘surface’ and ‘thickness’ with 0. If converting
to reference to the geoid, will fill nan’s before conversion, by default is
False
**kwargs (optional) – additional keyword arguments to pass to the resample_grid function
Returns:
Returns a loaded, and optional clip/resampled grid of Bedmap2.
All grids are by default referenced to the EIGEN-GL04C geoid. Use the
reference=’ellipsoid’ to convert to the WGS-84 ellipsoid or reference=’eigen-6c4’ to
convert to the EIGEN-6c4 geoid.
Unlike Bedmachine data, Bedmap2 surface and icethickness contain NaN’s over the
ocean, instead of 0’s. To fill these NaN’s with 0’s, set fill_nans=True.
Note, this only makes since if the reference is the geoid, therefore, if
reference=’ellipsoid and fill_nans=True, the nan’s will be filled before
converting the results to the geoid (just for surface, since thickness isn’t
relative to anything).
Parameters:
layer (str) – choose which layer to fetch:
“surface”, “icebase”, “bed”, “ice_thickness”, “water_thickness”,
“bed_uncertainty”, “ice_thickness_uncertainty”, and “mask”.
reference (str) – choose whether heights are referenced to the ‘eigen-6c4’ geoid, the WGS84
ellipsoid, ‘ellipsoid’, or by default the ‘eigen-gl04c’ geoid.
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 500m. If spacing >=
5000m, will resample the grid to 5km, and save it as a preprocessed grid, so
future fetch calls are performed faster.
registration (str, optional,) – choose between ‘g’ (gridline) or ‘p’ (pixel) registration types, by default is
the original type of the grid
fill_nans (bool, optional,) – choose whether to fill nans in ‘surface’ and ‘thickness’ with 0. If converting
to reference to the geoid, will fill nan’s before conversion, by default is
False
**kwargs (optional) – additional keyword arguments to pass to the resample_grid function
Returns:
Returns a loaded, and optional clip/resampled grid of Bedmap2.
version (str) – choose which version to load, either ‘max’ for maximum buttressing, ‘min’ for
minimum buttressing, ‘flow’ for along-flow buttressing, or ‘viscosity’ for
estimated ice viscosity values
Returns:
Returns a dataarray of buttressing or viscosity values
version=’an-2015’
Crustal thickness (distance from solid (ice and rock) top to Moho discontinuity)
from An et al.[12].
Accessed from http://www.seismolab.org/model/antarctica/lithosphere/index.html#an1s
File is the AN1-CRUST model, paper states “Moho depths and crustal thicknesses
referred to below are the distance from the solid surface to the Moho. We note that
this definition of Moho depth is different from that in the compilation of AN-MOHO”.
Unclear, but seems moho depth is just negative of crustal thickness. Not sure if its
to the ice surface or ice base.
Parameters:
version (str) – Either ‘shen-2018’,
will add later: ‘lamb-2020’, ‘an-2015’, ‘baranov’, ‘chaput’, ‘crust1’,
‘szwillus’, ‘llubes’, ‘pappa’, ‘stal’
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (int, optional) – grid spacing to resample the loaded grid to, by default spacing is read from
downloaded files
registration (str, optional) – change registration with either ‘p’ for pixel or ‘g’ for gridline registration,
by default is None.
**kwargs (Any) – additional keyword arguments to pass to the resample_grid function
Returns:
Returns a loaded, and optional clip/resampled grid of crustal thickness.
Loads a grid of Antarctic topography from ETOPO1 from ETOPO1 1 Arc-Minute Global Relief Model: Procedures, Data Sources and Analysis[15].
Originally at 10 arc-min resolution, reference to mean sea-level (geoid).
Loads a grid of Antarctic geoid heights derived from the EIGEN-6C4 from
Förste et al.[16] spherical harmonic model of Earth’s gravity field.
Originally at 10 arc-min resolution.
Negative values indicate the geoid is below the ellipsoid surface and vice-versa.
To convert a topographic grid which is referenced to the ellipsoid to be referenced
to the geoid, add this grid.
To convert a topographic grid which is referenced to the geoid to be referencde to
the ellipsoid, add this grid.
version=’burton-johnson-2020’
From Burton-Johnson et al.[23].
Accessed from supplementary material
Choose for either of grid, or the point measurements
Loads gravity anomaly data for the Arctic and Antarctic.
version=’antgg’
Antarctic-wide gravity data compilation of ground-based, airborne, and shipborne
data, from Scheinert et al.[30].
Accessed from https://doi.pangaea.de/10.1594/PANGAEA.848168
Anomalies are at the ice surface, or bedrock surface in areas of no ice. These
surfaces are defined by Bedmap2 and are relative to the ellipsoid.
version=’antgg-2021’
Updates on 2016 AntGG compilation.
Accessed from https://doi.pangaea.de/10.1594/PANGAEA.971238?format=html#download
Anomalies are at the ice surface, or bedrock surface in areas of no ice. These
surfaces are defined by Bedmap2 and are relative to the ellipsoid.
version (str) – choose which version of gravity data to fetch.
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3
registration (str, optional) – change registration with either ‘p’ for pixel or ‘g’ for gridline registration,
by default is None.
hemisphere (str, optional) – choose which hemisphere to retrieve data for, “north” or “south”, by default
None
kwargs (Any) – additional kwargs to pass to resample_grid and set the anomaly_type.
Keyword Arguments:
anomaly_type (str) – either ‘FA’ or ‘BA’, for free-air and bouguer anomalies, respectively. For
antgg-update can also be ‘DG’ for gravity disturbance, or ‘Err’ for error
estimates.
Returns:
Returns a loaded, and optional clip/resampled grid of either observed, free-air
or Bouguer gravity anomalies.
Load IBCSO v2 data, from Dorschel et al.[35] and
Dorschel et al.[36].
By default the elevations are relative to Mean Sea Level (the geoid). To convert
them to be relative to the WGS84 ellipsoid, set reference=”ellipsoid which will
add the EIGEN-6C4 geoid anomaly.
Parameters:
layer (str) – choose which layer to fetch:
‘surface’, ‘bed’
reference (str, optional) – choose which vertical reference to use, ‘geoid’ or ‘ellipsoid’, by default
‘geoid’
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 500m. If spacing >=
5000m, will resample the grid to 5km, and save it as a preprocessed grid, so
future fetch calls are performed faster.
registration (str, optional) – change registration with either ‘p’ for pixel or ‘g’ for gridline registration,
by default is None.
**kwargs (Any) – additional keyword arguments to pass to the resample_grid function
Returns:
Returns a loaded, and optional clip/resampled grid of IBCSO data.
Load IBCSO v2 data, from Dorschel et al.[35] and
Dorschel et al.[36].
Parameters:
region (tuple[float, float, float, float] or None) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
Returns:
Returns two geodataframes; points and polygons for a subset of IBCSO v2 point
measurement locations. Column ‘dataset_tid’ is the type identifier from IBCSO.
The points geodataframe contains all individual point measurements, including
single-beam (TID 10), seismic points (TID 12), isolated soundings (TID 13),
ENC sounding (TID 14), grounded iceberg draft (TID 46), and gravity-inverted
bathymetry (TID 45). The polygon geodataframe contains all polygon measurements,
including multi-beam (swath) (TID 11), contours from charts (TID 42), or
other unknown sources (TID 71).
Requires an EarthData login, see Tutorials/Download Polar datasets for how to
configure this.
Parameters:
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (float, optional,) – grid spacing to resample the loaded grid to, by default is 5km for Antarctica
(original data is 450m), and 250m for Greenland
registration (str, optional) – change registration with either ‘p’ for pixel or ‘g’ for gridline registration,
by default is None.
hemisphere (str, optional) – choose which hemisphere to retrieve data for, “north” or “south”, by default
None
kwargs (Any) – additional keyword arguments to pass to resample_grid
Returns:
Returns a calculated grid of ice velocity in meters/year.
Ice-sheet height and thickness changes from ICESat to ICESat-2 for both Antarctica
and Greenland from Smith et al.[45].
Choose a version of the data to download with the format: “ICESHEET_VERSION_TYPE”
where ICESHEET is “ais” or “gris”, for Antarctica or Greenland, VERSION is “dhdt”
for total thickness change or “dmdt” for corrected for firn-air content. For
Antarctic data, TYPE is “floating” or “grounded”.
add “_filt” to retrieve a filtered version of the data for some versions.
Requires an EarthData login, see Tutorials/Download Polar datasets for how to
configure this.
Parameters:
version (str, optional) – for Antarctica, choose between “750m” or “125m” resolutions, by default “750m”,
for Greenland, choose between “500m” or “100m” resolutions, by default “500m”
hemisphere (str, optional) – choose which hemisphere to retrieve data for, “north” or “south”, by default
None
version=’an-2015’
This is fetch.crustal_thickness(version=’an-2015)* -1
Documentation is unclear whether the An crust model from
An et al.[12] is crustal thickness or moho depths, or whether it
makes a big enough difference to matter.
version=’pappa-2019’
from Pappa et al.[48].
Accessed from supplement material
Parameters:
version (str) – Either ‘shen-2018’, ‘an-2015’, ‘pappa-2019’,
will add later: ‘lamb-2020’, ‘baranov’, ‘chaput’, ‘crust1’,
‘szwillus’, ‘llubes’,
region (tuple[float, float, float, float], optional) – region to clip the loaded grid to, in format [xmin, xmax, ymin, ymax], by
default doesn’t clip
spacing (int, optional) – grid spacing to resample the loaded grid to, by default spacing is read from
downloaded files
registration (str, optional,) – choose between ‘g’ (gridline) or ‘p’ (pixel) registration types, by default is
the original type of the grid
**kwargs (Any) – additional keyword arguments to pass to the resample_grid function
Returns:
Returns a loaded, and optional clip/resampled grid of crustal thickness.
Load the REMA surface elevation data from Howat et al.[5]. The data
are in EPSG3031 and reference to the WGS84 ellipsoid. To convert the data to be
geoid-referenced, subtract a geoid model, which you can get from fetch.geoid().
Choose between “1km” or “500m” resolutions with parameter version.
Resample a grid to a new spacing, region, and/or registration. Method of resampling
depends on comparison with initial and supplied values for spacing, region, and
registration. If initial values not supplied, will try and extract them from the
grid.
Add a colorbar based on the last cmap used by PyGMT and optionally a histogram of
the data values.
Parameters:
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, optional) – frame for the colorbar, by default None
verbose (str, optional) – verbosity level for pygmt, by default “w” for warnings
**kwargs (Any) – additional keyword arguments to pass
grid (str or xarray.DataArray) – Path to the grid file or an xarray DataArray containing the grid data.
cmap (str or bool, optional) – Colormap to use for the grid, by default “viridis”. If True, last used
colormap will be used.
shading (bool or str, optional) – If True, apply shading to the grid. If a string, it will be passed to
pygmt.grdshade as the shading argument. By default, False (no shading).
nan_transparent (bool, optional) – If True, set NaN values to be transparent in the grid image. Default is True
unless shading is False, in which case it is set to False.
colorbar (bool, optional) – If True, add a colorbar to the figure. Default is True.
**kwargs (Any) – Additional keyword arguments to pass
version (str | None, optional) – which version (resolution) of MODIS imagery to use, by default “750m” for
southern hemisphere and “500m” for northern hemisphere.
transparency (int, optional) – transparency of the MODIS imagery, by default 0
cmap (str, optional) – colormap to use for MODIS imagery, by default “grayC”
Add a simple basemap to a figure with grounded ice shown as grey and floating ice as
blue.
Parameters:
version (str | None, optional) – which version of shapefiles to use for grounding line / coastline, by default
“measures-v2” for southern hemisphere and “BAS” for northern hemisphere
transparency (int, optional) – transparency of all the plotted elements, by default 0
pen (str, optional) – GMT pen string for the coastline, by default “0.2p,black”
grounded_color (str, optional) – color for the grounded ice, by default “grey”
floating_color (str, optional) – color for the floating ice, by default “skyblue”
Create a figure basemap in polar stereographic projection, and add a range of
features such as coastline and grounding lines, inset figure location maps,
background imagery, scalebars, gridlines and northarrows. Plot supplied points with
either constant color or colored by a colormap. Reuse the figure instance to either
plot additional features on top, or shift the plot to create subplots. There are
many keyword arguments which can either be passed along to the various functions in
the maps module, or specified specifically. Kwargs can be passed directly to the
following functions: add_colorbar, add_north_arrow, add_scalebar, add_inset,
set_cmap. Other kwargs are specified below.
Parameters:
region (tuple[float, float, float, float] | None, optional) – region for the figure in format [xmin, xmax, ymin, ymax], by default None
hemisphere (str, optional) – set whether to plot in “north” hemisphere (EPSG:3413) or “south” hemisphere
(EPSG:3031), can be set manually, or will read from the environment variable:
“POLARTOOLKIT_HEMISPHERE”
coast (bool, optional) – choose whether to plot coastline and grounding line, by default False. Version
of shapefiles to plots depends on hemisphere, and can be changed with kwargs
coast_version, which defaults to BAS for the northern hemisphere and
measures-v2 for the southern.
north_arrow (bool, optional) – choose to add a north arrow to the plot, by default is False.
scalebar (bool, optional) – choose to add a scalebar to the plot, by default is False. See add_scalebar
for additional kwargs
faults (bool, optional) – choose to plot faults on the map, by default is False
simple_basemap (bool, optional) – choose to plot a simple basemap with floating ice colored blue and grounded ice
colored grey, with boarders defined by simple_basemap_version.
simple_basemap_transparency (int, optional) – transparency to use for the simple basemap, by default is 0
simple_basemap_version (str, optional) – version of the simple basemap to plot, by default is None
imagery_basemap (bool, optional) – choose to add a background imagery basemap, by default is False. If true, will
use LIMA for southern hemisphere and MODIS MoG for the northern hemisphere.
imagery_transparency (int, optional) – transparency to use for the imagery basemap, by default is 0
modis_basemap (bool, optional) – choose to add a MODIS background imagery basemap, by default is False.
modis_transparency (int, optional) – transparency to use for the MODIS basemap, by default is 0
modis_version (str, optional) – version of the MODIS basemap to plot, by default is None
title (str | None, optional) – title to add to the figure, by default is None
inset (bool, optional) – choose to plot inset map showing figure location, by default is False
points (pandas.DataFrame | None, optional) – points to plot on map, must contain columns ‘x’ and ‘y’ or
‘easting’ and ‘northing’.
gridlines (bool, optional) – choose to plot lat/lon grid lines, by default is False
origin_shift (str, | None, optional) – choose what to do with the plot when creating the figure. By default is
‘initialize’ which will create a new figure instance. To plot additional grids
on top of the existing figure provide a figure instance to fig and set
origin_shift to None. To create subplots, provide the existing figure instance
to fig, and set origin_shift to ‘x’ to add the the new plot to the right of
previous plot, ‘y’ to add the new plot above the previous plot, or ‘both’ to add
the new plot to the right and above the old plot. By default each of this shifts
will be the width/height of the figure instance, this can be changed with kwargs
xshift_amount and yshift_amount, which are in multiples of figure
width/height.
fig (pygmt.Figure, optional) – supply a figure instance for adding subplots or using other PyGMT plotting
methods, by default None
fig_height (int or float) – height in cm for figures, by default is 15cm.
fig_width (int or float) – width in cm for figures, by default is None and is determined by fig_height and
the projection.
xshift_amount (int or float) – amount to shift the origin in the x direction in multiples of current figure
instance width, by default is 1.
yshift_amount (int or float) – amount to shift the origin in the y direction in multiples of current figure
instance height, by default is -1.
frame (str | bool) – GMT frame string to use for the basemap, by default is “nesw+gwhite”
frame_pen (str) – GMT pen string to use for the frame, by default is “auto”
frame_font (str) – GMT font string to use for the frame, by default is “auto”
transparency (int) – transparency to use for the basemap, by default is 0
inset_position (str) – position for inset map with PyGMT syntax, by default is “jTL+jTL+o0/0”
title_font (str) – font to use for the title, by default is ‘auto’
show_region (tuple[float, float, float, float]) – show a rectangular region on the map, in the format [xmin, xmax, ymin, ymax].
region_pen (str) – GMT pen string to use for the region box, by default is None
x_spacing (float) – spacing for x gridlines in degrees, by default is None
y_spacing (float) – spacing for y gridlines in degrees, by default is None
points_style (str) – style of points to plot in GMT format, by default is ‘c.2c’.
points_fill (str) – fill color of points, either string of color name or column name to color
points by, by default is ‘black’.
points_pen (str) – pen color and width of points, by default is ‘1p,black’ if constant color or
None if using a cmap.
points_label (str) – label to add to legend, by default is None
points_cmap (str) – GMT color scale to use for coloring points, by default ‘viridis’. If True, will
use the last used in PyGMT.
cpt_lims (str or tuple]) – limits to use for color scale max and min, by default is max and min of data.
cmap_region (str or tuple[float, float, float, float]) – region to use to define color scale limits, in format [xmin, xmax, ymin, ymax],
by default is region
robust (bool) – use the 2nd and 98th percentile (or those specified with ‘robust_percentiles’)
of the data to set color scale limits, by default is False.
robust_percentiles (tuple[float, float]) – percentiles to use for robust colormap limits, by default is (0.02, 0.98).
reverse_cpt (bool) – reverse the color scale, by default is False.
Add points to a geoviews map instance.
:type points: DataFrame
:param points: points to plot on the map, by default None
:type points: pandas.DataFrame
:type points_z: str | None
:param points_z: column name to color the points by, by default None
:type points_z: str | None, optional
:type points_color: str
:param points_color: color for the points, by default “red”
:type points_color: str, optional
:type points_cmap: str
:param points_cmap: colormap to use to color the points based on points_z, by default “viridis”
:type points_cmap: str, optional
Plot an interactive map with satellite imagery. Clicking gives the cursor location
in a Polar Stereographic projection [x,y]. Requires ipyleaflet
Parameters:
hemisphere (str, optional) – choose between plotting in the “north” or “south” hemispheres
center_yx (tuple, optional) – choose center coordinates in EPSG3031 [y,x], by default [0,0]
zoom (float, optional) – choose zoom level, by default None
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 (pandas.DataFrame, optional) – choose to plot points supplied as columns ‘x’, ‘y’, or ‘easting’, ‘northing’, in
EPSG:3031 in a dataframe
basemap_type (str, optional) – choose what basemap to plot, options are ‘BlueMarble’, ‘Imagery’, ‘Basemap’, and
“IceVelocity”, by default ‘BlueMarble’ for northern hemisphere and ‘Imagery’ for
southern hemisphere.
Plot a grid (either a filename or a load dataarray) with PyGMT in a polar
stereographic projection, and add a range of features such as coastline and
grounding lines, inset figure location maps, background imagery, colorbar histogram,
scalebars, gridlines and northarrows. Reuse the figure instance to either plot
additional features on top, or shift the plot to create subplots. There are many
keyword arguments which can either be passed along to the various functions in the
maps module, or specified specifically. Kwargs can be passed directly to the
following functions: add_colorbar, add_north_arrow, add_scalebar, add_inset,
set_cmap. Other kwargs are specified below.
Parameters:
grid (str or xarray.DataArray) – grid file to plot, either loaded xarray.DataArray or string of the path to a
gridded data file, such as a netCDF, geotiff or zarr file.
region (tuple[float, float, float, float], optional) – region for the figure in format [xmin, xmax, ymin, ymax], by default is the
extent of the input grid. If provided, the grid will be cut to this region
before plotting.
hemisphere (str, optional) – set whether to plot in “north” hemisphere (EPSG:3413) or “south” hemisphere
(EPSG:3031), can be set manually, or will read from the environment variable:
“POLARTOOLKIT_HEMISPHERE”
coast (bool, optional) – choose whether to plot coastline and grounding line, by default False. Version
of shapefiles to plots depends on hemisphere, and can be changed with kwargs
coast_version, which defaults to BAS for the northern hemisphere and
measures-v2 for the southern.
north_arrow (bool, optional) – choose to add a north arrow to the plot, by default is False.
scalebar (bool, optional) – choose to add a scalebar to the plot, by default is False. See add_scalebar
for additional kwargs
faults (bool, optional) – choose to plot faults on the map, by default is False
simple_basemap (bool, optional) – choose to plot a simple basemap with floating ice colored blue and grounded ice
colored grey.
simple_basemap_transparency (int, optional) – transparency to use for the simple basemap, by default is 0
simple_basemap_version (str, optional) – version of the simple basemap to plot, by default is None
imagery_basemap (bool, optional) – choose to add a background imagery basemap, by default is False. If true, will
use LIMA for southern hemisphere and MODIS MoG for the northern hemisphere.
imagery_transparency (int, optional) – transparency to use for the imagery basemap, by default is 0
modis_basemap (bool, optional) – choose to add a MODIS background imagery basemap, by default is False.
modis_transparency (int, optional) – transparency to use for the MODIS basemap, by default is 0
modis_version (str, optional) – version of the MODIS basemap to plot, by default is None
title (str | None, optional) – title to add to the figure, by default is None
inset (bool, optional) – choose to plot inset map showing figure location, by default is False
points (pandas.DataFrame | None, optional) – points to plot on map, must contain columns ‘x’ and ‘y’ or
‘easting’ and ‘northing’.
gridlines (bool, optional) – choose to plot lat/lon grid lines, by default is False
origin_shift (str, | None, optional) – choose what to do with the plot when creating the figure. By default is
‘initialize’ which will create a new figure instance. To plot additional grids
on top of the existing figure provide a figure instance to fig and set
origin_shift to None. To create subplots, provide the existing figure instance
to fig, and set origin_shift to ‘x’ to add the the new plot to the right of
previous plot, ‘y’ to add the new plot above the previous plot, or ‘both’ to add
the new plot to the right and above the old plot. By default each of this shifts
will be the width/height of the figure instance, this can be changed with kwargs
xshift_amount and yshift_amount, which are in multiples of figure
width/height.
fig (pygmt.Figure, optional) – supply a figure instance for adding subplots or using other PyGMT plotting
methods, by default None
fig_height (int or float) – height in cm for figures, by default is 15cm.
fig_width (int or float) – width in cm for figures, by default is None and is determined by fig_height and
the projection.
xshift_amount (int or float) – amount to shift the origin in the x direction in multiples of current figure
instance width, by default is 1.
yshift_amount (int or float) – amount to shift the origin in the y direction in multiples of current figure
instance height, by default is -1.
frame (str | bool) – GMT frame string to use for the basemap, by default is “nesw+gwhite”
frame_pen (str) – GMT pen string to use for the frame, by default is “auto”
frame_font (str) – GMT font string to use for the frame, by default is “auto”
transparency (int) – transparency to use for the basemap, by default is 0
modis (bool) – set to True if plotting MODIS data to use a nice colorscale.
grd2cpt (bool) – use GMT module grd2cpt to set color scale from grid values, by default is False
cpt_lims (str or tuple]) – limits to use for color scale max and min, by default is max and min of data.
cmap_region (str or tuple[float, float, float, float]) – region to use to define color scale limits, in format [xmin, xmax, ymin, ymax],
by default is region
robust (bool) – use the 2nd and 98th percentile (or those specified with ‘robust_percentiles’)
of the data to set color scale limits, by default is False.
robust_percentiles (tuple[float, float]) – percentiles to use for robust colormap limits, by default is (0.02, 0.98).
reverse_cpt (bool) – reverse the color scale, by default is False.
shp_mask (geopandas.GeoDataFrame | str) – shapefile to use to mask the grid before extracting limits, by default is None.
colorbar (bool) – choose to add a colorbar to the plot, by default is True.
Function used to set the PyGMT colormap for a figure.
Parameters:
cmap (str | bool) – a string of either a PyGMT cpt file (.cpt), or a preset PyGMT color ramp, or
alternatively a value of True will use the last used cmap.
grid (str | xarray.DataArray | None, optional) – grid used to determine colormap limits and grd2cpt colormap equalization, by
default None
points (pandas.Series | numpy.ndarray | None, optional) – point values to use to determine colormap limits, by default None
modis (bool, optional) – choose appropriate cmap for plotting modis data, by default False
grd2cpt (bool, optional) – equalized the colormap to the grid data values, by default False
cpt_lims (tuple[float, float] | None, optional) – limits to set for the colormap, by default None
cmap_region (tuple[float, float, float, float] | None, optional) – extract colormap limits from a subset of the grid or points, in format
[xmin, xmax, ymin, ymax], by default None
robust (bool, optional) – use the 2nd and 98th percentile of the data from the grid or points, by default
False
robust_percentiles (tuple[float, float], optional) – percentiles to use for robust colormap limits, by default (0.02, 0.98)
absolute (bool, optional) – use the absolute value of the data from the grid or points, by default False
reverse_cpt (bool, optional) – change the direction of the cmap, by default False
shp_mask (geopandas.GeoDataFrame | str | None, optional) – a shapefile to mask the grid or points by before extracting limits, by default
None
hemisphere (str | None, optional) – “north” or “south” hemisphere needed for using shp_mask, by default None
colorbar (bool, optional) – tell subsequent plotting functions whether to add a colorbar, by default True
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 xarray.DataArray’s to be plotted
hemisphere (str, optional) – choose between plotting in the “north” or “south” hemispheres, by default None
region (tuple[float, float, float, float], optional) – choose to subset the grids to a specified region, in format
[xmin, xmax, ymin, ymax], 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.
fig_title (str, optional) – add a title to the figure, by default None
fig_x_axis_title (str, optional) – add a title to the x axis of the figure, by default None
fig_y_axis_title (str, optional) – add a title to the y axis of the figure, by default None
fig_title_font (str, optional) – font for the figure title, by default “30p,Helvetica-Bold”
subplot_labels (bool, optional) – add subplot labels (a, b, c …), by default True
subplot_labels_loc (str, optional) – location of subplot labels, by default “TL”
row_titles (list, optional) – add titles to the left of each row, by default None
column_titles (list, optional) – add titles above each column, by default None
Fetch default ice surface, ice base, and bed layers.
Parameters:
version (str) – choose between ‘bedmap2’, ‘bedmap3’, and ‘bedmachine’ layers for Antarctica, and
just ‘bedmachine’ Greenland
hemisphere (str, optional) – choose between plotting in the “north” or “south” hemispheres, by default None
reference (str, optional) – choose between ‘ellipsoid’, ‘eigen-6c4’ or ‘eigen-gl04c’ (only for bedmap),
for an elevation reference frame, by default None
region (tuple[float], optional) – region to subset grids by, in format [xmin, xmax, ymin, ymax], by default None
spacing (float, optional) – grid spacing to resample the grids to, by default None
verbose (str, optional) – verbosity level for fetch calls, by default “e” for errors
axes (list[int]) – y axes to use for each data. By default all data are on axis 0. Only 0 and 1 are
used, if you supply values > 1, they will use the same axis as 1.
Show sampled data on a cross section, with an optional location map.
Parameters:
method (str) – Choose sampling method, either “points”, “shapefile”, or “polyline”
data_dict (dict, optional) – nested dictionary of data to include in option graph, construct with
profiles.make_data_dict, by default is gravity and magnetic anomalies.
add_map (bool) – Choose whether to add a location map, by default is False.
fig_height (float, optional) – Set the height of the figure (excluding the map) in cm, by default is 9.
fig_width (float, optional) – Set the width of the figure (excluding the map) in cm, by default is 14.
hemisphere (str, optional) – choose between plotting in the “north” or “south” hemispheres, by default None
Show sampled layers and/or data on a cross section, with an optional location map.
Parameters:
method (str) – Choose sampling method, either “points”, “shapefile”, or “polyline”
layers_dict (dict, optional) – nested dictionary of layers to include in cross-section, construct with
profiles.make_data_dict, by default is created from Bedmap2, Bedmap3, or
Bedmachine data, as chosen from layers_version.
data_dict (dict, optional) – nested dictionary of data to include in option graph, construct with
profiles.make_data_dict, by default is gravity and magnetic anomalies.
add_map (bool) – Choose whether to add a location map, by default is False.
layers_version (str, optional) – choose between using ‘bedmap2’, ‘bedmap3’ or ‘bedmachine’ layers, the default
for Antarctica is Bedmap3 and for Greenland is BedMachine.
fig_height (float, optional) – Set the height of the figure (excluding the map) in cm, by default is 9.
fig_width (float, optional) – Set the width of the figure (excluding the map) in cm, by default is 14.
hemisphere (str, optional) – choose between plotting in the “north” or “south” hemispheres, by default None
default_layers_spacing (float) – Spacing to use for layers grid, by default, if profile is longer than 2000 km,
will use 5 km for faster plotting, or else it will default to the grids’ native
resolution.
default_layers_reference (str) – Vertical reference frame to use for elevation grids, by default uses defaults
from fetch functions for layers_version.
fillnans (bool) – Choose whether to fill nans in layers, defaults to True.
num (int) – Number of points to sample at along a line.
Plot an interactive map, and use the “Draw a Rectangle” button to draw a rectangle
and get the bounding region. Vertices will be returned as the output of the
function.
Returns:
Returns a list of list of vertices for each polyline.
filter_width (float | None, optional) – width of the filter in meters for high and low pass filtering, by default None
filt_type (str, optional) – type of filter to use from ‘lowpass’, ‘highpass’ ‘up_deriv’, ‘easting_deriv’,
‘northing_deriv’, or ‘total_gradient’ by default “lowpass”
pad_width_factor (int, optional) – factor of grid width to pad the grid by, by default 3, which equates to a pad
with a width of 1/3 of the grid width.
pad_mode (str, optional) – mode of padding, can be “linear”, by default “linear_ramp”
pad_constant (float | None, optional) – constant value to use for padding, by default None
pad_end_values (float | None, optional) – value to use for end of padding if pad_mode is “linear_ramp”, by default None
shapefile (Union[str or geopandas.GeoDataFrame], optional) – path or loaded shapefile to use for a mask, by default None
robust (bool, optional) – choose whether to return the 2nd and 98th percentile values, instead of the
min/max
region (tuple[float, float, float, float], optional) – give a subset region to get min and max values from, in format
[xmin, xmax, ymin, ymax], by default None
hemisphere (str, optional) – set whether to lat lon projection is for “north” hemisphere (EPSG:3413) or
“south” hemisphere (EPSG:3031)
absolute (bool, optional) – choose whether to return the absolute min and max values, by default False
robust_percentiles (tuple[float, float], optional) – percentiles to use for robust min and max values, by default (0.02, 0.98)
shapefile (Union[str or geopandas.GeoDataFrame], optional) – path or loaded shapefile to use for a mask, by default None
robust (bool, optional) – choose whether to return the 2nd and 98th percentile values, instead of the
min/max
region (tuple[float, float, float, float], optional) – give a subset region to get min and max values from, in format
[xmin, xmax, ymin, ymax], by default None
hemisphere (str, optional) – set whether to lat lon projection is for “north” hemisphere (EPSG:3413) or
“south” hemisphere (EPSG:3031)
absolute (bool, optional) – return the absolute min and max values, by default False
robust_percentiles (tuple[float, float], optional) – decimal percentiles to use for robust min and max, by default (0.02, 0.98)
hemisphere (str, optional) – choose between the “north” or “south” hemispheres
invert (bool, optional) – reverse the sense of masking, by default False
drop_nans (bool, optional) – drop nans after masking, by default False
grid (Union[str, xarray.DataArray], optional) – grid to mask, by default None
region (tuple[float, float, float, float], optional) – region to create a grid if none is supplied, in format [xmin, xmax, ymin, ymax],
by default None
spacing (int, optional) – spacing to create a grid if none is supplied, by default None
Create a mask or a masked grid from area inside or outside of a closed shapefile.
Parameters:
shapefile (str or geopandas.GeoDataFrame) – either path to .shp filename, must by in same directory as accompanying files :
.shx, .prj, .dbf, should be a closed polygon file, or shapefile which as already
been loaded into a geodataframe.
hemisphere (str, optional) – choose “north” for EPSG:3413 or “south” for EPSG:3031
invert (bool, optional) – choose whether to mask data outside the shape (False) or inside the shape
(True), by default True (masks inside of shape)
grid (xarray.DataArray or str, optional) – _xarray.DataArray or path to a .nc file; to use to define region, or to mask, by
default None
xr_grid (xarray.DataArray, optional) – deprecated, use grid instead, by default None
grid_file (str, optional) – deprecated, use grid instead, by default None
region (str or tuple[float, float, float, float], optional) – bounding region in format [xmin, xmax, ymin, ymax] in meters to create a dummy
grid if none are supplied, by default None
spacing (str or int, optional) – grid spacing in meters to create a dummy grid if none are supplied, by default
None
masked (bool, optional) – choose whether to return the masked grid (True) or the mask itself (False), by
default False
pixel_register (bool, optional) – choose whether the grid is pixel registered (True) or grid registered (False),
by default True
input_coord_names (tuple[str, str], optional) – set names for input coordinate columns, by default (“easting”, “northing”)
Returns:
Returns either a masked grid, or the mask grid itself.
Convert region in format [xmin, xmax, ymin, ymax] to bounding box format used for
icepyx:
[
lower left longitude,
lower left latitude,
upper right longitude,
upper right latitude
]
Same format as [xmin, ymin, xmax, ymax], used for bbox parameter of
geopandas.read_file
Parameters:
region (tuple[Any, Any, Any, Any]) – region boundaries in format [xmin, xmax, ymin, ymax] in meters or degrees.
Convert region bounds in format [xmin, xmax, ymin, ymax] to pandas dataframe with
coordinates of region corners, or reverse this if reverse is True.
Parameters:
region (tuple[Any, Any, Any, Any] | pandas.DataFrame) – bounding region in format [xmin, xmax, ymin, ymax] or, if reverse is True,
a DataFrame with coordinate columns with names set by cood_names
coord_names (tuple[str, str], optional) – names of input or output coordinate columns, by default (“easting”, “northing”)
reverse (bool, optional) – If True, convert from df to region tuple, else, convert from region tuple to df,
by default False
Returns:
Dataframe with easting and northing columns, and a row for each corner of the
region, or, if reverse is True, an array in the format
[xmin, xmax, ymin, ymax].
Convert coordinates from input CRS to output CRS. Coordinates can be supplied as a
dataframe with coordinate columns set by input_coord_names, or as a tuple of a list
of x coordinates and a list of y coordinates.
Parameters:
df (pandas.DataFrame or tuple[Any]) – input dataframe with easting/longitude and northing/latitude columns, or tuple
[x,y]
input_crs (str) – input CRS in EPSG format, e.g. “epsg:4326”
output_crs (str) – output CRS in EPSG format, e.g. “epsg:3413”
reg (bool, optional) – if true, returns a GMT formatted region string, by default False
input_coord_names (tuple, optional) – set names for input coordinate columns, by default “x”/”y” or
“easting”/”northing” if input_crs is “epsg:3413” or “epsg:3031”, or if input_crs
is “epsg_4326”, “lon”/”lat”
output_coord_names (tuple, optional) – set names for output coordinate columns, by default “x”/”y” if output_crs is
“epsg:3413” or “epsg:3031”, or if output_crs is “epsg_4326”, “lon”/”lat”.
Returns:
Updated dataframe with new latitude and longitude columns, numpy.ndarray in
format [xmin, xmax, ymin, ymax], or tuple in format [lat, lon]
From matplotlib/grid-strategy
Calculate the number of rows and columns based on the total number of items (n) to
make an arrangement as close to square as looks good.
Parameters:
n (int) – The number of total plots in the subplot
Returns:
Returns a tuple in the format (number of rows, number of columns), so for
example a 3 x 2 grid would be represented as (3,3), because there are 2
rows of length 3.