Repository navigation
Add Open-Meteo forecast for a spot: swell, wind waves and wind - #27
Merged
Merged
Conversation
Combine the marine and wind APIs into Pacific/Auckland hours, cache the pair for one hour, and print them from swellsense forecast. 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 Stage 3 (#21). Targets
feature/conditions.swellsense forecast <spot-id> [--hours 12]fetches an hourly forecast for one spot and prints swell, wind waves and wind in Pacific/Auckland, plus Open-Meteo's credit.Spotcan carry an optionalforecast_lat/forecast_lon. When they are omitted, the request uses the beach point.fetch_forecastcalls the Marine API (wave, swell, wind-wave height, period and direction) and the Forecast API (10 m wind speed, gusts and direction). Wind is requested withwind_speed_unit=kn, so knots are stored as returned.u = -speed * sin(direction)andv = -speed * cos(direction), so 0° is a north wind.forecast_lat/forecast_lonslightly offshore. That failure is not cached.data/cache/forecast/for one hour. The free API is non-commercial only. The credit constant is the licence-page wording: "Weather data by Open-Meteo.com", with the CC BY 4.0 link.Live check of all 7 Bay of Plenty spots (2 hours each) returned marine data at the beach coordinates, so
data/spots.yamlhas no offshore points.swellsense forecast mount-main-beach --hours 6printed a local-time table, for example swell 0.3 m at 6.2 s from 43° and wind 11 kn gusting 26 kn from 347° at 10:00 NZDT.Tests use
MockTransportonly: the two APIs are joined by hour (wind timestamps reversed), January and July offsets differ, nulls becomeNone, an all-null marine payload raises, and a cache younger than one hour does not call the network.