synthetic_bathymetry_inversion package

Submodules

synthetic_bathymetry_inversion.ice_shelf_stats module

synthetic_bathymetry_inversion.ice_shelf_stats.add_shelves_to_ensembles(x, y, ice_shelves, shelves_to_label=None, ax=None, col_to_add_to_label=None, legend=True, legend_cols=2, legend_loc='center left', legend_bbox_to_anchor=(1.3, 0.5), seperate_inverted_shelves=True, fontsize=8)

Add ice shelf labels to ensemble plots.

Parameters:
synthetic_bathymetry_inversion.ice_shelf_stats.add_single_constraint(ice_shelves, file_path=None, spacing=100, buffer=20000.0)

Add a single constraint to the ice shelf and recalculate the median minimum distance.

Parameters:
  • ice_shelves (GeoDataFrame)

  • file_path (str | None)

synthetic_bathymetry_inversion.ice_shelf_stats.combine_offshore_onshore_points(region, version='bedmachine', bedmap_version='all', grounded_as_points=False, spacing=1000.0)

Create a dataframe of constraint points for a region. The points are a combination of IBCSO v2 points offshore and your choice of bedmap or bedmachine points. The bedmap points can be either from bedmap versions 1,2,3 or all combined, or you can treat each grid cell (1km) of the Bedmap2 grid as a constraint point. The bedmachine points are extracted from the grid of data id values.

Parameters:
  • region (tuple[float, float, float, float]) – region to extract points for

  • version (str, optional) – choose between bedmachine or bedmap points, by default “bedmachine”

  • bedmap_version (str, optional) – choose which version of bedmap data to use, ‘bedmap1’, ‘bedmap2’, ‘bedmap3’, or ‘all’ combined, by default “all”

  • grounded_as_points (bool, optional) – treat grid cells of grounded ice as points rather than using bedmap points, by default False

  • spacing (float, optional) – sampling spacing to use for converted IBCSO multibeam polygons to points, by default 1e3

Returns:

a dataframe of constraint points

Return type:

pd.DataFrame

synthetic_bathymetry_inversion.ice_shelf_stats.constraints_and_min_distances(ice_shelves, buffer=20000.0, version='bedmachine', spacing=100, bedmap_version='all', grounded_as_points=False, file_path=None, plot=False, save_plot=False)

Compute the median of the minimum distances (in km) between each grid cell and the nearest constraint point (bedmap onshore, ibcso offshore) for each supplied ice shelf shapefile. Save the constraints to a csv and the minimum distance grid to a netcdf. Optionally, plot the results.

Parameters:
  • ice_shelves (gpd.GeoDataFrame) – ice shelf shapefiles, output from get_ice_shelves

  • buffer (float, optional) – buffer zone in meters around ice shelf bounding box to include points in, by default 20e3

  • spacing (float, optional) – grid spacing in meters to use for computing minimum distances and converted polygons to points, by default 100

  • bedmap_version (str, optional) – which bedmap points to include, either “bedmap1”, “bedmap2”, “bedmap3”, or “all”, by default “all”

  • grounded_as_points (bool, optional) – use bedmap grid cells as points rather than actual points, by default False

  • file_path (str | None, optional) – path to save the constraints and minimum distance files, by default None

  • plot (bool, optional) – show a plot for each ice shelf, by default False

  • version (str)

  • save_plot (bool)

Returns:

Ice shelf geodataframe with additional column “median_min_dist” containing the median minimum distance to the nearest point

Return type:

gpd.GeoDataFrame

synthetic_bathymetry_inversion.ice_shelf_stats.constraints_and_min_distances_single(ice_shelf, buffer=20000.0, spacing=100, version='bedmachine', bedmap_version='all', grounded_as_points=False, fname=None, plot=False, save_plot=False)

For an ice shelf, extract all available point measurements of bathymetry / bed topography in a region around the ice shelf. Save these to a csv, then compute a grid of the distance to the nearest points, and save this to a netcdf.

Parameters:
Return type:

None

synthetic_bathymetry_inversion.ice_shelf_stats.get_ice_shelves()

get a geodataframe of ice shelf shapefiles with some merged shelves.

synthetic_bathymetry_inversion.ice_shelf_stats.gravity_anomalies(ice_shelves, regional_grav_kwargs, buffer=10000.0, spacing=10000.0, progressbar=False, file_path=None, plot=False, save_plot=False)

