Skip to content

Fix heights at NOAA stations: measure datum offsets against the table's own MSL - #12

Merged
vinc3m1 merged 3 commits into
mainfrom
claude/bay-area-tides-offset-mpim28
Jul 18, 2026
Merged

vinc3m1 merged 3 commits into
mainfrom
claude/bay-area-tides-offset-mpim28

Conversation

@vinc3m1

@vinc3m1 vinc3m1 commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Bay Area (and all NOAA-sourced) heights were off by the full MSL→MLLW
conversion (~3.2 ft at Richmond Inner Harbor: app showed -1.2 ft when NOAA
predicted +2.0 ft). Two related bugs:

  1. datumOffset() assumed the station's datums table is MSL-relative
    (true for TICON, where MSL = 0) and returned -datums[target]. NOAA
    tables are station-datum-relative (STND = 0, MSL a few metres up), so
    the offset must be datums[MSL] - datums[target]. This affected 1,178
    reference stations.

  2. Subordinate-station ratios were applied to MSL-relative levels, but
    NOAA height ratios are defined on tide-table heights above the
    reference's chart datum. createModel now lifts reference levels into
    chart-datum space, warps there, and shifts back into the subordinate's
    model space (a no-op shift for the usual datum-less subordinate, whose
    display offset is also 0). This affected all 2,231 subordinates.

Also fixes the Detail-page datum selector labels, which printed raw
station-datum-relative values as "vs MSL".

Verified against NOAA's published predictions for Richmond Inner Harbor
(9414849, ratios on SF Golden Gate 9414290): highs/lows now match within
0.03 ft and 2 minutes; timing was already correct. Added a pinned
regression test for that station pair plus STND-relative datum unit tests.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com
Claude-Session: https://claude.ai/code/session_01Bsh1A5WLRb9xhiGNxUvs8p

claude added 2 commits July 18, 2026 19:32
…'s own MSL

Bay Area (and all NOAA-sourced) heights were off by the full MSL→MLLW
conversion (~3.2 ft at Richmond Inner Harbor: app showed -1.2 ft when NOAA
predicted +2.0 ft). Two related bugs:

1. datumOffset() assumed the station's datums table is MSL-relative
   (true for TICON, where MSL = 0) and returned -datums[target]. NOAA
   tables are station-datum-relative (STND = 0, MSL a few metres up), so
   the offset must be datums[MSL] - datums[target]. This affected 1,178
   reference stations.

2. Subordinate-station ratios were applied to MSL-relative levels, but
   NOAA height ratios are defined on tide-table heights above the
   reference's chart datum. createModel now lifts reference levels into
   chart-datum space, warps there, and shifts back into the subordinate's
   model space (a no-op shift for the usual datum-less subordinate, whose
   display offset is also 0). This affected all 2,231 subordinates.

Also fixes the Detail-page datum selector labels, which printed raw
station-datum-relative values as "vs MSL".

Verified against NOAA's published predictions for Richmond Inner Harbor
(9414849, ratios on SF Golden Gate 9414290): highs/lows now match within
0.03 ft and 2 minutes; timing was already correct. Added a pinned
regression test for that station pair plus STND-relative datum unit tests.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bsh1A5WLRb9xhiGNxUvs8p
The Settings-persisted datum key was a cross-station foot-gun: one global
value applied to every station on Earth. Stations lacking the chosen key
silently fell back to MSL-relative heights while the readout still wore
the selected label, and datum-less subordinate stations mislabeled under
any override. Users overwhelmingly want the numbers that match local
published tide tables — the station's own chart datum — so that is now
the only display reference.

The Detail page's datum selector becomes a read-only table of the
station's datums vs MSL (transparency kept, mutation removed), with the
chart datum called out. The engine's predict-around-MSL / convert-at-
display architecture is unchanged. A stale `datum` key persisted in
existing users' localStorage is simply no longer read.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bsh1A5WLRb9xhiGNxUvs8p
@vinc3m1
vinc3m1 enabled auto-merge (squash) July 18, 2026 19:57
The test clicked the recenter control and immediately asserted
map.isMoving(). On a slow CI runner the click-resolution plus evaluate
round-trip can outlast the 450 ms ease, so the animation is already
finished and isMoving() is legitimately false — the CI failure was a
race, not a product bug.

Poll for either state instead: still animating, or camera already
re-centred on the selection. The ease starts synchronously in the click
handler, so one of the two always holds. Arrival alone can't be the sole
predicate because environments that block tile/style requests never
advance MapLibre's render loop, leaving the animation pending forever.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bsh1A5WLRb9xhiGNxUvs8p
@vinc3m1
vinc3m1 merged commit fba497f into main Jul 18, 2026
2 checks passed
@vinc3m1
vinc3m1 deleted the claude/bay-area-tides-offset-mpim28 branch July 18, 2026 20:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f939a642fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/stores/settings.ts
Comment on lines 5 to 9
heightUnit: HeightUnit;
distanceUnit: DistanceUnit;
timeFormat: TimeFormat;
/** Chart datum key, or null to use each station's own chart_datum. */
datum: string | null;
theme: 'dark' | 'light' | 'auto';
showMarine: boolean;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Update the user documentation after removing datum selection

Removing datum from persisted settings and the Detail-page selector leaves the documented workflow inaccurate: README.md:26-27 still advertises chart datum as a preference, README.md:36-37 instructs users to switch it, and README.md:75-77 says it is stored locally. Users following those instructions will look for a control that no longer exists, so the README should describe the new station-chart-datum-only behavior.

Useful? React with 👍 / 👎.

vinc3m1 added a commit that referenced this pull request Jul 19, 2026
* Update README for station-chart-datum-only heights

The datum switcher was removed in #12 (a global override mislabeled
stations lacking the chosen datum key), but the README still advertised
chart datum as a switchable, persisted preference. Drop it from the
preference lists, reword the Source & accuracy step, and document the
new behavior: heights are always above the station's own chart datum,
matching its published tide tables, with the reference levels listed
read-only on the Source & accuracy page.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bsh1A5WLRb9xhiGNxUvs8p

* Qualify reference-levels promise for datum-less stations

Subordinate stations predicted by offsets (e.g. NOAA 9414849) ship no
datums table, so the Source & accuracy page has no reference levels to
list — don't promise them unconditionally.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Bsh1A5WLRb9xhiGNxUvs8p

---------

Co-authored-by: Claude <noreply@anthropic.com>
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