Skip to main content

drifterOI

Python code for 3D (space + time) optimal interpolation of sparse Lagrangian drifter velocities, using Gauss-Markov / Gaussian Process regression. Splits observed velocities into:

  • a seasonal component: a smooth annual harmonic cycle per location, fit as a separable spatial-Matern x per-harmonic Gauss-Markov model (drifterOI.seasonal_gp, solved efficiently via datide.MultiscaleGP's block-diagonal decomposition rather than a dense joint solve), and
  • an eddy/synoptic residual: fit as a Vecchia-approximated Gaussian Process over the seasonal-corrected residuals (via gpvecchia), to scale to the full drifter dataset without a dense covariance solve.

This is the companion code for the accompanying manuscript, submitted to Ocean Science: [preprint link]. See Citation below.

Installation

Local development install (no PyPI release yet):

git clone https://github.com/williamedge/drifterOI.git
cd drifterOI
pip install -e .

Requires Python >= 3.10 (set by the gpvecchia dependency's floor). Besides the usual scientific Python stack, this pulls in three sibling packages from the same research group: gpvecchia (Vecchia-approximated GPs), datide (Gauss-Markov / data assimilation routines), and gptide (GP kernels, MLE/MCMC fitting).

Quickstart

A minimal example of the separable seasonal Gauss-Markov model on synthetic data -- the same model seasonal_gp.init_gm_scales builds for the real pipeline, without needing the drifter dataset:

import numpy as np
from datide import MultiscaleGP

import drifterOI.seasonal_gp as sgp
from drifterOI.cov import matern32_covfunc

rng = np.random.default_rng(0)
n_obs = 200
X = np.column_stack([
    rng.uniform(-100, 100, n_obs),   # easting (km)
    rng.uniform(-100, 100, n_obs),   # northing (km)
    np.sort(rng.uniform(0, 200, n_obs)),  # time (days)
])
Y = rng.normal(size=n_obs)  # observed velocity component

# [sigma, lx, ly, lt]: spatial Matern prior for the seasonal coefficients
B_params = [1.0, 50.0, 50.0, 5.0]
R = np.eye(n_obs) * 0.05  # observation noise covariance

H_list, scales, design = sgp.init_gm_scales(X, matern32_covfunc, B_params, mean=True)
model = MultiscaleGP(H_list, scales, R)

param_stack = model.conditional_mean(Y)          # (n_params, n_obs) harmonic coefficients
seasonal_fit = sgp.apply_harmonic_design(design, param_stack)
eddy_residual = Y - seasonal_fit

Pipeline

The scripts/ directory holds the full analysis pipeline behind the manuscript, in stages (each stage reads the previous stage's saved output):

Stage Purpose
L0_processing/ Raw drifter/bathymetry inspection and pre-processing notebooks
L1_inference/ Fit the seasonal + eddy Gauss-Markov/Vecchia-GP model to drifter observations (MLE + MCMC)
L2_predict_seasonal/ Predict the seasonal field on a spatial grid or at a fixed point, from the L1 fit
L3_predict_eddy/ Predict the eddy/synoptic field and derive stream function / velocity potential
L4_plot_results/ Manuscript figures and comparisons against reference (e.g. BLUElink) products

Example data (data/) is included in the repository so the L1-L2 scripts can be run directly (BODY_drifters_6_hours.nc drifter observations, SUNTANS_bathy_unstructured.nc bathymetry for plotting). data/, scripts/, and tests/ aren't part of the installable package (pip install drifterOI won't fetch them) -- clone the repo if you want the example data or to run the pipeline scripts yourself.

Citation

If you use this code, please cite it as described in CITATION.cff. Once published, the accompanying Ocean Science manuscript will be the preferred citation -- see [preprint link] in the meantime.

License

BSD-3-Clause -- see LICENSE.

Metadata

Release files for drifterOI 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for drifterOI 0.1.0
File Size Uploaded
drifteroi-0.1.0.tar.gz 30.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for drifterOI 0.1.0
File Interpreter ABI Platform
drifteroi-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 57.4 kB

Release files / drifteroi-0.1.0.tar.gz

Download URL drifteroi-0.1.0.tar.gz
Size 30.2 kB
Tags Source
SHA-256 checksum
How to use checksums
232624fd8b7d0b44534875793c52621c3eb0f9b69d223f06916d2720cc170ce8
BLAKE2b-256 checksum
How to use checksums
fc8100175a75f013aef6a16e1627252c4d95dcbf5fec85c3985e565481b27a77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2026.

Transparency log

Release files / drifteroi-0.1.0-py3-none-any.whl

Download URL drifteroi-0.1.0-py3-none-any.whl
Size 27.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
45d9e3c11936ff29d14be223183e7db8bd7cd9afe22b172c2e6eaf6a1ecd62b7
BLAKE2b-256 checksum
How to use checksums
f214d0221b521b54a3652c11cfcfdd9bb901980cb18979bf89415f195c019658
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page