Compute gravity anomalies for each ice shelf and save to csv.

Parameters:
Return type:

None

synthetic_bathymetry_inversion.ice_shelf_stats.gravity_anomalies_single(ice_shelf, regional_grav_kwargs, constraints_df, buffer=10000.0, spacing=10000.0, progressbar=False, fname=None, plot=False, save_plot=False)

Calculate gravity disturbance anomalies over an ice shelf region and the terrain mass effect components due to ice, water, and rock layers. Save the resulting datasets to csv files. Optionally plot the results.

Parameters:
Return type:

None

synthetic_bathymetry_inversion.ice_shelf_stats.load_constraints_and_min_distances(ice_shelves, file_path=None, plot=False, save_plot=False)

Load constraints and minimum distances for each ice shelf and calculate some statistics.

Parameters:
  • ice_shelves (GeoDataFrame)

  • file_path (str | None)

  • plot (bool)

  • save_plot (bool)

synthetic_bathymetry_inversion.ice_shelf_stats.load_grav_anomalies(ice_shelves, file_path=None, plot=False, save_plot=False)

Load gravity anomalies and calculate statistics for each ice shelf.

Parameters:
  • ice_shelves (GeoDataFrame)

  • file_path (str | None)

  • plot (bool)

  • save_plot (bool)

synthetic_bathymetry_inversion.ice_shelf_stats.load_ice_shelf_info(ice_shelves, file_path=None, plot=False, save_plot=False)

Go through each ice shelf and load saved constraint proximity and gravity anomaly data and calculate statistics. Optionally make subplots of this data for each ice shelf.

Parameters:
  • ice_shelves (GeoSeries)

  • file_path (str | None)

  • plot (bool)

  • save_plot (bool)

synthetic_bathymetry_inversion.ice_shelf_stats.load_ice_shelf_info_single(ice_shelf, file_path=None, plot=False, save_plot=False)

Load ice shelf bed constraint points and gravity anomalies from saved files, and calculated statistics on constraint proximity and gravity anomalies. Optionally make subplots of this data for the ice shelf.

Parameters:
  • ice_shelf (GeoSeries)

  • file_path (str | None)

  • plot (bool)

  • save_plot (bool)

synthetic_bathymetry_inversion.ice_shelf_stats.plot_constraints_and_min_distances(ice_shelf, min_dist, constraints_df, fname=None, show_plot=True)

Plot constraint proximity and the locations of the constraints for an ice shelf.

Parameters:
  • ice_shelf (GeoSeries)

  • min_dist (DataArray)

  • constraints_df (DataFrame)

  • fname (str | None)

  • show_plot (bool)

synthetic_bathymetry_inversion.ice_shelf_stats.plot_grav_anomalies(ice_shelf, grav_df, constraints_df, fname=None)

Plot gravity anomalies for a single ice shelf.

Parameters:
synthetic_bathymetry_inversion.ice_shelf_stats.plot_ice_shelf_info(ice_shelf, grav_df=None, constraints_df=None, min_dist=None, fig_path=None, show_plot=True)

Plot ice shelf information including constraint proximity and gravity anomalies.

Parameters:
synthetic_bathymetry_inversion.ice_shelf_stats.plot_ice_shelf_names(fig, ice_shelves, font='8p,Helvetica', offset='.4c/.4c+v.6p', justify='BL', shadow=True, shadow_font='2p,white', names_as_numbers=False)

Add ice shelf names to a pygmt map.

Parameters:
  • fig (Figure)

  • ice_shelves (GeoDataFrame)

synthetic_bathymetry_inversion.ice_shelf_stats.polygon_to_points(polygon, spacing=100)

Convert a polygon shapefile to a grid of points with a specified spacing. Also include the vertices of the polygon.

Parameters:
  • polygon (gpd.GeoSeries) – Polygon shapefile to convert to points

  • spacing (float, optional) – Spacing between points, by default 100

Returns:

Dataframe of points with columns “easting”, “northing”, and “geometry”

Return type:

pd.DataFrame

synthetic_bathymetry_inversion.ice_shelf_stats.polygons_to_points(polygons, spacing=100)

Convert a geodataframe of polygons to a grid of points with a specified spacing.

