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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

drifteroi-0.1.0.tar.gz (30.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

drifteroi-0.1.0-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

Details for the file drifteroi-0.1.0.tar.gz.

File metadata

  • Download URL: drifteroi-0.1.0.tar.gz
  • Upload date:
  • Size: 30.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for drifteroi-0.1.0.tar.gz
Algorithm Hash digest
SHA256 232624fd8b7d0b44534875793c52621c3eb0f9b69d223f06916d2720cc170ce8
MD5 8597bd00fc4418ae7459dfe17cca550f
BLAKE2b-256 fc8100175a75f013aef6a16e1627252c4d95dcbf5fec85c3985e565481b27a77

See more details on using hashes here.

Provenance

The following attestation bundles were made for drifteroi-0.1.0.tar.gz:

Publisher: publish.yml on williamedge/drifterOI-public

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file drifteroi-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: drifteroi-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for drifteroi-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 45d9e3c11936ff29d14be223183e7db8bd7cd9afe22b172c2e6eaf6a1ecd62b7
MD5 15b4c806766e8eb968d320c9107d6493
BLAKE2b-256 f214d0221b521b54a3652c11cfcfdd9bb901980cb18979bf89415f195c019658

See more details on using hashes here.

Provenance

The following attestation bundles were made for drifteroi-0.1.0-py3-none-any.whl:

Publisher: publish.yml on williamedge/drifterOI-public

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 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