API Reference
Contents
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.
Utils#
- 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_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_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