Parameters:
  • polygons (geopandas.GeoDataFrame) – Geodataframe of polygons to convert to points

  • spacing (float, optional) – Spacing between points, by default 100

Returns:

Dataframe of points with columns “easting”, “northing”, and “geometry”

Return type:

pd.DataFrame

synthetic_bathymetry_inversion.plotting module

synthetic_bathymetry_inversion.plotting.plot_2var_ensemble(df, x, y, figsize=(9, 6), x_title=None, y_title=None, background='score', background_title=None, background_cmap=<matplotlib.colors.LinearSegmentedColormap object>, background_lims=None, background_cpt_lims=None, points_color=None, points_share_cmap=False, points_size=None, points_scaling=1, points_label=None, points_title=None, points_color_log=False, points_cmap=<matplotlib.colors.LinearSegmentedColormap object>, points_lims=None, points_edgecolor='black', background_color_log=False, background_robust=False, points_robust=False, plot_contours=None, contour_color='black', plot_title=None, logx=False, logy=False, flipx=False, colorbar=True, colorbar_axes=(0.95, 0.1, 0.05, 0.8), constrained_layout=True)

plot 2D ensemble results with 1 axis for each ensemble variable, and background color showing the values of a 3rd variable (e.g., score). Optionally, overlay points colored by a 4th variable.

Parameters:
  • colorbar (bool)

  • colorbar_axes (tuple)

  • constrained_layout (bool)

synthetic_bathymetry_inversion.plotting.plot_ensemble_as_lines(results, x, y, groupby_col, figsize=(5, 3.5), x_lims=None, y_lims=None, x_label=None, y_label='Bathymetry RMSE (m)', cbar_label=None, markersize=7, logy=False, logx=False, trend_line=False, horizontal_line=None, horizontal_line_label=None, horizontal_line_label_loc='best', horizontal_line_color='gray', plot_title=None, slope_min_max=False, slope_min=False, slope_max=False, slope_mean=False, slope_decimals=3, trend_line_text_loc=(0.05, 0.95), flipx=False, colorbar=True, ax=None, plot_maximums=False, plot_minimums=False)

plot 2D ensemble results as lines with y axis as 1 ensemble variable and color as the other ensemble variable.

Parameters:

colorbar (bool)

synthetic_bathymetry_inversion.plotting.plotly_profiles(data, y, x='dist_along_line', y_axes=None, xlims=None, ylims=None, **kwargs)

plot data profiles with plotly currently only allows 3 separate y axes, set with “y_axes”, starting with 1

Parameters:

y (tuple[str])

synthetic_bathymetry_inversion.plotting.uncert_plots(results, inversion_region, bathymetry, deterministic_bathymetry=None, constraint_points=None, weight_by=None)

plot uncertainty results from invert4geom uncertainty module

synthetic_bathymetry_inversion.synthetic module

synthetic_bathymetry_inversion.synthetic.airborne_survey(along_line_spacing, grav_observation_height, region, ns_line_spacing=None, ew_line_spacing=None, ns_line_number=None, ew_line_number=None, padding=None, ns_lines_to_remove=None, ew_lines_to_remove=None, grav_grid=None, plot=False)

Create a synthetic airborne gravity survey within a rectangular region. Specify either number of lines or line spacing in each direction.

Parameters:
synthetic_bathymetry_inversion.synthetic.average_consecutive_difference(numbers)

Calculates the average difference between consecutive numbers in a list.

synthetic_bathymetry_inversion.synthetic.constraint_layout_number(num_constraints=None, latin_hypercube=False, shape=None, spacing=None, shift_stdev=0, region=None, shapefile=None, padding=None, add_outside_points=False, grid_spacing=None, plot=False, seed=0)

Create a layout of constraint points within a region. Can either specify number of constraints, their spacing, or the number of points in each direction (shape).

synthetic_bathymetry_inversion.synthetic.distance_along_line(data, line_col_name='line', time_col_name='unixtime')

Calculate the distances along each flight line in meters, assuming the lowest time value is the start of each lines. If you don’t have time information, you can pass the index of the dataframe as the time column.

Parameters:
  • data (geopandas.GeoDataFrame | pd.DataFrame) – Dataframe containing the data points to calculate the distance along each line, must have a set geometry column.

  • line_col_name (str, optional) – Column name specifying the line number, by default “line”

  • time_col_name (str, optional) – Column name containing time in seconds for each datapoint, by default “unixtime”

