Skip to content

Harden EstimateBandwidth frequency bounds - #920

Merged
wangyinz merged 4 commits into
masterfrom
codex/issue-856-estimate-bandwidth
Aug 21, 2026
Merged

wangyinz merged 4 commits into
masterfrom
codex/issue-856-estimate-bandwidth

Conversation

@wangyinz

@wangyinz wangyinz commented Aug 12, 2026 •

Copy link
Copy Markdown
Member

Fixes #856.

Maintainer-approved behavior

  • Smooth the SNR curve with a centered moving average over the bins that actually exist at each edge; the shortened edge window is renormalized and no zero, reflection, or extrapolated bins are introduced.
  • Define the passband by strict SNR > threshold; a bin equal to the threshold is outside the passband and is returned as the boundary bin.
  • Validate frequency and smoother parameters before spectrum access, clamp the requested ceiling without rounding above it, and avoid out-of-range calls for empty or unequal-length spectra.

Verification

  • EstimateBandwidth contract suite: 47 passed
  • Combined broadband/diagnostic/window/EstimateBandwidth contracts: 81 passed
  • Existing non-database SNR numerical regressions: passed
  • Black, Python 3.12/3.13 py_compile, and git diff --check: passed
  • The tests include an independent manual truncated-window oracle, constant-spectrum edge preservation, exact-threshold cases, and bounded unequal-grid cases

@codecov

codecov Bot commented Aug 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.07843% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.63%. Comparing base (b3bae32) to head (7cbed89).
⚠️ Report is 2 commits behind head on master.

Files with missing lines Patch % Lines
python/mspasspy/algorithms/snr.py 96.07% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #920      +/-   ##
==========================================
+ Coverage   70.51%   70.63%   +0.12%     
==========================================
  Files         176      177       +1     
  Lines       35094    35193      +99     
  Branches     2498     2503       +5     
==========================================
+ Hits        24745    24860     +115     
+ Misses       9449     9430      -19     
- Partials      900      903       +3     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@wangyinz
wangyinz marked this pull request as draft August 14, 2026 05:58

Copy link
Copy Markdown
Member Author

Draft decision required (renewed review)

A signal-processing owner must define smoothing behavior at spectral boundaries and the exact threshold-equality convention. This PR stays draft until the selected policy is documented and validated by an independent synthetic passband oracle rather than by reproducing NumPy's implementation.

@wangyinz
wangyinz force-pushed the codex/issue-856-estimate-bandwidth branch from 6f907e7 to f0dcade Compare August 21, 2026 02:34
@wangyinz
wangyinz changed the base branch from master to codex/issue-857-snr-windows August 21, 2026 02:35
@wangyinz
wangyinz marked this pull request as ready for review August 21, 2026 02:35

Copy link
Copy Markdown
Member Author

Maintainer decision implemented: smoothing uses a truncated, renormalized moving window containing only real spectral bins, and the passband is strictly SNR > threshold (equality is outside). Independent edge and equality oracles pass. The former scientific blocker is resolved. This PR is temporarily stacked on #918 and is now Ready.

@wangyinz
wangyinz force-pushed the codex/issue-857-snr-windows branch from 20c3903 to 878d300 Compare August 21, 2026 02:52
@wangyinz
wangyinz force-pushed the codex/issue-856-estimate-bandwidth branch from f0dcade to 1497409 Compare August 21, 2026 02:55
@wangyinz
wangyinz force-pushed the codex/issue-856-estimate-bandwidth branch from 1497409 to eb87c06 Compare August 21, 2026 03:18
@wangyinz
wangyinz changed the base branch from codex/issue-857-snr-windows to master August 21, 2026 03:18
@wangyinz
wangyinz force-pushed the codex/issue-856-estimate-bandwidth branch from eb87c06 to 7cbed89 Compare August 21, 2026 03:20
@wangyinz
wangyinz merged commit 70f40e8 into master Aug 21, 2026
18 checks passed
@wangyinz
wangyinz deleted the codex/issue-856-estimate-bandwidth branch August 22, 2026 08:26
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.

Bound and smooth EstimateBandwidth without out-of-range access

1 participant