Skip to main content

microstructure-tpw

CI PyPI DOI Python 3.12+ License: GPL v3 codecov Code style: ruff type checked: mypy

Python tools for reading Rockland Scientific microprofiler data and computing turbulent dissipation rates from VMP (Vertical Microstructure Profiler) and MicroRider instruments.

Overview

microstructure-tpw provides a complete processing pipeline for ocean turbulence measurements from Rockland Scientific instruments equipped with shear probes and fast thermistors (FP07). The package reads proprietary .p binary data files, converts channels to physical units, detects profiles, and computes both the rate of dissipation of turbulent kinetic energy (epsilon) and the rate of dissipation of thermal variance (chi), following the methods described in the Rockland Scientific ODAS MATLAB Library and associated Technical Notes.

  • Epsilon (TKE dissipation rate) from shear probe spectra (detailed mathematics), including Goodman coherent noise removal, Nasmyth spectrum fitting, and Macoun & Lueck wavenumber correction.

  • Chi (thermal variance dissipation rate) from FP07 thermistor spectra (detailed mathematics), including Batchelor/Kraichnan spectrum models, FP07 transfer function correction, and spectral fitting (iterative Peterson & Fer 2014, the default, or MLE).

The package is organized into six subpackages under odas_tpw:

  • rsi — Rockland Scientific instrument I/O, NetCDF conversion, profiles, epsilon/chi orchestration
  • chi — Chi (thermal variance dissipation) calculation
  • scor160 — ATOMIX shear-probe benchmark processing and shared physics modules
  • perturb — Full campaign processing pipeline (trim, merge, calibrate, compute, bin)
  • processing — Instrument-agnostic profile processing (top trim, bottom-crash, CT alignment, multi-probe epsilon combining)

Installation

pip install -e ".[dev]"    # editable install with dev dependencies
pip install .              # standard install

See docs/installation.md for more options.

Quick Start

Several CLIs ship with the package (rsi-tpw, perturb, perturb-plot, perturb-diag, scor160-tpw); the two primary ones, for different workflows:

  • rsi-tpw — single-file or short batch processing on the command line.
  • perturb — full campaign pipeline driven by a YAML config file (trim → merge → profiles → epsilon → chi → bin → combo), with parallel workers and stage-aware logging. Use this for cruise-scale runs.

The two CLIs use different spectral defaults (rsi-tpw: fft_length=1024 with a 4096-sample dissipation window; perturb: duration-based fft_sec=1.0 — one second, resolved per instrument sampling rate, = 512 samples on a 512-Hz VMP-250 — for both epsilon and chi), so their outputs differ in vertical resolution and noise behavior.

rsi-tpw (single files / short batches)

