regionate

Create xgcm-grid-consistent regional masks and boundaries for ocean model output.

regionate turns a geographic polygon into a discrete, grid-aware region: it snaps the polygon to a model grid and produces a boolean cell mask plus the staggered (u, v) velocity faces that trace the region’s boundary. Because the mask and the boundary faces come from the same construction, a volume, mass, or heat budget integrated over the masked region is exactly consistent with the fluxes through its boundary — the property that makes closed regional budgets possible.

It leans on its sibling package sectionate for the section- and face-tracing math, and builds on xgcm grids.

The central object is GriddedRegion (a polygon bound to an xgcm.Grid); BoundedRegion defines a region from named sections instead of a raw polygon, and Regions collects many of them. See the worked examples below for thickness, heat, and mass budgets over named regions.