Fix: unwrap response list phase before interpolation (#3585) - #3803
Open
ThomasLecocq wants to merge 2 commits into
Open
Fix: unwrap response list phase before interpolation (#3585)#3803ThomasLecocq wants to merge 2 commits into
ThomasLecocq wants to merge 2 commits into
Conversation
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
marked this pull request as ready for review
September 1, 2026 14:27
1 task
ThomasLecocq
requested review from
jwassermann
and removed request for
d-chambers and
trichter
September 1, 2026 14:47
Contributor
Author
|
@krisvanneste here |
ThomasLecocq
commented
Sep 3, 2026
| - 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 |
Contributor
Author
There was a problem hiding this comment.
gnee, have to put the changes in master
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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).
Fixes #3585
AI used?
Claudydude
PR Checklist
masterfor new features,maintenance_?.?.xfor bug fixesCHANGELOG.txt(only obsolete if fixing a bug introduced after the last release)ready for reviewlabel when you the PR is ready to be reviewed