# Full pipeline: .p files → epsilon → chi
rsi-tpw pipeline VMP/*.p -o results/

# Or run individual stages
rsi-tpw eps VMP/*.p -o epsilon/                       # writes into epsilon/eps_00/
rsi-tpw chi VMP/*.p --epsilon-dir epsilon/ -o chi/    # finds eps_00/ automatically

# Pre-deployment bench test (dummy probes, instrument at rest): raw-count
# figures + spectra + an auto-evaluated Rockland checklist (see docs/rsi-tpw/bench.md)
rsi-tpw bench VMP/*.p -o bench/

Note: eps writes into a hash-tracked subdirectory (epsilon/eps_00/, see output directories). The chi command searches the given --epsilon-dir and its eps_* subdirectories (most recently modified first), and matches both single-profile ({stem}_eps.nc) and per-profile ({stem}_prof001_eps.nc, ...) file names, concatenating the latter along time. Only when no matching epsilon files exist anywhere does chi fall back to Method 2 for that file, with a console warning.

from odas_tpw.rsi.pipeline import run_pipeline
from pathlib import Path

# Full pipeline: .p → profiles → epsilon → chi → binning → combine
run_pipeline([Path("VMP/file.p")], Path("results/"))

# Or use the modular API
from odas_tpw.rsi.dissipation import compute_diss_file
from odas_tpw.rsi.chi_io import compute_chi_file

compute_diss_file("VMP/file.p", "epsilon/")
compute_chi_file("VMP/file.p", "chi/")

Note: get_diss() and get_chi() still work for backward compatibility but are deprecated in favor of run_pipeline() or the modular compute_diss_file() / compute_chi_file() functions.

perturb (campaign-scale batch pipeline)

# Write a template config you can edit (cruise paths, GPS file,
# instrument-specific overrides, parallelism, etc.).
perturb init my-cruise.yaml

# Run the full pipeline — outputs land in <output_root>/{profiles_NN,
# diss_NN, chi_NN, ctd_NN, *_binned_NN, combo}, with a per-run log under
# <output_root>/logs/.
perturb run -c my-cruise.yaml

# Or run individual stages against the same config:
perturb trim -c my-cruise.yaml
perturb profiles -c my-cruise.yaml
perturb diss     -c my-cruise.yaml
perturb chi      -c my-cruise.yaml
perturb bin      -c my-cruise.yaml
perturb combo    -c my-cruise.yaml

See docs/perturb/pipeline.md for the full stage list and docs/perturb/configuration.md for the config schema.

Documentation

rsi-tpw (science library)

Document Description
CLI Reference All rsi-tpw subcommands and flags
ODAS .p File Format TN-051 compliance: versions, bad buffers, sampling-rate and timestamp notes
Configuration YAML config file format and all parameter defaults
Pipeline Processing stages and data flow
Python API Using microstructure-tpw from Python code
Output Directories Sequential hash-tracked output scheme
Vectorization Vectorized compute internals
Calibration Provenance Plausible-range checks on calibration coefficients, and the cal_* attrs on L1 variables
Bench Test Pre-deployment bench check (bench): quick_bench figures + auto checklist
Deployment Procedures Field procedures that keep the data analysable: pre/post bench runs, probe/channel swaps, calibration bracketing, config hygiene
Tab-completion Optional shell <TAB> completion for the CLIs (argcomplete)

perturb (batch pipeline)

Document Description
Pipeline Batch processing stages and data flow
CLI Reference All perturb subcommands and flags
Configuration YAML config file format for perturb
Parallel Scaling Benchmark results for multi-core scaling
Modules Module-level reference
pyturb Comparison Comparison with oceancascades/pyturb

scor160 (ATOMIX benchmark)

Document Description
CLI Reference All scor160-tpw subcommands and flags

Shared

Document Description
Epsilon Mathematics TKE dissipation algorithm details
Chi Mathematics Thermal dissipation algorithm details
Mixing Efficiency Mathematics of the dissipation ratio
Best Practices Guidance for comparing turbulence measurements
Bibliography Consolidated references
Installation Installation options
Changelog Version history

References

This package is a Python implementation derived from the Rockland Scientific ODAS MATLAB Library (v4.5.1) and associated Technical Notes (TN-028, TN-051, TN-061).

See docs/bibliography.md for the full list of references.

Testing

python -m pytest                          # run all tests
python -m pytest tests/test_epsilon.py    # epsilon pipeline tests only

Development

This project was developed in collaboration with Claude Code.

Validation and known limitations

Epsilon is validated against the ATOMIX shear-probe benchmark (Fer et al. 2024) — 1416 spectra from six benchmark records spanning 10⁻¹⁰ to 10⁻³ W/kg, with a log10 bias below 0.09, log10 RMSD of 0.008–0.096, and 100% of estimates within half a decade of the published reference.

Chi has no equivalent benchmark and its absolute level is not anchored: report it as a relative field with a systematic of order 1.5×. Note also that a chi fom near 1.0 does not mean the spectral fit is good — it is an integrated ratio, and cancellation across the band hides a factor-of-two structured residual.

Before trusting an absolute level on your own data, audit the calibration constants (rsi-tpw sensors --cal-dir, --diff-gain): they, not the estimator, are usually the dominant uncertainty.

Full detail, and suggested wording for a manuscript, in docs/validation_and_limitations.md.

Citation

If you use this software in published work, please cite it. Citation metadata lives in CITATION.cff — GitHub renders a "Cite this repository" button from it (BibTeX/APA export). Each tagged release is archived on Zenodo with a DOI.

Cite the version DOI of the release that produced your numbers — the concept DOI resolves to whatever release is newest, which is not what you ran. Version DOIs are listed in CITATION.cff; v0.3.0 is 10.5281/zenodo.21366143. The concept (all-versions) DOI 10.5281/zenodo.21366142 is the right one to cite when referring to the software in general rather than to a specific result.

License

GPLv3 — see LICENSE for details.

Metadata

Release files for microstructure-tpw 0.4.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 microstructure-tpw 0.4.0
File Size Uploaded
microstructure_tpw-0.4.0.tar.gz 1.3 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for microstructure-tpw 0.4.0
File Interpreter ABI Platform
microstructure_tpw-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 2.1 MB

Release files / microstructure_tpw-0.4.0.tar.gz

Download URL microstructure_tpw-0.4.0.tar.gz
Size 1.3 MB
Tags Source
SHA-256 checksum
How to use checksums
9c29531a57b8e1d48ce8df893d608e05aaab6fd56ca2efba1d2bb63b5448e31c
BLAKE2b-256 checksum
How to use checksums
40e7e4bc2c55b650034a9d3a804c5aa83bcd59deb0194deb3ad771a031a21f19
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 Sep 11, 2026.

Transparency log

Release files / microstructure_tpw-0.4.0-py3-none-any.whl

Download URL microstructure_tpw-0.4.0-py3-none-any.whl
Size 857.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1c8c9d12173758b68d0e17bc3d2c95a9c413fa8a5049a85481c9b8c72e19e7d8
BLAKE2b-256 checksum
How to use checksums
cb89d29e0cf0a79af3a442da04f03ba04ab252cac08cd6add44f31c2ad3e673e
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 Sep 11, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

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