Skip to content

feat!: available forecast window is now dependent the current hour (instead of 12 AM of the day) and implemented quantitive changes to let the OpenMeteo forecast and reflect the amount of sunshine that passes through clouds - #92

Merged
lmarkmann merged 2 commits into
mainfrom
weather-intake
Sep 6, 2026

Conversation

@lmarkmann

@lmarkmann lmarkmann commented Sep 6, 2026

Copy link
Copy Markdown
Owner

What changed

Request window. forecast_hours=168&past_hours=24&timeformat=unixtime replaces forecast_days=7. The old window started at local midnight, so an evening launch had already spent most of its first day and could scrub six days ahead; the new one is 24 hours back and 168 forward from now, and --at -6h lands inside it. Timestamps are unix seconds, so the local-string parse and its Decode path are gone.

Sun through cloud. The analytic sky's weight was (1 - cover), which switched the physical model off under any cloud, a cirrus veil included. It is now the model's direct_normal_irradiance_instant over Meinel's clear-sky beam at that elevation, and the same number is Sun.strength, which scales the disc and its glow. This closes the "known compromise in the analytic blend" note.

Turbidity from aerosol optical depth. New weather::aerosol fetches CAMS AOD at 550 nm beside the forecast (scoped thread, same latency); Atmosphere::from_readings maps it through Preetham's beta relation and falls back to visibility when the request fails or past the five-day horizon. Visibility still drives the near-ground haze.

Precipitation. rain, showers and snowfall are read separately: sleet draws both renderers, freezing rain draws rain, any showers make the low deck cumulonimbus. precipitation_probability scales what is drawn (floor 0.3). Storm intensity is cape / 2500 when CAPE is present.

Fog. Code 45/48, or humidity >= 97% with visibility under 1 km, becomes a full-frame veil (the fog draft's haze, darkened at night), pulls the gradient toward a new Palette::Fog by daylight, and hides stars and meteors.

README credits Open-Meteo (CC BY 4.0) and GeoNames, as their licence asks.

Not in this change

minutely_15=lightning_potential is regional and needs a second time axis. No --model flag and no previous-runs request; forecast confidence is expressed through precipitation probability only.

Release

Breaking on the public API (HourlyArrays.time and the daily timestamps are i64, HourlyArrays and Sun gain fields), so this is 0.8.0. cargo-semver-checks reports the added fields; the type change it cannot see is named in the BREAKING CHANGE trailer. Goldens are unchanged: no scene carries an analytic sky and Sun.strength defaults to 1.0, so the render is bit-identical there.

Verification

just ci and just policy green locally; 210 tests. Live: --plain now, --at -6h, --at -23h, --at +7d, --at +167h, --frame all return the expected sky.

…how much sun gets through

The forecast request asked for seven calendar days from local midnight,
so a launch at 22:00 had spent most of its first day already and could
scrub six days ahead. It now asks for 24 hours back and 168 forward from
the current hour, with unix timestamps, which also removes the local
wall-clock string parsing and its error path.

Three hand-derived quantities are replaced by fields the model already
computes. The analytic sky's weight was (1 - cover), which switched the
physical model off under any cloud, a cirrus veil included; it is now the
direct beam over Meinel's clear-sky beam, and the same number dims the
sun disc and its glow, so a sun behind a deck is a faint patch rather
than a disc painted over the cloud. Turbidity came from visibility,
which most models cap at 24 km and which therefore sat at 2 on most
days; it now comes from CAMS aerosol optical depth through Preetham's
own beta relation, fetched beside the forecast and falling back to
visibility when that request fails or past its five-day horizon.
Storm intensity was rain rate; it is CAPE when present.

Rain, showers and snowfall are read separately, so a sleet hour draws
both renderers, freezing rain draws rain, and any showers make the low
deck cumulonimbus. Precipitation probability scales what is drawn, with
a floor so light certain rain still shows. Fog, from the code or from
saturation with under a kilometre of visibility, becomes a full-frame
veil, pulls the gradient toward a fog palette by daylight, and hides the
stars.

The README credits Open-Meteo and GeoNames as their licence asks.

BREAKING CHANGE: HourlyArrays.time and DailyArrays.time, sunrise and sunset are i64 unix seconds instead of local ISO strings; HourlyArrays gains rain, showers, precipitation_probability, cape, direct_normal_irradiance_instant and aerosol_optical_depth; Sun gains strength; compose_at no longer fails on a timestamp it cannot parse.
@codspeed

codspeed Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will improve performance by 52.95%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 3 improved benchmarks
✅ 71 untouched benchmarks
⏩ 10 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation at_far 212 µs 73.9 µs ×2.9
Simulation at_near 82.5 µs 73.1 µs +12.91%
Simulation timeline_168h 5.1 ms 4.6 ms +10.52%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing weather-intake (6aba832) with main (f546234)

Open in CodSpeed

Footnotes

  1. 10 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@lmarkmann lmarkmann changed the title feat!: window the forecast on the current hour and let the model say how much sun gets through feat!: available forecast window is now dependent the current hour (instead of 12 AM of the day) and implemented quantitive changes to let the OpenMeteo forecast and reflect the amount of sunshine that passes through clouds Sep 6, 2026
@lmarkmann
lmarkmann merged commit c6abb9e into main Sep 6, 2026
8 checks passed
@lmarkmann
lmarkmann deleted the weather-intake branch September 6, 2026 19:43
@lmarkmann lmarkmann mentioned this pull request Sep 6, 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.

1 participant