Repository navigation
MAINT: keep Python STA/LTA implementations scale-invariant - #3819
Open
barlowa124 wants to merge 1 commit into
Open
barlowa124 wants to merge 1 commit into
barlowa124 wants to merge 1 commit into
Conversation
classic_sta_lta_py floored lta at np.finfo(0.0).tiny and recursive_sta_lta_py seeded lta with the same absolute epsilon. Both break the amplitude-rescaling invariance that STA/LTA, as a ratio of energies, should satisfy: signals near 1e-155 squared to values below the floor, so the characteristic function differed from the same function on unscaled input. Match the C implementations, which use no absolute epsilon: recursive seeds lta at 0 and emits NaN for all-zero input, and classic divides under errstate with the head region zeroed afterwards. Scale diffs drop from ~1.5 to ~1e-13, matching the C versions' residuals. Closes obspy#3815
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.
What does this PR do?
Fixes #3815.
classic_sta_lta_pyflooredltaatnp.finfo(float).tiny, andrecursive_sta_lta_pyseededltawith the same absolute epsilon.STA/LTA is a ratio of energies, so the characteristic function should
be invariant when the whole trace is scaled. The absolute floors broke
that.
A trace scaled by 1e-155 squares into the subnormal range below
the floor, and the characteristic function diverged from the same
function on unscaled input by order one.
Both functions now match their C counterparts, which carry no
absolute epsilon. The recursive version seeds
ltaat 0 and emitsNaN where a fully-zero history makes the ratio undefined. The classic
version drops the floor and divides under
errstate, with the headregion zeroed afterwards as before.
On the issue's reproduction the differences drop from ~1.5 to ~1e-13,
the same residual the C versions show.
Links to other Issues?
Fixes #3815
AI used?
Implementation and tests were AI-assisted (Devin). The #3815 reproduction runs locally and the
fix direction was checked against the C paths in
obspy/signal/src/.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 reviewedRare actions items:
CONTRIBUTORS.txtCODEOWNERSwith your github handleIssue labels
The PR can be flagged with the following "issue labels" to alter CI runs:
no_cito skip CI builds while work-in-progressbuild_docsto trigger automatic docs build to see how docs render for the PRtest_networkto include "networked" tests if the PR touches any tests marked as "network"upload_imagesto attach plots generated in tests as artifacts to the CI run