Start from observations
Pass x/y coordinates, measured values, optional weights, and a correlation length.
Coastline-aware interpolation
Ocean-DIVA turns irregular spatial samples into a gridded field and relative posterior error while respecting coastlines, islands, and disconnected basins.
What makes it useful
Ocean-DIVA combines a compact Python API with path-aware covariance for marine and bounded-domain analyses.
Pass x/y coordinates, measured values, optional weights, and a correlation length.
Use contour rings, a water mask, or an xarray land mask whose coordinates define the grid.
Receive the analysis, relative posterior error, and water-domain mask together.
Install
python -m pip install ocean-diva
python -m pip install "ocean-diva[accessors]"
python -m pip install "ocean-diva[plot]"
Interactive playground
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.
Coordinate-aware masks
Pass an xarray DataArray or a single-variable
Dataset as land_mask. Its named coordinates
are sorted and used as the output grid.
water variable for display or export.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
The xarray accessor preserves coordinate names and source attributes.
analysisThe interpolated field on the requested grid, with land set to the exclusion value.
errorRelative posterior error, from lower uncertainty near observations toward 1 farther away.
waterA boolean domain mask: true in analyzed ocean cells and false on land.