Skip to content

Filter out spurious extremes#220

Merged
bkeepers merged 9 commits intomainfrom
surious-extremes
Mar 5, 2026
Merged

Filter out spurious extremes#220
bkeepers merged 9 commits intomainfrom
surious-extremes

Conversation

@bkeepers
Copy link
Contributor

@bkeepers bkeepers commented Feb 18, 2026

#219 reports bad data for stations like Vahemadal (Estonia), where tidal amplitudes are negligible. The derivative-based root-finding algorithm introduced in #213 correctly finds mathematical zeros of h'(t), but reports tiny oscillations (1-4mm) as tidal extremes (previous code may have produced those oscillations too, depending on their timing). For example, Vahemadal returns 6 extremes in 1 day with a total range of only 3.6cm, where physically there's just one slow rise/fall dominated by seasonal constituents (SSA: 0.158m, SA: 0.059m, vs M2: 0.006m).

This PR filters spurious extremes from tide predictions using prominence threshold and minimum temporal gap criteria.

This PR also adds a snapshot test with extremes from a selection of representative stations to make it more obvious how model changes affect real world predictions.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds prominence-based filtering to the extremes prediction algorithm to eliminate spurious mathematical extremes from low-amplitude tidal stations. The issue was particularly apparent in micro-tidal locations like Vahemadal, Estonia, where tiny oscillations (1-4mm) caused by numerical computation were incorrectly reported as tidal extremes alongside the real tidal signal.

Changes:

  • Implements post-processing prominence filter that iteratively removes extremes with level differences below 2% of total constituent amplitude
  • Adds unit tests for prominence filtering behavior on both low-amplitude and normal tidal stations
  • Adds comprehensive snapshot tests covering 20 representative stations worldwide to catch regressions from future algorithm changes

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
packages/tide-predictor/src/harmonics/prediction.ts Adds prominence filtering algorithm after extremes detection
packages/tide-predictor/test/harmonics/prediction.test.ts Adds unit tests for prominence filtering on low-amplitude and normal stations
packages/neaps/test/snapshots.test.ts New snapshot test suite covering 20 diverse tidal stations
packages/neaps/test/snapshots/snapshots.test.ts.snap Generated snapshot data showing filtered extremes for all test stations

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

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated 8 comments.


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

@bkeepers bkeepers force-pushed the surious-extremes branch 2 times, most recently from d94fb9a to bb60461 Compare March 5, 2026 12:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

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


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

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bkeepers bkeepers merged commit c1f0144 into main Mar 5, 2026
@bkeepers bkeepers deleted the surious-extremes branch March 5, 2026 17:21
@github-actions github-actions bot mentioned this pull request Mar 5, 2026
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