Skip to content

Add return_cc option to run_pipeline - #32

Merged
mdenolle merged 2 commits into
masterfrom
feat/run-pipeline-return-cc
Aug 3, 2026
Merged

Add return_cc option to run_pipeline#32
mdenolle merged 2 commits into
masterfrom
feat/run-pipeline-return-cc

Conversation

@mdenolle

@mdenolle mdenolle commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What

run_pipeline(ccfs, t, fs, cfg, eps_max=..., return_cc=True) now returns (dvv, valid, cc), where cc is the per-epoch stretching correlation coefficient. The default call is unchanged and still returns (dvv, valid).

  • Fixed reference + stretching: CC from measure_stretching (as already computed).
  • Moving reference + stretching: the per-epoch loop was already computing CC and discarding it; it is now collected (_moving_reference(collect_cc=True)).
  • Non-stretching estimators and the inversion reference: CC is NaN.

Why

Coherence-based error models need the per-epoch CC — specifically uq_measurement.weaver_stretching_error, which converts CC into the Weaver/Clarke (2011) aleatoric floor. The new noisepy-dvv-cloud pipeline (single-station dv/v on AWS Batch) currently fakes CC=0.8 for its dvv_err_within Parquet column; this PR lets it use the real value.

Behavior safety

  • CC-gating stays fixed-reference-only, exactly as before: previously the moving branch never produced a CC, so the gate never fired there; that is now preserved explicitly with ref == "fixed" in the gate condition. The moving-reference CC is returned for error modelling but does not alter valid.
  • tests/test_deviations.py gains a TestReturnCC class (4 tests): default two-tuple preserved, dvv/valid identical with and without return_cc, moving warm-up NaNs, non-stretching NaN CC.
  • Full test_deviations.py (8 passed) and the golden expected-metrics suite test_golden.py (22 passed) run clean on Python 3.10.

🤖 Generated with Claude Code

run_pipeline(..., return_cc=True) returns (dvv, valid, cc) with the
per-epoch stretching correlation coefficient, the input needed by
uq_measurement.weaver_stretching_error. CC is collected for the fixed and
moving references with the stretching estimator (the moving loop was
already computing it and discarding it); NaN for other estimators and the
inversion reference.

Behavior-preserving: the default two-tuple return is unchanged, and
CC-gating stays fixed-reference-only (the moving-reference CC is returned
for error modelling but does not alter the valid mask). Verified against
the golden expected-metrics suite (22 passed).

Motivation: the noisepy-dvv-cloud pipeline needs the real per-epoch CC to
replace a placeholder in its dvv_err_within (Weaver/Clarke) column.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 2, 2026 08:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR extends the codameter.deviations.run_pipeline API to optionally return the per-epoch stretching correlation coefficient (CC) alongside dvv and valid, enabling coherence-based error models to use real CC values while keeping the default return shape unchanged.

Changes:

  • Add return_cc option to run_pipeline, returning (dvv, valid, cc) when enabled and preserving (dvv, valid) by default.
  • Collect per-epoch CC for moving-reference stretching via _moving_reference(..., collect_cc=True); return NaN CC for non-stretching estimators and inversion reference.
  • Add targeted tests covering backward-compatible returns, CC behavior for fixed/moving stretching, and NaN CC for non-stretching configurations.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
src/codameter/deviations.py Adds return_cc behavior and CC collection for moving-reference stretching while keeping fixed-only CC gating behavior.
tests/test_deviations.py Adds TestReturnCC to verify return shapes, CC behavior, and backward compatibility.
CHANGELOG.md Documents the new return_cc option and its behavior in the Unreleased section.
.claude/settings.json Adds Claude permissions configuration (not directly related to the run_pipeline change).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread .claude/settings.json Outdated
Comment on lines +1 to +8
{
"permissions": {
"allow": [
"Skill(deep-research)",
"Skill(deep-research:*)"
]
}
}
Per Copilot review: this file grants Skill(deep-research) permissions,
unrelated to run_pipeline's return_cc option -- it isn't tracked on
master and doesn't belong bundled into this change. Removing it here;
whether it should exist in the repo at all is a separate decision.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants