OCEAN-DIVA

Coastline-aware interpolation

Scattered observations, analyzed around land.

Ocean-DIVA turns irregular spatial samples into a gridded field and relative posterior error while respecting coastlines, islands, and disconnected basins.

12.0 °C 18.0 °C

What makes it useful

Spatial structure without crossing the coast.

Ocean-DIVA combines a compact Python API with path-aware covariance for marine and bounded-domain analyses.

01

Start from observations

Pass x/y coordinates, measured values, optional weights, and a correlation length.

02

Describe the domain

Use contour rings, a water mask, or an xarray land mask whose coordinates define the grid.

03

Keep uncertainty

Receive the analysis, relative posterior error, and water-domain mask together.

Install

NumPy-first, with optional integrations.

Core
python -m pip install ocean-diva
pandas + xarray
python -m pip install "ocean-diva[accessors]"
Plots
python -m pip install "ocean-diva[plot]"

Interactive playground

See the barrier change the field.

Drag observations, click ocean to add one, or Shift-click near a point to remove it. The browser preview is illustrative; the Python API runs DIVA’s full solver.

4 observations · drag to explore
10 °C 20 °C · patterned area is land
Parameters reflected in Python

Coordinate-aware masks

Use 1 for land and 0 for ocean.

Pass an xarray DataArray or a single-variable Dataset as land_mask. Its named coordinates are sorted and used as the output grid.

  1. 1Create observations with longitude and latitude coordinates.
  2. 2Create a binary land mask on the desired output coordinates.
  3. 3Analyze, then use the returned water variable for display or export.
xarray land-mask example
import numpy as np
import xarray as xr

temperature = xr.DataArray(
    [12.0, 10.0, 20.0, 18.0],
    dims="observation",
    coords={
        "longitude": ("observation", [0.2, 0.3, 0.7, 0.8]),
        "latitude": ("observation", [0.25, 0.75, 0.75, 0.25]),
    },
    name="temperature",
    attrs={"units": "degree_Celsius"},
)

longitude = np.linspace(0, 1, 51)
latitude = np.linspace(0, 1, 51)
land = xr.DataArray(
    (
        (latitude[:, None] >= 0.20)
        & (latitude[:, None] <= 0.80)
        & (longitude[None, :] >= 0.42)
        & (longitude[None, :] <= 0.58)
    ).astype(np.uint8),
    dims=("latitude", "longitude"),
    coords={"longitude": longitude, "latitude": latitude},
)

result = temperature.diva.analyze(
    x="longitude",
    y="latitude",
    correlation_length=0.2,
    land_mask=land,
)

water_temperature = result["analysis"].where(result["water"])

Result dataset

Three aligned variables.

The xarray accessor preserves coordinate names and source attributes.

analysis

The interpolated field on the requested grid, with land set to the exclusion value.

error

Relative posterior error, from lower uncertainty near observations toward 1 farther away.

water

A boolean domain mask: true in analyzed ocean cells and false on land.