Repository navigation
Add LINZ tide predictions for Tauranga with tide state at any time - #25
Merged
Merged
Conversation
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>
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.
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_yearfetches LINZ's yearly Tauranga CSV fromstatic.charts.linz.govt.nzand caches it underdata/cache/tides/. A file already on disk is not downloaded again.data/cache/is gitignored.parse_predictionsreads 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.tide_atcosine-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 raisesValueError.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:
Tests
bash scripts/check.shpassed (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):swellsense tides --date 2026-07-15(standard time):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.