Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix: unwrap response list phase before interpolation (#3585) - #3803

Open
ThomasLecocq wants to merge 2 commits into
masterfrom
fix_3585_responselist_phase
Open

Fix: unwrap response list phase before interpolation (#3585)#3803
ThomasLecocq wants to merge 2 commits into
masterfrom
fix_3585_responselist_phase

Conversation

@ThomasLecocq

@ThomasLecocq ThomasLecocq commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

A ResponseListResponseStage (frequency/amplitude/phase triplets) interpolated its phase with a cubic spline directly on the wrapped values. Across +/-180 degree phase wraps the spline overshoots wildly (Gibbs-like oscillation), producing spurious spikes in the response phase (and amplitude notches after evalresp) - clearly visible on real legacy FAP responses such as a Willmore Mk3 from a SEISAN file.

Unwrap the phase before the spline and wrap the result back to (-180, 180]. The interpolant now follows the physical continuous phase and stays exact at the tabulated nodes. Amplitude interpolation is unchanged.

image

Impact is minimal: only ResponseListResponseStage is affected (a rare stage type), and np.unwrap is a no-op unless adjacent phase samples jump by more than 180 degrees. FAP responses without wraps are bit-identical (verified on the bundled IM_IL31 response, whose existing full-evalresp test passes unchanged); only responses with genuine +/-180 wraps change, and only in the between-node regions that were previously wrong. Amplitude never changes.

Regression test added (fails on master, passes here).

Fixes #3585

AI used?

Claudydude

PR Checklist

  • Correct base branch selected? master for new features, maintenance_?.?.x for bug fixes
  • Tests: Added new tests for any new features or fixed regressions
  • Changelog: Added a short note in CHANGELOG.txt (only obsolete if fixing a bug introduced after the last release)
  • Add the yellow ready for review label when you the PR is ready to be reviewed

A ResponseListResponseStage (frequency/amplitude/phase triplets) interpolated its phase with a cubic spline directly on the wrapped values. Across +/-180 degree phase wraps the spline overshoots wildly (Gibbs-like oscillation), producing spurious spikes in the response phase (and amplitude notches after evalresp) - clearly visible on real legacy FAP responses such as a Willmore Mk3 from a SEISAN file.

Unwrap the phase before the spline and wrap the result back to (-180, 180]. The interpolant now follows the physical continuous phase and stays exact at the tabulated nodes. Amplitude interpolation is unchanged.

Impact is minimal: only ResponseListResponseStage is affected (a rare stage type), and np.unwrap is a no-op unless adjacent phase samples jump by more than 180 degrees. FAP responses without wraps are bit-identical (verified on the bundled IM_IL31 response, whose existing full-evalresp test passes unchanged); only responses with genuine +/-180 wraps change, and only in the between-node regions that were previously wrong. Amplitude never changes.

Regression test added (fails on master, passes here).
@ThomasLecocq
ThomasLecocq requested a review from megies September 1, 2026 14:27
@ThomasLecocq
ThomasLecocq marked this pull request as ready for review September 1, 2026 14:27
@ThomasLecocq ThomasLecocq added the ready for review PRs that are ready to be reviewed to get marked ready to merge label Sep 1, 2026
@ThomasLecocq ThomasLecocq added the .core.inventory issues related to our Inventory functionality label Sep 1, 2026
@ThomasLecocq
ThomasLecocq requested review from jwassermann and removed request for d-chambers and trichter September 1, 2026 14:47
@ThomasLecocq ThomasLecocq added this to the 1.6.0 milestone Sep 1, 2026
@ThomasLecocq

Copy link
Copy Markdown
Contributor Author

@krisvanneste here

Comment thread CHANGELOG.txt Outdated
- obspy.core:
* inventory: fix a bug that Latitude, Longitude and Distance did not accept
'measurement_units' when being initialized (see #3623)
* inventory: unwrap the phase of a response list (FAP) stage before

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

gnee, have to put the changes in master

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.core.inventory issues related to our Inventory functionality ready for review PRs that are ready to be reviewed to get marked ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Phase interpolation issues when using ResponseListResponseStage

1 participant