Returns:

The distance along each line in meters

Return type:

pd.Series

synthetic_bathymetry_inversion.synthetic.filter_flight_lines(df, filt_type, data_column, distance_column='dist_along_line', line_column='line', pad_width_percentage=10)

_summary_

Parameters:
  • df (geopandas.GeoDataFrame | pd.DataFrame) – _description_

  • filt_type (str) – a string with format “<type><width>+h” where type is GMT filter type, width is the filter width in same units as distance column, and optional +h switches from low-pass to high-pass filter; e.g. “g10+h” is a 10m high-pass Gaussian filter.

  • data_column (str) – _description_

  • distance_column (str, optional) – _description_, by default “dist_along_line”

  • line_column (str, optional) – _description_, by default “line”

  • pad_width_percentage (float, optional) – _description_, by default 10

Returns:

_description_

Return type:

geopandas.GeoDataFrame | pd.DataFrame

synthetic_bathymetry_inversion.synthetic.load_synthetic_model(spacing=1000.0, inversion_region=(-40000.0, 260000.0, -1800000.0, -1400000.0), buffer=0, zref=0, bathymetry_density_contrast=1476, basement_density_contrast=100, basement=False, gravity_noise=None, gravity_noise_wavelength=50000.0, plot_topography=True, plot_gravity=True, just_topography=False)

Function to perform all necessary steps to create a synthetic model for the examples in the documentation.

Parameters:
  • spacing (float, optional) – spacing of the grid and gravity, by default 1e3

  • buffer (float, optional) – buffer to add around the region, by default 0. Buffer region used for creating topography and prisms, while inner region used for extent of gravity and constraints.

  • zref (float , optional) – reference level to use, by default 0

  • bathymetry_density_contrast (float, optional) – density contrast between bathymetry and water, by default 1476, (2500 - 1024)

  • basement_density_contrast (float, optional) – density contrast between basement and water, by default 100

  • basement (bool, optional) – set to True to include a basement model for the regional gravity field, by default False

  • gravity_noise (float | None, optional) – decimal percentage noise level to add to gravity data, by default None

  • gravity_noise_wavelength (float, optional) – wavelength of noise in km to add to gravity data, by default 50e3

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

  • plot_gravity (bool, optional) – plot the gravity data, by default True

  • just_topography (bool, optional) – return only the topography, by default False

  • inversion_region (tuple[float, float, float, float])

Return type:

tuple[DataArray, DataFrame]

Returns:

  • true_topography (xarray.DataArray) – the true topography

  • grav_df (pandas.DataFrame) – the gravity data

synthetic_bathymetry_inversion.synthetic.min_distance_linspace(start, stop, num)

Return evenly spaced values which result in the the minimal max distance between any of the values and anypoint between start and stop.

Parameters:
synthetic_bathymetry_inversion.synthetic.rotated_airborne_survey(along_line_spacing, grav_observation_height, survey_polygon, line_spacing=None, tie_spacing=None, line_numbers=None, tie_numbers=None, padding=None, mask=None, proximity_mask=None, survey_spacing_mask=None, plot=False)

Create a synthetic airborne gravity survey within a survey polygon. Specify either number of lines or line spacing, and either number of ties or tie spacing. Line are automatically oriented along the longest edge of the polygon, and ties are oriented perpendicular to the lines. If number of lines or ties is supplied, will make them evenly spaced to minimize the maximum distance between any point and any line. Will return a dataframe with the survey points and survey metadata such as line spacing and gravity point proximity. If a ‘mask’ is supplied, only points within the mask will be retained. If a ‘proximity_mask’ is supplied, the proximity will only be calculated with the masked. If a ‘survey_spacing_mask’ is supplied, the regions used to calculate the spacing of lines and ties will be determined from the mask’s region.

Parameters:
synthetic_bathymetry_inversion.synthetic.scipy_interp1d(df, to_interp=None, interp_on=None, method=None)

interpolate NaN’s in “to_interp” column, based on values from “interp_on” column method: ‘linear’, ‘nearest’, ‘nearest-up’, ‘zero’, ‘slinear’, ‘quadratic’, ‘cubic’, ‘previous’, ‘next’ use kwargs to pass other arguments to scipy.interpolate.interp1d()