i7aof.imbie

High-level API for IMBIE basin datasets and masks. See i7aof.imbie for developer details.

i7aof.imbie.download.download_imbie()

Download the geojson files that define the IMBIE basins

i7aof.imbie.masks.make_imbie_masks(config)

Generate IMBIE2 Antarctic basin masks on the ISMIP grid.

This function downloads IMBIE2 basin shapefiles (if needed), rasterizes the polygons onto the ISMIP grid using a point-in-polygon test (via inpoly), and extends each basin mask into the ocean using a distance transform. The final basin map is saved as a NetCDF file.

Parameters:

config (mpas_tools.config.MpasConfigParser) – Configuration object providing resolution and file paths.

class i7aof.imbie.extend.ShelfParams(shelf_isobath_depth_m: float = 1500.0, frac_threshold: float = 0.001, seed_dilation_iters: int = 10)

Bases: object

Parameters controlling shelf-break constrained basin extension.

frac_threshold: float = 0.001
seed_dilation_iters: int = 10
shelf_isobath_depth_m: float = 1500.0
i7aof.imbie.extend.component_island_stats(*, basin_number: ndarray, num_basins: int) dict

Return component and island-cell stats per basin (4-neighbor).

i7aof.imbie.extend.count_basin_components(*, basin_number: ndarray, num_basins: int) dict

Count 4-neighbor connected components for each basin id.

i7aof.imbie.extend.enforce_basin_contiguity(*, basin_number: ndarray, num_basins: int, max_iters: int = 8) ndarray

Reassign disconnected basin islands to adjacent basins.

For each basin, only the largest 4-neighbor connected component is kept. Any other component is reassigned to the dominant adjacent basin label on its 4-neighbor boundary. This pass is repeated until no changes remain or max_iters is reached.

i7aof.imbie.extend.extend_basins_to_ocean_nearest(*, basin_number: ndarray, num_basins: int, dx: float = 1.0, dy: float = 1.0) ndarray

Extend basin masks everywhere by nearest-distance to a defined basin.

This matches the existing behavior in i7aof.imbie.masks but allows grid spacing to be specified.

i7aof.imbie.extend.extend_imbie_basins(*, config, basin_number: ndarray, num_basins: int, workdir: str = '.') ndarray

Extend IMBIE basins to the ocean using a shelf-break constraint.

This is a two-stage extension:

  1. Within the continental shelf (defined by an isobath), assign basin labels by projecting from the shelf-break contour (effectively normal to the contour).

  2. Beyond the shelf, extend basins by nearest distance to the basin seeds (current behavior).

The shelf is defined on the configured topography dataset on the ISMIP grid. Topography is built if missing.

Parameters:
  • config (mpas_tools.config.MpasConfigParser) – Configuration options.

  • basin_number (numpy.ndarray) – A 2D array of basin labels from rasterization, with -1 where undefined.

  • num_basins (int) – The number of basins.

  • workdir (str, optional) – Base working directory containing topo/ (and where topography will be built if missing).

Returns:

A 2D array of basin labels extended to the full domain.

Return type:

numpy.ndarray

i7aof.imbie.extend.extend_imbie_basins_with_shelf_break(*, basin_number: ndarray, bed: ndarray, ocean_frac: ndarray, shelf_isobath_depth_m: float, dx: float, dy: float, num_basins: int, frac_threshold: float = 0.001, seed_dilation_iters: int = 10, debug: bool = False, debug_dir: str = 'imbie2', x: ndarray | None = None, y: ndarray | None = None) ndarray

Fill basin labels within the continental shelf using shelf-break rules.

This function does not do the final deep-ocean fill; call extend_basins_to_ocean_nearest() after this step.

Notes

  • ocean_frac is used directly, which includes floating-ice cavities. This ensures shelf regions exist and can be seeded even if the shelf break passes under ice shelves.

i7aof.imbie.polygons.main() None
i7aof.imbie.polygons.make_imbie_polygon_shapefile(config, *, workdir='.', simplify_tolerance_m=0.0, remove_extension_holes=True, min_hole_area_m2=0.0, out_shapefile='imbie2/extended_basin_polygons.shp', validate=True)

Build polygon shapefiles for combined + extended IMBIE basins.

The algorithm keeps the original IMBIE combined polygons exactly and appends only the extension outside the original IMBIE footprint:

  1. Build/load extended basin labels from the raster workflow.

  2. Convert each raster basin to polygons.

  3. Remove the full original IMBIE footprint from each raster basin.

  4. Optionally simplify extension polygons.

  5. Union exact original basin polygons with the extension polygons.

Parameters:
  • config (mpas_tools.config.MpasConfigParser) – Configuration object.

  • workdir (str, optional) – Base working directory for reading/writing files.

  • simplify_tolerance_m (float, optional) – Shapely simplification tolerance in meters, applied only to extension polygons. A value of 0 disables simplification.

  • remove_extension_holes (bool, optional) – Whether to remove holes from extension polygons after simplification.

  • min_hole_area_m2 (float, optional) – Minimum interior-ring area to retain when removing holes from extension polygons. With the default (0), all extension holes are removed.

  • out_shapefile (str, optional) – Output shapefile path.

  • validate (bool, optional) – Whether to run basic topology checks (no overlaps and valid geometry) on the final basin polygons.

Returns:

Mapping from basin name to final polygon geometry.

Return type:

dict