Skip to content

Add LINZ tide predictions for Tauranga with tide state at any time - #25

Merged
xquantize merged 1 commit into
feature/conditionsfrom
agent/linz-tauranga-tides-115c
Oct 14, 2026
Merged

xquantize merged 1 commit into
feature/conditionsfrom
agent/linz-tauranga-tides-115c

Conversation

@xquantize

Copy link
Copy Markdown
Owner

Part of #21. Fixes #24.

Spot profiles say which tides work. This loads official Tauranga predictions so code can say what the tide is doing at any moment. Every Bay of Plenty spot uses this port for now. Secondary-port offsets come later.

What changed

  • download_year fetches LINZ's yearly Tauranga CSV from static.charts.linz.govt.nz and caches it under data/cache/tides/. A file already on disk is not downloaded again. data/cache/ is gitignored.
  • parse_predictions reads the real CSV shape: three preamble lines, then day rows with up to four time/height pairs and no high/low column. A tide is high when it is higher than the next one.
  • Times are Pacific/Auckland civil time. Checked on the 2026 file: 15 January is UTC+13 and 15 July is UTC+12, so daylight saving is already in the published clock times. LINZ's tide page says the same.
  • tide_at cosine-interpolates height between the surrounding low and high. The bottom third of that range is low, the top third is high, and the rest is mid. A time outside the loaded events raises ValueError.
  • swellsense tides [--date YYYY-MM-DD] prints that day's highs and lows in New Zealand local time, then LINZ's acknowledgement. The default day is today in Pacific/Auckland.

Attribution

The constant is the adapted-work sentence from linz.govt.nz/copyright, because these CSVs are published on a LINZ subdomain and the tide page says they are not the official Nautical Almanac tables:

This work is based on/includes Toitū Te Whenua Land Information New Zealand data which are licensed by Toitū Te Whenua Land Information New Zealand for re-use under the Creative Commons Attribution 4.0 International licence.

Tests

bash scripts/check.sh passed (115 tests). Tests use a small fixture in the real CSV shape and never call the network. Separately, download_year(2026) matched a direct download of the LINZ file (1410 tides, highs and lows alternating all year).

swellsense tides --date 2026-01-15 (daylight saving):

Tauranga 2026-01-15 (Pacific/Auckland)
05:28  high  1.6 m
11:25  low   0.7 m
17:29  high  1.6 m
23:50  low   0.5 m

swellsense tides --date 2026-07-15 (standard time):

Tauranga 2026-07-15 (Pacific/Auckland)
01:05  low   0.3 m
07:18  high  1.9 m
13:26  low   0.2 m
19:54  high  2.1 m

On the 2026 file, the 05:31 high is 1.8 m and phase high. Halfway down to the next low is phase mid and falling. Halfway up from that low to the next high is phase mid and rising. A time before the first prediction raises ValueError.

Open in Web Open in Cursor 

Cache the yearly standard-port CSV, read its times as Pacific/Auckland
civil time, and interpolate height and phase between highs and lows.

Co-authored-by: Zane <xquantize@users.noreply.github.com>
@xquantize
xquantize marked this pull request as ready for review October 14, 2026 21:43
@xquantize
xquantize merged commit 6e96f12 into feature/conditions Oct 14, 2026
1 check passed
@xquantize
xquantize deleted the agent/linz-tauranga-tides-115c branch October 14, 2026 21:43
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