Python replacement for the MATLAB half of Thompson et al. (Communications Earth & Environment, 2026, doi:10.1038/s43247-026-03673-y). The quasi-geostrophic omega inversion for vertical velocity xinvert, which is the solver used in that paper.
The package reconstructs upper-ocean density on a SWOT KaRIn swath from a local gravest empirical mode (GEM), builds the thermal-wind velocity and the Hoskins Q-vector, tiles each swath for an elliptic solve, and writes
I strictly kept splitting the calculation in the same way as Thompson et al. did . CreateDensityFields.m (Zenodo doi:10.5281/zenodo.19981347) reads SWOT L3 absolute dynamic topography and cyclogeostrophic surface velocity, looks up xinvert, and stitches the left and right solutions onto the swath. Code availability in the paper states the same division.
This package therefore replaces only the MATLAB diagnostic path. numpy, scipy, numba, and xarray implement the GEM lookup, centered differences, Gaussian smoothing, Q-vector, and mirror tiling. xinvert.invert_omega remains the elliptic solver, with Dirichlet conditions xinvert kernels enforce a periodic condition only on the last axis; that limit is reported at runtime and is not hidden by a second solver.
Two lines in the deposited .m file do not reproduce the published example NetCDF, so the port follows the product rather than those lines.
The printed rotation cross = u\cos\theta + v\sin\theta anticorrelates with the published vorticity. Here sw_dist bearing of the cross-track chord from north, and
With that projection, pass 155 vorticity, strain, and divergence match the published fields.
The script selects GEM table sshbindens_681_final_curve_098_v2. Published buoyancy on the same pass matches sshbindens_681_final_curve_098 in the same .mat file. This package loads 098. Smoothing follows smoothdata(..., 'gaussian', 8): a truncated Gaussian with
On the one archived example (FOCUS_data_trunc_swath_155_9.nc, SWOT pass 155, late January 2024), correlations against this pipeline are xinvert call, are consistent with the unpublished xinvert options used for the archive and with the missing second periodic boundary. They are not removed by rescaling.
The GEM is the campaign table. Glider profiles are not refit here. Only one vertical-velocity file is in the Zenodo deposit; other passes can be regenerated with the batch script below. SWOT swaths in this tree are the FOCUS crops shipped with that deposit, not a new AVISO download.
The eight panels below follow Figure 4 of Thompson et al. (2026) for SWOT pass 155. Maps show absolute dynamic topography, buoyancy, the cyclogeostrophic cross-track surface velocity, and vertical velocity. Sections are cross-track index 55 and show
The deposited plotting script selects w level 200, which is 1207 m on the truncated depth grid, and it contours buoyancy rather than python scripts/plot_figure4.py. The side-by-side vertical-velocity comparison is figures/pass155_vertical_velocity.png.
| Role | Product | Reference |
|---|---|---|
| Reference code, GEM, SWOT crops, example |
Zenodo | https://doi.org/10.5281/zenodo.19981347 |
| Seagliders SG659 and SG681 | Zenodo | https://doi.org/10.5281/zenodo.17252347 |
| SWOT L3 KaRIn LR Expert v1.0.2 | AVISO/DUACS | https://doi.org/10.24400/527896/A01-2023.018 |
| DUACS L4 SLA/ADT | CMEMS/DUACS | https://doi.org/10.48670/moi-00148 |
| QG omega solver | xinvert |
https://github.com/miniufo/xinvert |
swot_qg_omega/
swot_qg_omega/ # package
tests/
vendor/zenodo_19981347/ # deposited scripts and reference files
data/swot/ # FOCUS SWOT L3 Expert swaths
data/glider/ # Seaglider archives
data/duacs/
data/derived/python/ # pipeline outputs
scripts/
env/
conda env create -f env/environment.yml
conda activate swot-qg-omega
# or
python -m pip install -r env/requirements.txt
python scripts/download_zenodo.py
python scripts/download_zenodo.py --fullpython scripts/run_qg_omega.py --pass 155 --no-w
python scripts/run_qg_omega.py --pass 155
python scripts/compare_matlab_python.py
python scripts/plot_figure4.py
python scripts/run_focus_passes.py
python scripts/run_focus_passes.py --with-w
pytest--no-w writes density, velocity diagnostics, and Q-vector forcing. The default single-pass command also calls xinvert, which takes on the order of 15 minutes per swath. Orientation defaults to the along-track diagonal (SW--NE or NW--SE). run_focus_passes.py uses the last January 2024 cycle of each FOCUS file under data/swot/ and, unless --with-w is set, skips the inversion. pytest checks the operators and, when the reference NetCDF and pass 155 SWOT file are present, recomputes the diagnostic fields against that NetCDF. The archived data/derived/python/qg_omega_swath_155_9.nc already contains w_vel.
Thompson, A.F., Dove, L.A., Tranchant, YT. et al. The three-dimensional structure of fine-scale, vertical velocities in the Southern Ocean inferred from space. Commun Earth Environ 7, 712 (2026). https://doi.org/10.1038/s43247-026-03673-y
Qian, Y., (2023). xinvert: A Python package for inversion problems in geophysical fluid dynamics. Journal of Open Source Software, 8(89), 5510, https://doi.org/10.21105/joss.05510
