API Reference#

Maps#

add_box(fig: pygmt.Figure, box: list, pen='2p,black')[source]#

Plot a GMT region as a box.

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

  • box (Union[list or np.ndarray]) – 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”

add_coast(fig: pygmt.Figure, region: Optional[str] = None, projection: Optional[str] = None, no_coast: bool = False, pen=None)[source]#

add coastline and groundingline to figure.

Parameters
  • fig (pygmt.Figure) –

  • region (Union[str or np.ndarray], 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”

add_colorbar(fig: pygmt.Figure, hist: bool = False, cpt_lims: Optional[list] = 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 (list, 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

add_gridlines(fig: pygmt.Figure, region: Optional[str] = None, projection: Optional[str] = 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 (Union[str or np.ndarray], 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.

add_inset(fig: pygmt.Figure, region: Optional[str] = None, inset_pos: str = 'TL', inset_width: float = 0.25, inset_reg: list = [- 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 (Union[str or np.ndarray], 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 (list, optional) – Region of Antarctica to plot for the inset map, by default is whole continent

add_scalebar(fig: pygmt.Figure, region: Optional[str] = None, projection: Optional[str] = None, **kwargs)[source]#

add lat lon grid lines and annotations to a figure.

Parameters
  • fig (pygmt.Figure instance) –

  • region (np.ndarray, 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.

basemap(region: Optional[str] = None, fig_height: float = 15, fig_width: Optional[float] = None, origin_shift: str = 'initialize', **kwargs)[source]#
geoviews_points(points: Optional[pandas.core.frame.DataFrame] = None, points_z: Optional[str] = None, points_color: str = 'red', points_cmap: str = 'viridis', **kwargs)[source]#
interactive_data(coast: bool = True, grid: Optional[xarray.core.dataarray.DataArray] = None, grid_cmap: str = 'inferno', points: Optional[pandas.core.frame.DataFrame] = None, points_z: Optional[str] = None, points_color: str = 'red', points_cmap: str = 'viridis', **kwargs)[source]#

plot points or grids on an interactive map using GeoViews

coastbool, optional

choose whether to plot Antarctic coastline data, by default True

gridxr.DataArray, optional

display a grid on the map, by default None

grid_cmapstr, optional

colormap to use for the grid, by default β€˜inferno’

pointspd.DataFrame, optional

points to display on the map, must have columns β€˜x’ and β€˜y’, by default None

points_zstr, optional

name of column to color points by, by default None

points_colorstr, optional

if no points_z supplied, color to use for all points, by default β€˜red’

points_cmapstr, optional

colormap to use for the points, by default β€˜viridis’

image = maps.interactive_data(

grid = bedmap2_bed, points = point_data, points_z = β€˜z_ellipsoidal’, )

image
>>> from antarctic_plots import maps, regions, fetch
...
>>> bedmap2_bed = fetch.bedmap2(layer='bed', region=regions.ross_ice_shelf)
>>> GHF_point_data = fetch.ghf(version='burton-johnson-2020', points=True)
...
>>> image = maps.interactive_data(
... grid = bedmap2_bed,
... points = GHF_point_data[['x','y','GHF']],
... points_z = 'GHF',
... )
>>> image
holoviews.Overlay

holoview/geoviews map instance

interactive_map(center_yx: Optional[list] = None, zoom: float = 0, display_xy: bool = True, show: bool = True, points: Optional[pandas.core.frame.DataFrame] = None, **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 displat the map, by default True

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

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

_summary_

Parameters
  • grids (list) – _description_

  • cmaps (list) – _description_

  • exaggeration (list) – _description_

  • view (list, optional) – _description_, by default [170, 30]

  • vlims (list, optional) – _description_, by default [-10000, 1000]

  • region (Union[str or np.ndarray], optional) – _description_, by default None

  • shp_mask (Union[str or gpd.GeoDataFrame], optional) – _description_, by default None

  • cpt_lims (list, optional) – _description_, by default None

  • colorbar (bool, optional) – _description_, by default True

Returns

_description_

Return type

_type_

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

Helps easily create PyGMT maps, individually or as subplots.

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

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

  • region (Union[str or np.ndarray], 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’.

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 (Union[str or np.ndarray]) – 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 (np.ndarray) – GMT-format region to use to plot a bounding regions.

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

  • fig (pygmt.Figure()) – if adding subplots, set the first returned figure to a variable, and add that variable as the kwargs β€˜fig’ to subsequent calls to plot_grd.

  • 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 antarctic_plots import maps
...
>>> fig = maps.plot_grd('grid1.nc')
>>> fig = maps.plot_grd(
... 'grid2.nc',
... origin_shift = 'xshift',
... fig = fig,
... )
...
>>> fig.show()
subplots(grids: list, region: Optional[str] = None, dims: Optional[tuple] = 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 (Union[str or np.ndarray], 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.

Returns

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

Return type

PyGMT.Figure()

Profile#

create_profile(method: str, start: Optional[numpy.ndarray] = None, stop: Optional[numpy.ndarray] = None, num: Optional[int] = None, shapefile: Optional[str] = None, polyline: Optional[pandas.core.frame.DataFrame] = None, **kwargs)[source]#

Create a pandas DataFrame of points along a line with multiple methods.

Parameters
  • method (str) – Choose sampling method, either β€œpoints”, β€œshapefile”, or β€œpolyline”

  • start (np.ndarray, optional) – Coordinates for starting point of profile, by default None

  • stop (np.ndarray, optional) – Coordinates for eding point of profile, by default None

  • num (int, optional) – Number of points to sample at, for β€œpoints” by default is 100, for other methods num by default is determined by shapefile or dataframe

  • shapefile (str, optional) – shapefile file name to create points along, by default None

  • polyline (pd.DataFrame, optional) – pandas dataframe with columns x and y as vertices of a polyline, by default None

Returns

Dataframe with β€˜x’, β€˜y’, and β€˜dist’ columns for points along line or shapefile path.

Return type

pd.Dataframe

cum_dist(df: pandas.core.frame.DataFrame, **kwargs)[source]#

calculate cumulative distance of points along a line.

Parameters

df (pd.DataFrame) – Dataframe containing columns x, y, and rel_dist

Returns

Returns orignal dataframe with additional column dist

Return type

pd.DataFrame

default_data(region=None) dict[source]#

Fetch default gravity and magnetic datasets.

Parameters

region (str or list[int], optional) – region of Antarctic to load, by default is data’s original region.

Returns

Nested dictionary of data and attributes

Return type

dict[dict]

default_layers(version, region=None) dict[source]#

Fetch default ice surface, ice base, and bed layers.

Parameters
  • version (str) – choose between β€˜bedmap2’ and β€˜bedmachine’ layers

  • region (str or list[int], optional) – region of Antarctic to load, by default is data’s original region.

Returns

Nested dictionary of earth layers and attributes

Return type

dict[dict]

draw_lines(**kwargs)[source]#

Plot an interactive map, and use the β€œDraw a Polyline” button to create vertices of a line. Verticles will be returned as the output of the function.

Returns

Returns a tuple of list of vertices for each polyline in lat long.

Return type

tuple

fill_nans(df)[source]#

Fill NaN’s in sampled layer with values from above layer.

Parameters

df (pd.DataFrame) – First 3 columns as they are assumed to by x, y, dist.

Returns

Dataframe with NaN’s of lower layers filled

Return type

pd.DataFrame

make_data_dict(names: list, grids: list, colors: list) dict[source]#

Create nested dictionary of data and attributes

Parameters
  • names (list[str]) – data names

  • grids (list[str or xarray.DataArray]) – files or xarray.DataArray’s

  • colors (list[str]) – colors to plot data

Returns

Nested dictionaries of grids and attributes

Return type

dict[dict]

plot_data(method: str, data_dict: dict, **kwargs)[source]#

Sample and plot data along a path.

Parameters
  • method (str) – Choose sampling method, either β€œpoints”, β€œshapefile”, or β€œpolyline”

  • data_dict (dict) – nested dictionary of data to include in option graph, construct with profile.make_data_dict.

Keyword Arguments
  • fillnans (bool) – Choose whether to fill nans in layers, defaults to True.

  • clip (bool) – Choose whether to clip the profile based on distance.

  • num (int) – Number of points to sample at along a line.

  • max_dist (int) – Clip all distances greater than.

  • min_dist (int) – Clip all distances less than.

  • data_buffer (float (0-1)) – Change vertical white space within data graph, by default is 0.1.

  • legend_loc (str) – Change the legend location with a GMT position string, by default is β€œJBR+jBL+o0c” which puts the Bottom Left corner of the legend in the Bottom Right corner of the plot, with 0 offset.

  • save (bool) – Choose to save the image, by default is False.

  • path (str) – Filename for saving image, by default is None.

plot_profile(method: str, layers_dict: Optional[dict] = None, data_dict: Optional[dict] = None, add_map: bool = False, layers_version='bedmap2', fig_height: float = 9, fig_width: float = 14, **kwargs)[source]#

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 profile.make_data_dict, by default is Bedmap2 layers.

  • data_dict (dict, optional) – nested dictionary of data to include in option graph, construct with profile.make_data_dict, by default is gravity and magnetic anomalies.

  • add_map (bool = False) – Choose whether to add a location map, by default is False.

  • layers_version (str, optional) – choose between using β€˜bedmap2’ or β€˜bedmachine’ layers, by default is β€˜bedmap2’

  • 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.

Keyword Arguments
  • fillnans (bool) – Choose whether to fill nans in layers, defaults to True.

  • clip (bool) – Choose whether to clip the profile based on distance.

  • num (int) – Number of points to sample at along a line.

  • max_dist (int) – Clip all distances greater than.

  • min_dist (int) – Clip all distances less than.

  • map_background (str or xarray.DataArray) – Change the map background by passing a filename string or grid, by default is imagery.

  • map_cmap (str) – Change the map colorscale by passing a valid GMT cmap string, by default is β€˜earth’.

  • map_buffer (float (0-1)) – Change map zoom as relative percentage of profile length, by default is 0.3.

  • layer_buffer (float (0-1)) – Change vertical white space within cross-section, by default is 0.1.

  • data_buffer (float (0-1)) – Change vertical white space within data graph, by default is 0.1.

  • legend_loc (str) – Change the legend location with a GMT position string, by default is β€œJBR+jBL+o0c” which puts the Bottom Left corner of the legend in the Bottom Right corner of the plot, with 0 offset.

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

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

  • save (bool) – Choose to save the image, by default is False.

  • path (str) – Filename for saving image, by default is None.

rel_dist(df: pandas.core.frame.DataFrame, reverse: bool = False)[source]#

calculate distance between x,y points in a dataframe, relative to the previous row.

Parameters
  • df (pd.DataFrame) – Dataframe containing columns x and y in meters.

  • reverse (bool, optional,) – choose whether to reverse the profile, by default is False

Returns

Returns original dataframe with additional column rel_dist

Return type

pd.DataFrame

sample_grids(df: pandas.core.frame.DataFrame, grid: str, name: str, **kwargs)[source]#

Sample data at every point along a line

Parameters
  • df (pd.DataFrame) – Dataframe containing columns β€˜x’, β€˜y’

  • grid (str or xr.DataArray) – Grid to sample, either file name or xr.DataArray

  • name (str,) – Name for sampled column

Returns

Dataframe with new column (name) of sample values from (grid)

Return type

pd.DataFrame

shorten(df, max_dist=None, min_dist=None, **kwargs)[source]#

Shorten a dataframe at either end based on distance column.

Parameters
  • df (pd.DataFrame) – Dataframe to shorten and recalculate distance, must contain β€˜x’, β€˜y’, β€˜dist’

  • max_dist (int, optional) – remove rows with dist>max_dist, by default None

  • min_dist (int, optional) – remove rows with dist<min_dist, by default None

Returns

Shortened dataframe

Return type

pd.DataFrame

Fetch#

class EarthDataDownloader[source]#

Adapted from IcePack: https://github.com/icepack/icepack/blob/master/icepack/datasets.py # noqa Either pulls login details from pre-set environment variables, or prompts user to input username and password.

IBCSO(layer: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load IBCSO v2 data, from Dorschel et al. 2022: The International Bathymetric Chart of the Southern Ocean Version 2. Scientific Data, 9(1), 275, https://doi.org/10.1038/s41597-022-01366-7

Accessed from https://doi.pangaea.de/10.1594/PANGAEA.937574?format=html#download

Parameters
  • layer (str) – choose which layer to fetch: β€˜surface’, β€˜bed’

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default

Returns

Returns a loaded, and optional clip/resampled grid of IBCSO data.

Return type

xr.DataArray

IBCSO_coverage(region: str, plot: bool = False)[source]#

Load IBCSO v2 data, from Dorschel et al. 2022: The International Bathymetric Chart of the Southern Ocean Version 2. Scientific Data, 9(1), 275, https://doi.org/10.1038/s41597-022-01366-7

Accessed from https://doi.pangaea.de/10.1594/PANGAEA.937574?format=html#download

Parameters
  • region (str or np.ndarray, optional) – GMT-format region to subset the data from.

  • plot (bool, optional) – choose whether to plot the resulting points on a map, by default is False

Returns

Returns a geodataframe of a subset of IBCSO v2 point measurement locations

Return type

gpd.GeoDataFrame

REMA(version: int = 1000.0, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load the REMA surface elevation data. 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.

from Howat et al. 2019: The Reference Elevation Model of Antarctica, The Cryosphere, 13, 665-674, https://doi.org/10.5194/tc-13-665-2019.

accessed from https://www.pgc.umn.edu/data/rema/

Parameters
  • version (int, optional,) – choose which resolution to fetch, either 1km or 500m, by default is 1000

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of the REMA DEM.

Return type

xr.DataArray

ROSETTA_gravity(shapefile: bool = False)[source]#

Load either a shapefile of ROSETTA-ice flightliens, or a dataframe of ROSETTA-Ice airborne gravity data over the Ross Ice Shelf. from Tinto et al. (2019). Ross Ice Shelf response to climate driven by the tectonic imprint on seafloor bathymetry. Nature Geoscience, 12( 6), 441– 449. https://doi.org/10.1038/s41561‐019‐0370‐2 Accessed from https://www.usap-dc.org/view/project/p0010035

This is only data from the first 2 of the 3 field seasons.

Columns: Line Number: The ROSETTA-Ice survey line number, >1000 are tie lines Latitude (degrees): Latitude decimal degrees WGS84 Longitude (degrees): Longitude decimal degrees WGS84 unixtime (seconds): The number of seconds that have elapsed since midnight

(00:00:00 UTC) on January 1st, 1970

Height (meters): Height above WGS84 ellipsoid x (meters): Polar stereographic projected coordinates true to scale at 71Β° S y (meters): Polar stereographic projected coordinates true to scale at 71Β° S FAG_levelled (mGal): Levelled free air gravity (centered on 0)

Parameters

shapefile (bool, optional) – If true, instead return a shapefile of flight line locations

Returns

Returns a dataframe containing the gravity data

Return type

pd.DataFrame

basement(plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load a grid of basement topography. Offshore and sub-Ross Ice Shelf basement topography. from Tankersley et al. 2022: https://onlinelibrary.wiley.com/doi/10.1029/2021GL097371 accessed from https://doi.pangaea.de/10.1594/PANGAEA.941238 offshore data from Lindeque et al. 2016: https://doi.org/10.1002/2016GC006401

Elevations are referenced to WGS84 (? need to check this!)

Parameters
  • plot (bool, optional) – plot the fetched grid, by default False

  • info (bool, optional) – print info on the fetched grid, by default False

Returns

dataarray of basement depths

Return type

xr.DataArray

bedmachine(layer: str, reference: str = 'eigen-6c4', plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, **kwargs) xarray.core.dataarray.DataArray[source]#

Load BedMachine data, from Morlighem et al. 2020: https://doi.org/10.1038/s41561-019-0510-8

Accessed from NSIDC via https://nsidc.org/data/nsidc-0756/versions/1. Also available from https://github.com/ldeo-glaciology/pangeo-bedmachine/blob/master/load_plot_bedmachine.ipynb # noqa

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

Surface and ice thickness are in ice equivalents. Actual snow surface is from REMA (Howat et al. 2019), 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)

Parameters
  • layer (str) – choose which layer to fetch: β€˜surface’, β€˜thickness’, β€˜bed’, β€˜firn’, β€˜geoid’, β€˜mapping’, β€˜mask’, β€˜errbed’, β€˜source’; β€˜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’

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of Bedmachine.

Return type

xr.DataArray

bedmap2(layer: str, reference: str = 'eigen-gl04c', plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, fill_nans=False, **kwargs) xarray.core.dataarray.DataArray[source]#

Load bedmap2 data as xarray.DataArrays from Fretwell et a. 2022: BEDMAP2 - Ice thickness, bed and surface elevation for Antarctica - gridding products (Version 1.0) [Data set]. NERC EDS UK Polar Data Centre. DOI: https://doi.org/10.5285/FA5D606C-DC95-47EE-9016-7A82E446F2F2 accessed from https://ramadda.data.bas.ac.uk/repository/entry/show?entryid=fa5d606c-dc95-47ee-9016-7a82e446f2f2. # noqa

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”, β€œthickness”, β€œthickness_uncertainty_5km”, β€œgl04c_geiod_to_WGS84”, β€œicebase”

  • reference (str) – choose whether heights are referenced to the β€˜eigen-6c4’ geoid, the WGS84 ellipsoid, β€˜ellipsoid’, or by default the β€˜eigen-gl04c’ geoid.

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

  • 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

Returns

Returns a loaded, and optional clip/resampled grid of Bedmap2.

Return type

xr.DataArray

bedmap_points(version: str, region: Optional[list] = None, plot: bool = False) pandas.core.frame.DataFrame[source]#

Load bedmap point data, choose from Bedmap 1, 2 or 3

version == β€˜bedmap1’

from Lythe, M. B. and Vaughan, D. G. 2000. BEDMAP-bed topography of the Antarctic, British Antarctic Survey, Natural Environment Research Council DOI: https://doi.org/10.5285/f64815ec-4077-4432-9f55-0ce230f46029 accessed from https://data.bas.ac.uk/full-record.php?id=GB/NERC/BAS/PDC/01619

version == β€˜bedmap2’

from Fretwell et al. 2013. Bedmap2: improved ice bed, surface and thickness datasets for Antarctica, The Cryosphere, 7, 375–393 DOI: https://doi.org/10.5285/2fd95199-365e-4da1-ae26-3b6d48b3e6ac accessed from https://data.bas.ac.uk/full-record.php?id=GB/NERC/BAS/PDC/01616

version == β€˜bedmap3’

Publication not released yet DOI: https://doi.org/10.5285/91523ff9-d621-46b3-87f7-ffb6efcd1847 accessed from https://data.bas.ac.uk/full-record.php?id=GB/NERC/BAS/PDC/01614

Parameters
  • version (str) – choose between β€˜bedmap1’, β€˜bedmap2’, or β€˜bedmap3’ point data

  • region (list, optional) – add a GMT region to subset the data by, by default None

  • bool (plot ;) – choose whether to show the points on a simple map

  • optional – choose whether to show the points on a simple map

Returns

Return a dataframe, optionally subset by a region

Return type

pd.DataFrame

crustal_thickness(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load 1 of x β€˜versions’ of Antarctic crustal thickness grids.

version=’shen-2018’ Crustal thickness (excluding ice layer) from Shen et al. 2018: The crust and upper mantle structure of central and West Antarctica from Bayesian inversion of Rayleigh wave and receiver functions. https://doi.org/10.1029/2017JB015346 Accessed from https://sites.google.com/view/weisen/research-products?authuser=0

version=’an-2015’ Crustal thickness (distance from solid (ice and rock) top to Moho discontinuity) from An et al. 2015: S-velocity Model and Inferred Moho Topography beneath the Antarctic Plate from Rayleigh Waves. J. Geophys. Res., 120(1),359–383, doi:10.1002/2014JB011332 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’

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (int, optional) – grid spacing to resample the loaded grid to, by default spacing is read from downloaded files

Returns

Returns a loaded, and optional clip/resampled grid of crustal thickness.

Return type

xr.DataArray

deepbedmap(plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load DeepBedMap data, from Leong and Horgan, 2020: https://doi.org/10.5194/tc-14-3687-2020 Accessed from https://zenodo.org/record/4054246#.Ysy344RByp0

Parameters
  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of DeepBedMap.

Return type

xr.DataArray

etopo(plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, **kwargs) xarray.core.dataarray.DataArray[source]#

Loads a grid of Antarctic topography from ETOPO1. Originally at 10 arc-min resolution, reference to mean sea-level

orignally from https://www.ncei.noaa.gov/access/metadata/landing-page/bin/iso?id=gov.noaa.ngdc.mgg.dem:316 # noqa Accessed via the Fatiando data repository https://github.com/fatiando-data/earth-topography-10arcmin # noqa

Parameters
  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of topography.

Return type

xr.DataArray

geoid(plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, **kwargs) xarray.core.dataarray.DataArray[source]#

Loads a grid of Antarctic geoid heights derived from the EIGEN-6C4 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 reference to the ellipsoid, subtract this grid.

orignally from https://dataservices.gfz-potsdam.de/icgem/showshort.php?id=escidoc:1119897 # noqa Accessed via the Fatiando data repository https://github.com/fatiando-data/earth-geoid-10arcmin # noqa

Parameters
  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of geoid height.

Return type

xr.DataArray

ghf(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, **kwargs) xarray.core.dataarray.DataArray[source]#

Load 1 of 6 β€˜versions’ of Antarctic geothermal heat flux data.

version=’an-2015’ From At et al. 2015: emperature, lithosphere–asthenosphere boundary, and heat flux beneath the Antarctic Plate inferred from seismic velocities http://dx.doi.org/doi:10.1002/2015JB011917 Accessed from http://www.seismolab.org/model/antarctica/lithosphere/index.html

version=’martos-2017’ From Martos et al. 2017: Heat flux distribution of Antarctica unveiled. Geophysical Research Letters, 44(22), 11417-11426, https://doi.org/10.1002/2017GL075609 Accessed from https://doi.pangaea.de/10.1594/PANGAEA.882503

verion=’shen-2020’: From Shen et al. 2020; A Geothermal Heat Flux Map of Antarctica Empirically Constrained by Seismic Structure. https://doi.org/ 10.1029/2020GL086955 Accessed from https://sites.google.com/view/weisen/research-products?authuser=0 Used https://paperform.co/templates/apps/direct-download-link-google-drive/ to generate a direct download link from google drive page. https://drive.google.com/uc?export=download&id=1Fz7dAHTzPnlytuyRNctk6tAugCAjiqzR

version=’burton-johnson-2020’ From Burton-Johnson et al. 2020: Review article: Geothermal heat flow in Antarctica: current and future directions, https://doi.org/10.5194/tc-14-3843-2020 Accessed from supplementary material Choose for either of grid, or the point measurements

version=’losing-ebbing-2021’ From Losing and Ebbing 2021: Predicting Geothermal Heat Flow in Antarctica With a Machine Learning Approach. Journal of Geophysical Research: Solid Earth, 126(6), https://doi.org/10.1029/2020JB021499 Accessed from https://doi.pangaea.de/10.1594/PANGAEA.930237

version=’aq1’ From Stal et al. 2021: Antarctic Geothermal Heat Flow Model: Aq1. DOI: https://doi.org/10.1029/2020GC009428 Accessed from https://doi.pangaea.de/10.1594/PANGAEA.924857

Parameters
  • version (str) – Either β€˜burton-johnson-2020’, β€˜losing-ebbing-2021’, β€˜aq1’,

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (int, optional) – grid spacing to resample the loaded grid to, by default spacing is read from downloaded files

Returns

Returns a loaded, and optional clip/resampled grid of GHF data.

Return type

xr.DataArray

gia(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load 1 of 1 β€˜versions’ of Antarctic glacial isostatic adjustment grids.

version=’stal-2020’ From Stal et al. 2020: Review article: The Antarctic crust and upper mantle: a flexible 3D model and framework for interdisciplinary research, https://doi.org/10.5194/tc-14-3843-2020 Accessed from https://doi.org/10.5281/zenodo.4003423

Parameters
  • version (str) – For now the only option is β€˜stal-2020’,

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (int, optional) – grid spacing to resample the loaded grid to, by default spacing is read from downloaded files

Returns

Returns a loaded, and optional clip/resampled grid of GIA data.

Return type

xr.DataArray

gravity(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, **kwargs) xarray.core.dataarray.DataArray[source]#

Loads 1 of 3 β€˜versions’ of Antarctic gravity grids.

version=’antgg’ Antarctic-wide gravity data compilation of ground-based, airborne, and shipborne data, from Scheinert et al. 2016: New Antarctic gravity anomaly grid for enhanced geodetic and geophysical studies in Antarctica. DOI: https://doi.org/10.1002/2015GL067439 Accessed from https://doi.pangaea.de/10.1594/PANGAEA.848168

version=’antgg-update’ Preliminary compilation of Antarctica gravity and gravity gradient data. Updates on 2016 AntGG compilation. Accessed from https://ftp.space.dtu.dk/pub/RF/4D-ANTARCTICA/

version=’eigen’ Earth gravity grid (eigen-6c4) at 10 arc-min resolution at 10km geometric height. orignally from https://dataservices.gfz-potsdam.de/icgem/showshort.php?id=escidoc:1119897 # noqa Accessed via the Fatiando data repository https://github.com/fatiando-data/earth-gravity-10arcmin # noqa

Parameters
  • version (str) – choose which version of gravity data to fetch.

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

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.

Return type

xr.DataArray

groundingline(version: str = 'depoorter-2013') str[source]#

Load the file path of two versions of groundingline shapefiles

version = β€œdepoorter-2013” from https://doi.pangaea.de/10.1594/PANGAEA.819147 Supplement to Depoorter et al. 2013: https://doi.org/10.1038/nature12567

version = β€œmeasures-v2” from Mouginot, J., B. Scheuchl, and E. Rignot. (2017). MEaSUREs Antarctic Boundaries for IPY 2007-2009 from Satellite Radar, Version 2 [Data Set]. Boulder, Colorado USA. NASA National Snow and Ice Data Center Distributed Active Archive Center. https://doi.org/10.5067/AXE4121732AD. accessed at https://nsidc.org/data/nsidc-0709/versions/2

Parameters

version (str, optional) – choose which version to retrieve, by default β€œdepoorter-2013”

Returns

file path

Return type

str

ice_vel(plot: bool = False, info: bool = False, region=None, spacing=None, registration=None, **kwargs) xarray.core.dataarray.DataArray[source]#

MEaSUREs Phase-Based Antarctica Ice Velocity Map, version 1: from Mouginot, Rignot, and Scheuchl 2019. MEaSUREs Phase-Based Antarctica Ice Velocity Map, Version 1. Boulder, Colorado USA. NASA National Snow and Ice Data Center Distributed Active Archive Center. https://doi.org/10.5067/PZ3NJ5RXRH10. accessed from https://nsidc.org/data/nsidc-0754/versions/1#anchor-1 Data part of https://doi.org/10.1029/2019GL083826

Units are in m/yr

Parameters
  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3, original spacing is 450m

  • registration (str, optional) – set either β€˜p’ for pixel or β€˜g’ for gridline registration, by default is β€˜g’

Returns

Returns a calculated grid of ice velocity in meters/year.

Return type

xr.DataArray

imagery() xarray.core.dataarray.DataArray[source]#

Load the file path of Antarctic imagery geotiff from LIMA: https://lima.usgs.gov/fullcontinent.php will replace with below once figured out login issue with pooch MODIS Mosaic of Antarctica: https://doi.org/10.5067/68TBT0CGJSOJ Assessed from https://daacdata.apps.nsidc.org/pub/DATASETS/nsidc0730_MEASURES_MOA2014_v01/geotiff/ # noqa

Returns

file path

Return type

str

magnetics(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load 1 of 3 β€˜versions’ of Antarctic magnetic anomaly grid. version=’admap1’ ADMAP-2001 magnetic anomaly compilation of Antarctica. https://admap.kongju.ac.kr/databases.html

version=’admap2’ ADMAP2 magnetic anomaly compilation of Antarctica. Non-geosoft specific files provide from Sasha Golynsky.

version=’admap2_gdb’ Geosoft-specific .gdb abridged files. Accessed from https://doi.pangaea.de/10.1594/PANGAEA.892722?format=html#download

Parameters
  • version (str) – Either β€˜admap1’, β€˜admap2’, or β€˜admap2_gdb’

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of magnetic anomalies.

Return type

xr.DataArray

measures_boundaries(version: str) str[source]#

Load various files from the MEaSUREs Antarctic Boundaries for IPY 2007-2009

from Mouginot, J., B. Scheuchl, and E. Rignot. (2017). MEaSUREs Antarctic Boundaries for IPY 2007-2009 from Satellite Radar, Version 2 [Data Set]. Boulder, Colorado USA. NASA National Snow and Ice Data Center Distributed Active Archive Center. https://doi.org/10.5067/AXE4121732AD. accessed at https://nsidc.org/data/nsidc-0709/versions/2

Parameters

version (str,) – choose which file to retrieve from the following list: β€œCoastline”, β€œBasins_Antarctica”, β€œBasins_IMBIE”, β€œIceBoundaries”, β€œIceShelf”, β€œMask”

Returns

file path

Return type

str

modis_moa(version: int = 750) str[source]#

Load the MODIS MoA imagery in either 750m or 125m resolutions.

Parameters

version (int, optional) – choose between 750m or 125m resolutions, by default 750m

Returns

filepath for either 750m or 125m MODIS MoA Imagery

Return type

str

moho(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load 1 of x β€˜versions’ of Antarctic Moho depth grids.

version=’shen-2018’ Depth to the Moho relative to the surface of solid earth (bottom of ice/ocean) from Shen et al. 2018: The crust and upper mantle structure of central and West Antarctica from Bayesian inversion of Rayleigh wave and receiver functions. https://doi.org/10.1029/2017JB015346 Accessed from https://sites.google.com/view/weisen/research-products?authuser=0 Appears to be almost identical to crustal thickness from Shen et al. 2018

version=’an-2015’ This is fetch.crustal_thickness(version=’an-2015)* -1 Documentation is unclear whether the An crust model is crustal thickness or moho depths, or whether it makes a big enough difference to matter.

version=’pappa-2019’ from Pappa, F., Ebbing, J., & Ferraccioli, F. (2019). Moho depths of Antarctica: Comparison of seismic, gravity, and isostatic results. Geochemistry, Geophysics, Geosystems, 20, 1629– 1645. https://doi.org/10.1029/2018GC008111 Accessed from supplement material

Parameters
  • version (str) – Either β€˜shen-2018’, β€˜an-2015’, β€˜pappa-2019’, will add later: β€˜lamb-2020’, β€˜baranov’, β€˜chaput’, β€˜crust1’, β€˜szwillus’, β€˜llubes’,

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (int, optional) – grid spacing to resample the loaded grid to, by default spacing is read from downloaded files

Returns

Returns a loaded, and optional clip/resampled grid of crustal thickness.

Return type

xr.DataArray

resample_grid(grid, initial_spacing=None, initial_region=None, initial_registration=None, spacing=None, region=None, registration=None, verbose='w', **kwargs)[source]#
sample_shp(name: str) str[source]#

Load the file path of sample shapefiles

Parameters

name (str) – chose which sample shapefile to load, either β€˜Disco_deep_transect’ or β€˜Roosevelt_Island’

Returns

file path as a string

Return type

str

sediment_thickness(version: str, plot: bool = False, info: bool = False, region=None, spacing=None, registration=None) xarray.core.dataarray.DataArray[source]#

Load 1 of 4 β€˜versions’ of sediment thickness data.

version=’ANTASed’ From Baranov A, Morelli A and Chuvaev A (2021) ANTASed; An Updated Sediment Model for Antarctica. Front. Earth Sci. 9:722699. doi: 10.3389/feart.2021.722699 Accessed from https://www.itpz-ran.ru/en/activity/current-projects/antased-a-new-sediment-model-for-antarctica/ # noqa

version=’tankersley-2022’ From Tankersley, Matthew; Horgan, Huw J; Siddoway, Christine S; Caratori Tontini, Fabio; Tinto, Kirsty (2022): Basement topography and sediment thickness beneath Antarctica’s Ross Ice Shelf. Geophysical Research Letters. https://doi.org/10.1029/2021GL097371 Accessed from https://doi.pangaea.de/10.1594/PANGAEA.941238?format=html#download

version=’lindeque-2016’ From Lindeque, A et al. (2016): Preglacial to glacial sediment thickness grids for the Southern Pacific Margin of West Antarctica. Geochemistry, Geophysics, Geosystems, 17(10), 4276-4285. https://doi.org/10.1002/2016GC006401 Accessed from https://doi.pangaea.de/10.1594/PANGAEA.864906

version=’GlobSed’ From Straume, E. O., Gaina, C., Medvedev, S., Hochmuth, K., Gohl, K., Whittaker, J. M., et al. (2019). GlobSed: Updated total sediment thickness in the world’s oceans. Geochemistry, Geophysics, Geosystems, 20, 1756– 1772. https://doi.org/10.1029/2018GC008115 Accessed from https://ngdc.noaa.gov/mgg/sedthick/

Parameters
  • version (str,) – choose which version of data to fetch.

  • plot (bool, optional) – choose to plot grid, by default False

  • info (bool, optional) – choose to print info on grid, by default False

  • region (str or np.ndarray, optional) – GMT-format region to clip the loaded grid to, by default doesn’t clip

  • spacing (str or int, optional) – grid spacing to resample the loaded grid to, by default 10e3

Returns

Returns a loaded, and optional clip/resampled grid of sediment thickness.

Return type

xr.DataArray

Regions#

Bounding regions for commonly plotted Antarctic regions. In Polar Stereographic Projection (EPSG:3031). The format is [East, West, North, South], in meters.

combine_regions(region1: list, region2: list)[source]#

Get the bounding region of 2 regions.

Parameters
  • region1 (list) – first region

  • region2 (list) – second region

Returns

Bounding region of the 2 supplied regions.

Return type

list

draw_region(**kwargs)[source]#

Plot an interactive map, and use the β€œDraw a Rectangle” button to draw a rectangle and get the bounding region. Verticles will be returned as the output of the function.

Returns

Returns a tuple of list of vertices for each polyline.

Return type

tuple

Utils#

GMT_str_to_list(region: list)[source]#
RMSE(data)[source]#
alter_region(starting_region: numpy.ndarray, zoom: float = 0, n_shift: float = 0, w_shift: float = 0, buffer: float = 0, print_reg: bool = False)[source]#

Change a region string by shifting the box east/west or north/south, zooming in or out, or adding a seperate buffer region.

Parameters
  • starting_region (np.ndarray) – Initial GMT formatted region in meters, [e,w,n,s]

  • zoom (float, optional) – zoom in or out, in meters, by default 0

  • n_shift (float, optional) – shift north, or south if negative, in meters, by default 0

  • w_shift (float, optional) – shift west, or eash if negative, in meters, by default 0

  • buffer (float, optional) – create new region which is zoomed out in all direction, in meters, by default 0

  • print_reg (bool, optional) – print out the dimensions of the altered region, by default False

Returns

Returns of list of the following variables: region, buffer_region

Return type

list

block_reduce(df: pandas.core.frame.DataFrame, reduction: Callable, input_coord_names: list = ['x', 'y'], input_data_names: Optional[list] = None, **kwargs)[source]#
change_reg(grid)[source]#

Use GMT grdedit to change the registration type in the metadata.

Parameters

grid (xr.DataArray) – input grid to change the reg for.

Returns

returns a dataarray with switch reg type.

Return type

xr.DataArray

coherency(grids: list, label: str, **kwargs)[source]#

Compute and plot the Radially Averaged Power Spectrum input data.

Parameters
  • grids (list) – list of 2 grids to calculate the cohereny between. grid format can be str (filename), xr.DataArray, or pd.DataFrame.

  • label (str) – used to label line.

Keyword Arguments
  • region (Union[str, np.ndarray]) – grid region if input is pd.DataFrame

  • spacing (float) – grid spacing if input is pd.DataFrame

dd2dms(dd: float)[source]#

Convert decimal degrees to minutes, seconds. Modified from https://stackoverflow.com/a/10286690/18686384

Parameters

dd (float) – input decimal degrees

Returns

degrees in the format β€œDD:MM:SS”

Return type

str

epsg3031_to_latlon(df, reg: bool = False, input=['x', 'y'], output=['lon', 'lat'])[source]#

Convert coordinates from EPSG:3031 Antarctic Polar Stereographic in meters to EPSG:4326 WGS84 in decimal degrees.

Parameters
  • df (pd.DataFrame or list) – input dataframe with easting and northing columns, or list [x,y]

  • reg (bool, optional) – if true, returns a GMT formatted region string, by default False

  • input (list, optional) – set names for input columns, by default [β€œx”, β€œy”]

  • output (list, optional) – set names for output columns, by default [β€œlon”, β€œlat”]

Returns

Updated dataframe with new latitude and longitude columns, np.ndarray in format [e, w, n, s], or list in format [lat, lon]

Return type

pd.DataFrame or np.ndarray

get_fig_height(figure)[source]#
get_fig_width(figure)[source]#
get_grid_info(grid)[source]#

Returns information of the specified grid.

Parameters

grid (str or xarray.DataArray) – Input grid to get info from. Filename string or loaded grid.

Returns

(string of grid spacing, array with the region boundaries, data min, data max, grid registration)

Return type

list

get_min_max(grid: xarray.core.dataarray.DataArray, shapefile: Optional[str] = None)[source]#

Get a grids max and min values, optionally just for the region within a shapefile.

Parameters
  • grid (xr.DataArray) – grid to get values for

  • shapefile (Union[str or gpd.geodataframe.GeoDataFrame], optional) – path or loaded shapefile to use for a mask, by default None

Returns

returns the min and max values.

Return type

tuple

grd_blend(grid1: xarray.core.dataarray.DataArray, grid2: xarray.core.dataarray.DataArray, **kwargs)[source]#

Use GMT grdblend to blend 2 grids into 1.

Parameters
  • grid1 (xr.DataArray) – input grid to change the reg for.

  • grid2 (xr.DataArray) – input grid to change the reg for.

Returns

returns a blended dataarray.

Return type

xr.DataArray

grd_compare(da1: Union[xarray.core.dataarray.DataArray, str], da2: Union[xarray.core.dataarray.DataArray, str], plot: bool = False, plot_type: str = 'pygmt', **kwargs)[source]#

Find the difference between 2 grids and plot the results, if necessary resample and cut grids to match

Parameters
  • da1 (xr.DataArray or str) – first grid, loaded grid of filename

  • da2 (xr.DataArray or str) – second grid, loaded grid of filename

  • plot (bool, optional) – plot the results, by default False

  • plot_type (str, optional) – choose the style of plot, by default is pygmt, can choose xarray for faster, simplier plots.

Keyword Arguments
  • shp_mask (str) – shapefile filename to use to mask the grids for setting the color range.

  • robust (bool) – use xarray robust color lims instead of min and max, by default is False.

  • region (Union[str, np.ndarray]) – choose a specific region to compare.

  • rmse_in_title (bool) – add the RMSE to the title, by default is True.

Returns

list of xr.DataArrays: (diff, resampled grid1, resampled grid2)

Return type

list

grd_mask(df, spacing, region, clobber='o', values='0/0/1', radius='0c')[source]#
grd_trend(da: xarray.core.dataarray.DataArray, coords: list = ['x', 'y', 'z'], deg: int = 1, plot: bool = False, plot_type='pygmt', **kwargs)[source]#

Fit an arbitrary order trend to a grid and use it to detrend.

Parameters
  • da (xr.DataArray) – input grid

  • coords (list, optional) – coordinate names of the supplied grid, by default [β€˜x’, β€˜y’, β€˜z’]

  • deg (int, optional) – trend order to use, by default 1

  • plot (bool, optional) – plot the results, by default False

  • plot_type (str, by default "pygmt") – choose to plot results with pygmt or xarray

Returns

returns xr.DataArrays of the fitted surface, and the detrended grid.

Return type

tuple

latlon_to_epsg3031(df, reg: bool = False, input=['lon', 'lat'], output=['x', 'y'])[source]#

Convert coordinates from EPSG:4326 WGS84 in decimal degrees to EPSG:3031 Antarctic Polar Stereographic in meters.

Parameters
  • df (pd.DataFrame) – input dataframe with latitude and longitude columns

  • reg (bool, optional) – if true, returns a GMT formatted region string, by default False

  • input (list, optional) – set names for input columns, by default [β€œlon”, β€œlat”]

  • output (list, optional) – set names for output columns, by default [β€œx”, β€œy”]

Returns

Updated dataframe with new easting and northing columns or np.ndarray in format [e, w, n, s]

Return type

pd.DataFrame or np.ndarray

make_grid(region: Union[str, numpy.ndarray], spacing: float, value: float, name: str)[source]#

Create a grid with 1 variable by defining a region, spacing, name and constant value

Parameters
  • region (Union[str, np.ndarray]) – GMT format region for the inverion, by default is extent of gravity data,

  • spacing (float) – spacing for grid

  • value (float) – constant value to use for variable

  • name (str) – name for variable

Returns

Returns a xr.DataArray with 1 variable of constant value.

Return type

xr.DataArray

mask_from_polygon(polygon: list, invert: bool = False, drop_nans: bool = False, grid: Optional[Union[str, xarray.core.dataarray.DataArray]] = None, region: Optional[list] = None, spacing: Optional[int] = None, **kwargs)[source]#

convert the output of regions.draw_region to a mask or use it to mask a grid

Parameters
  • polygon (list) – list of polygon vertices

  • 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, xr.DataArray], optional) – grid to mask, by default None

  • region (list, optional) – region to create a grid if none is supplied, by default None

  • spacing (int, optional) – spacing to create a grid if none is supplied, by default None

Returns

masked grid or mask grid with 1’s inside the mask.

Return type

xr.Dataarray

mask_from_shp(shapefile: str, invert: bool = True, xr_grid=None, grid_file: Optional[str] = None, region=None, spacing=None, masked: bool = False, crs: str = 'epsg:3031', pixel_register=True, input_coord_names=('x', 'y'))[source]#

Create a mask or a masked grid from area inside or outside of a closed shapefile.

Parameters
  • shapefile (Union[str or gpd.geodataframe.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.

  • invert (bool, optional) – choose whether to mask data outside the shape (False) or inside the shape (True), by default True (masks inside of shape)

  • xr_grid (xarray.DataArray, optional) – _xarray.DataArray; to use to define region, or to mask, by default None

  • grid_file (str, optional) – path to a .nc or .tif file to use to define region or to mask, by default None

  • region (str or np.ndarray, optional) – GMT region string or 1x4 ndarray 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

  • crs (str, optional) – if grid is provided, rasterio needs to assign a coordinate reference system via an epsg code, by default β€œepsg:3031”

Returns

Returns either a masked grid, or the mask grid itself.

Return type

xarray.DataArray

points_inside_region(df: pandas.core.frame.DataFrame, region: list, names: list = ['x', 'y'], reverse: bool = False)[source]#

return a subset of a dataframe which is within a region

Parameters
  • df (pd.DataFrame) – dataframe with columns β€˜x’,’y’ to use for defining if within region

  • region (list) – GMT region string to use as bounds for new subset dataframe

  • names (list, optional) – list of column names to use for x and y coordinates, by default [β€œx”, β€œy”]

  • reverse (bool, optional) – if True, will return points outside the region, by default False

Returns

returns a subset dataframe

Return type

pd.DataFrame

polygon_to_region(polygon: list)[source]#

convert the output of regions.draw_region to bounding region in EPSG:3031

Parameters

polyon (list) – list of polygon vertices

Returns

list in format [e,w,n,s]

Return type

list

random_color()[source]#

generate a random color in format R/G/B

Returns

returns a random color string

Return type

str

raps(data: Union[pandas.core.frame.DataFrame, xarray.core.dataarray.DataArray, xarray.core.dataset.Dataset], names: numpy.ndarray, plot_type: str = 'mpl', filter: Optional[str] = None, **kwargs)[source]#

Compute and plot the Radially Averaged Power Spectrum input data.

Parameters
  • data (Union[pd.DataFrame, str, list, xr.Dataset, xr.Dataarray]) – if dataframe: need with columns β€˜x’, β€˜y’, and other columns to calc RAPS for. if str: should be a .nc or .tif file. if list: list of grids or filenames.

  • names (np.ndarray) – names of pd.dataframe columns, xr.dataset variables, xr.dataarray variable, or files to calculate and plot RAPS for.

  • plot_type (str, optional) – choose whether to plot with PyGMT or matplotlib, by default β€˜mpl’

  • filter (str) – GMT string to use for pre-filtering data, ex. β€œc100e3+h” is a 100km low-pass cosine filter, by default is None.

Keyword Arguments
  • region (Union[str, np.ndarray]) – grid region if input is not a grid

  • spacing (float) – grid spacing if input is not a grid

region_to_bounding_box(input)[source]#

Convert GMT region string [e, w, n, s] to bounding box format used for icepyx: [ lower left longitude,

lower left latitude, upper right longitude, uper right latitude

] Same format as [xmin, ymin, xmax, ymax], used for bbox parameter of geopandas.read_file

Parameters

input (np.ndarray) – Array of 4 strings in GMT format; [e, w, n, s] in meters or degrees.

Returns

Array of 4 strings in bounding box format.

Return type

list

region_to_df(input, names=['x', 'y'], reverse=False)[source]#

Convert region bounds in [e, w, n, s] (GMT format) to pandas dataframe with coordinates of region corners

Parameters
  • input (np.ndarray or pd.DataFrame) – Array of 4 strings in GMT format; [e, w, n, s], or, if reverse is True, a DataFrame with easting and northing columns with names set by names

  • names (list, optional) – List of names to use for easting and northing, by default [β€œx”, β€œy”]

  • reverse (bool, False) – If True, convert from df to region string.

Returns

Dataframe with easting and northing columns, and a row for each corner of the region, or, if reverse is True, a array in the format [e,w,n,s].

Return type

pd.DataFrame or np.ndarray

region_xy_to_ll(input, dms=False)[source]#

Convert GMT region string [e, w, n, s] in EPSG:3031 to lat / lon

Parameters
  • input (np.ndarray) – Array of 4 strings in GMT format; [e, w, n, s] in meters

  • dms (bool, False) – if True, will return results as deg:min:sec iinstead of decimal degrees

Returns

Array of 4 strings in GMT format; [e, w, n, s] in lat, lon

Return type

np.ndarray

set_proj(region: str, fig_height: float = 15, fig_width: Optional[float] = None) str[source]#

Gives GMT format projection string from region and figure height or width. Inspired from https://github.com/mrsiegfried/Venturelli2020-GRL.

Parameters
  • region (Union[str or np.ndarray]) – GMT-format region str or list (e, w, n, s) in meters EPSG:3031

  • fig_height (float) – desired figure height in cm

  • fig_width (float) – instead of using figure height, set the projection based on figure width in cm, by default is None

Returns

returns a list of the following variables: (proj, proj_latlon, fig_width, fig_height)

Return type

list

shapes_to_df(shapes: list)[source]#

convert the output of regions.draw_region and profile.draw_lines to a dataframe of x and y points

Parameters

shapes (list) – list of vertices

Returns

Dataframe with x, y, and shape_num.

Return type

pd.DataFrame

square_subplots(n: int)[source]#

From https://github.com/matplotlib/grid-strategy/blob/master/src/grid_strategy/strategies.py # noqa 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.

Return type

tuple