# Method

Two questions, two calls. **plan** answers "what should I do near here over
the next few days": for each day, the sun and moon at the point, the walks
that fit the weather and the night's best stargazing. **check** answers "is
my plan on": for a named walk on a date, or stargazing at a point on a night,
a verdict, the timing, the other days that suit it and better options nearby.

## Verdicts

Every walk and night leads with a verdict and a one-line `why` in UK local
time.

- **go**: it fits.
- **marginal**: it fits with a catch the `why` names.
- **unknown**: the hourly forecast does not reach far enough to say yet.
- **no**: it does not fit.

MET Norway's forecast is hourly for about two and a half days, and the
connector counts 48 hours from each fetch as hourly. Days further out, up to
13 days ahead, come back **unknown**; for nights the `why` quotes how often
the site has been clear in that month. A plan lists only go and marginal
options. Plan data includes `hourly_until`, the latest UTC cutoff among the requested datasets (null if unavailable). Individual locations may end earlier. A day with none says why in `walk_note` or `stargazing_note`.

## Walks

### Optional UKV support

When a walk check includes UKV support, `walk.ukv` gives its status and any samples.
Otherwise the field is absent. Its hours cover only the checked walk's returned slot;
`plan`, other days and nearby alternatives retain their existing forecasts.
`status` is `sampled`, `unavailable` or `stale`. Sampled values do not establish
safe conditions. Missing values stay null and unsupported hours stay absent.

Real inputs currently identify walk starts only. They are model grid samples,
with both requested and sampled WGS84 coordinates, never measured summit
forecasts. Synthetic fixtures exercise explicit summit elevations. Actual
summit coverage requires summit coordinates and elevations from DoBIH. Route ascent
never supplies summit elevation. No height adjustment is applied to wind.

Wind and gust are km/h. Cloud base is metres with an explicit height reference;
above-ground values need the sampled model orography in metres above mean sea
level before comparison. Unknown references cannot support that comparison.
Freezing level and explicit point elevations use metres above mean sea level.
UTC run and hourly valid times are separate. Runs older than 12 hours and
future-dated support are unavailable for assessment; forecast steps are never
interpolated. Supported cloud or freezing evidence can downgrade `go` to
`marginal` with the point and valid hour in the reason. Existing `marginal`,
`no` and `unknown` outcomes are preserved. Missing elevation preserves the
existing verdict and conveys no summit safety assessment.

Each returned UKV weather field has a separate `meta.sources` entry with its
field path, adaptation description and CC BY-SA 4.0 licence URI. Reuse of these
fields remains permitted under those terms, including through metered access.
Other sources retain their existing metadata and reuse terms.

### Walk-start forecasts

**Walks** are the Walkhighlands catalogue: name, start point, length, ascent
and estimated time, with a link to the walk's page. The route, maps and
descriptions stay on Walkhighlands; follow the link for them.

**Forecast** is MET Norway's Locationforecast at each walk's start point,
fetched every two hours. It is not a summit forecast: conditions on high
ground are usually colder and windier. For hill days also check the Mountain
Weather Information Service.

A **good hour** is a complete daylight hour (starting at or after sunrise and ending by sunset at the walk's start)
with at most 2 mm of rain and wind at most 80 km/h. 2 mm in an hour is light
rain, so by default a good hour may be drizzly.

**Weather limits.** `max_rain_mm_h`, `max_wind_kmh` and `min_temp_c`, on
plan and check, change what counts as a good hour to what the person will put
up with: `max_rain_mm_h=0` asks for dry hours only, and `max_rain_mm_h=4`
accepts wetter ones. Temperature has no default limit. The limits apply
before the slot is found, so they change the verdict, the start window, the
other days and the walks offered nearby. Loosening needs forecast data that
carries every daylight hour; on data that holds the default good hours only,
such a limit is refused as not available yet rather than silently ignored.
There is no limit on gusts or the chance of rain: MET Norway forecasts them
only within its Nordic model, which in Scotland covers Shetland alone. Each
limit rounds to the
data's 0.1 in its strict direction (a maximum down, a minimum up), so
rounding never admits an hour the caller ruled out. Under limits the hours
beside a slot are often daylight the person ruled out, so a long walk's
dark credit counts only on a side of the slot that meets real darkness
(before sunrise or after sunset at the start): with neither, the walk does
not fit, and with only the far side, it starts with the slot and finishes in
the dark.

The **slot** is the day's longest run of good hours, with one bad hour
tolerated inside it. A walk **fits** when the slot holds at least 80% of its
estimated time; walks over seven hours get two hours of credit for starting
or finishing in the dark. Only hours that have not begun count, so at 11:20
today's slot starts at 12:00 at the earliest, and the start window never lies
in the past.

- **go** when it fits in daylight, with no bad hour inside the slot and wind
  at most 50 km/h.
- **marginal** when it fits only with the dark credit, with a bad hour
  mid-walk, or in wind over 50 km/h.
- **no** when the slot is too short, or there is no good hour at all.
- **unknown** when the hourly forecast ends before the day's daylight does
  and no slot long enough has appeared yet.

`start_from` and `start_by` bound the start time that keeps the walk inside
the slot. A walk longer than its slot gets one start: before the slot, so it
finishes at the slot's end, or at sunrise when that would be dark, so it runs
past the slot's end. A walk that needs the dark either way is `marginal`. The slot carries its highest wind, total rain, wettest hour
(`max_rain_mm_h`), `wet_hours` (good hours with at least 0.1 mm of rain) and
temperature range across its good hours, so an agent can tell a dry, calm
slot from a drizzly, breezy one. A check also returns the checked walk's slot
hour by hour (`hours`): rain, wind, temperature, cloud, low cloud and fog,
each where the forecast gives it. The one bad hour a slot may hold is
`good: false` with `fails` naming what it failed (`rain`, `wind`, `cold`); on
data that holds good hours only, a bad hour that failed the defaults has no
weather.

**In a plan**, walks whose start is within `radius_km` of the point, and
that pass the filters on estimated time (`min_duration_h`,
`max_duration_h`), length (`min_length_km`, `max_length_km`) and ascent
(`max_ascent_m`), are assessed for each day; go comes before marginal, then the longest slot, then
the nearest. Walks that do not fit are left out, and the day's `walk_note`
says why when none fit.

**In a check**, a walk is found by `walk_id` or by `walk_name`, which matches
Walkhighlands names ignoring case, accents and apostrophes. It first looks for
names where every query word starts a word of the name. A name that starts
with the whole query ranks first, then shorter names. If no prefix match
exists, lookup ignores linking words and handles possessives, then allows a
single edit against a name word of five or more letters. An unresolved name
can receive up to three suggestions. Other matches are listed in
`also_matched`. When the walk is not a go, `nearby_walks` offers up to two
that fit better the same day: of similar length (half to one and a half times
its time), starting within 20 km, nearest first.

## Light windows

`light` (REST `GET /v1/light`) computes light at the supplied coordinates,
even when no forecast snapshot is available.

`from` and `to` are inclusive Europe/London civil dates. Today through two
days later is the default, with at most seven dates and nothing later than
13 days ahead. Coordinates round to 0.01 degrees. `radius_km` has plan's
1 to 100 km bounds and 30 km default; the effective forecast-site reach is
at most 30 km. The nearest site wins, with ID breaking exact distance ties.
Astronomy stays at the requested point; the returned `site` identifies where
the weather samples came from, with its fetch time, horizon and truncation.

Sun, moon and twilight crossing times are UTC RFC3339 seconds. Each date owns local midnight to
the next midnight, so DST dates can have 23 or 25 hours. Null means the
crossing does not occur on that date. Absent windows are omitted, with an
empty array when none exist. Intervals include their start and exclude their end,
are clipped at midnight and sorted by start then kind. The same night can
appear as two civil-date pieces. Each window carries the existing
noon-to-noon night label at its midpoint.

Sunrise/set use centre altitude -0.833 degrees. Civil, nautical and
astronomical dawn/dusk cross -6, -12 and -18 degrees, with twilight windows
between adjacent thresholds (civil ends at -0.833). Golden light is sun
-4 to +6 degrees; blue light is -6 to -4. Moonrise/set use topocentric
centre altitude -0.833 degrees as an approximate refraction and disc-radius
allowance. Moon phase and lit fraction are sampled at local noon,
`reference_at`: new 0, first quarter .25, full .5 and last quarter .75.
Direction is waxing before the unrounded phase .5 and waning after it.

Milky Way windows require fixed galactic-centre RA 17h45m, declination
-29 degrees above the geometric horizon and sun below -12 degrees
(nautical darkness, matching stars). July can retain astronomical twilight
throughout the night. Twilight and moonlight still limit faint details;
these are geometry windows with no guarantee of a useful view.
Astronomical darkness below -18 degrees is returned separately. Computation
uses the existing truncated solar/lunar series and linear sidereal time,
without terrain or core refraction. Numerical events resolve to about a
second; the simplified astronomical model has lower physical accuracy.

The optional `kinds` filter selects golden, blue, civil, nautical, astronomical,
darkness or milky_way windows. Pass a comma-separated query value to REST or
an array to MCP. Omission selects all windows. By default, windows retain RFC3339 `from` and `until` and a nested `cloud` verdict. For unknown windows, `cloud.why` is an empty string and the enclosing day supplies `cloud_why`. Opt in with `compact=true` (MCP boolean `true`) for the following representation. Each window’s `from_s` and
`until_s` are elapsed seconds from Europe/London midnight on the day’s date,
including on clock-change days. Each window reports its own `coverage`.
The day’s `cloud_why` explains unknown support once. Omitted sample counts
and supported seconds are zero. The stars snapshot retains only already-clear (cloud below 10%)
twilight-dark (sun below -10 degrees) samples. Their one-hour buckets are
intersected with the window and requested-point sun below -10.
`supported_seconds` measures the union of those intersections. `samples`
counts matching rows. `clear` requires the whole window to have sample
support; otherwise `unknown` has `partial` or `none` coverage. These are
sampled forecasts, with no claim of continuously clear conditions at the
point. Golden/blue cloud is unknown because those observations are absent.
No missing row proves cloud. No new forecast feed is queried.

Missing, future-dated or expired site fetches are unknown. Hours before the
as-of hour or the site's fetch hour are dropped; complete hourly buckets
must end by the earlier site/dataset 48-hour horizon. Truncated lists retain
their positive samples but cannot establish anything about omitted hours.
`nights` separately reuses `AssessNight` for suitability, including moonlight
and coverage. A whole-night verdict is never an interval cloud forecast.
Moon advice text is omitted there because `days` already carries the geometry.

For cacheable plan and light answers (see Freshness), browsers can reuse an
answer for 60 seconds and the
Cloudflare-only header gives the edge 600 seconds, with the same bounded
stale directives. The ETag includes snapshot version, as-of hour, exact
freshness state and canonical query. Forecast updates can change the cloud
part. Headers and fixture tests establish the repository contract; actual
edge hits, query isolation and published cloud coverage remain live checks.

## Stargazing

A **clear-dark hour** is a forecast hour at a site where cloud cover is below
10% and the sun is more than 12 degrees below the horizon. A **clear-twilight
hour** relaxes the sun to 10 degrees below. For about seven weeks around
midsummer Scotland gets no darkness past -12 degrees, and twilight hours are
then the darkest available.

**Sites** are a 2 km grid over Scottish land, kept where they are within 2 km
of a drivable road (OpenStreetMap) and fall in the three darkest
light-pollution zones (pristine, excellent, rural).

**Forecast** cloud cover is MET Norway's Locationforecast for each site,
fetched every three hours.

**Nights** run from local noon to local noon (Europe/London) and are named by
the date of their evening: a plan day's stargazing, and a check's `date`, are
the night that starts that evening. Until 09:00 the night under way is
yesterday's date, and plan and check accept it.

**The moon.** A clear-dark hour is **moonless** when the moon is below the
horizon or under 10% lit. Positions come from truncated lunar and solar
series after Meeus (Astronomical Algorithms), within about a third of a
degree of a full ephemeris. `moon_illumination` is the lit fraction at local
midnight after the evening.

**Dark score** weighs a night's clear-dark hours by the moon: a moonless hour
counts 1, a moonlit one 1 minus the moon's lit fraction.

- **go** at a dark score of 3 or more.
- **marginal** when it is clear but short of that: only twilight-dark, too
  few clear-dark hours, or a bright moon.
- **no** when it is cloudy all night.
- **unknown** when the hourly forecast ends before the night does and what is
  forecast is not already a go.

The stars snapshot lists at most 25 clear hours per site, earliest first. A
night past the end of a capped site's list is **unknown** unless it is
already a go: its later hours were left out of the snapshot, not forecast
cloudy.

`clear_from` and `clear_until` bound the night's clear-dark hours (its
clear-twilight hours when none is dark), which may have gaps.

**In a plan**, sites within `radius_km` are ranked by verdict, then dark
score, then distance, and kept at least 5 km apart. **In a check**, the
answer is the best site within 10 km of the point, widening to 30 km with a
`site_note` when none is that close.

**Clear-sky odds** are the share of dark hours that were clear in that
calendar month over the Copernicus CERRA reanalysis record.

## Sun

Sunrise and sunset use the NOAA solar equations at the point, with the
standard 50 arcminutes for refraction and the sun's radius.

## Places

Pass the latitude and longitude of the place the person means; they are
rounded to 0.01 degrees (about 1 km), and anything outside Scotland is
refused. Distances are great-circle approximations, accurate to well under
0.1 km within the 100 km radius cap.

## Freshness

`meta.forecast_fetched_at` is the older of the newest MET Norway fetches
behind the answer; `meta.as_of` is the hour it is computed for. With warning
screening on, plan and light send `no-store` to browsers and Cloudflare, even
when no active warning applies. A plan that includes walks also uses `no-store`
when roadworks screening is on. Other successful plan and light answers allow
caching. Check responses always use `no-store`.

## Near-term aurora

`aurora` (MCP) and `GET /v1/aurora?lat=...&lon=...` share one
snapshot-only engine. Supply coordinates. Omit `at` to assess at the snapshot’s `forecast_at`,
or supply an RFC3339 timestamp with timezone. Outside the 1 km radius,
the unknown answer includes the nearest site ID, coordinates and distance.
The assessment returns `go`, `marginal`, `no` or `unknown`, with per-input
evidence and source times. When optional aurora support is off or its
snapshot is unavailable, the verdict is `unknown`; plan, check and readiness keep their existing rules.

NOAA OVATION supplies an observation time, a forecast time and a global
longitude/latitude intensity grid. Its usual 30 to 90 minute lead varies with
solar-wind travel time. The current-Kp fallback can have no lead. The JSON
does not identify that forcing mode or supply a valid-until timestamp. This
version supports the exact forecast instant only, with requests between now
and two hours ahead. An equal observation/forecast timestamp is reported
as `no_lead`; this alone does not identify the fallback mode.

Application freshness limits are separate: NOAA collection under 20 minutes,
observation under two hours, MET collection under four hours and MET issue
under six hours. Exactly at an expiry limit is unknown. Future input times
are unknown. Refreshing or retaining a cached object never extends support.
Both HTTP cache headers are `no-store`, including conditional requests.

The nearest NOAA cell must be within 80 km. A supported site must be within
1 km, with unrounded coordinates. Weather uses MET's unfiltered instant cloud
rows: an exact row, or the larger cloud fraction from two bracketing rows no
more than an hour apart. It never bridges a missing hour or extrapolates a
capped row. Darkness uses shared solar-coordinate calculations at the requested
site/time, with the stars policy's -10 and -12 degree thresholds.

Every input must be supported before any assessment other than unknown.
Sun at or above -10 degrees, cloud at least 75%, sampled northern terrain at
least 10 degrees, or NOAA intensity below 10 gives `no`. Sun below -12,
cloud at most 25%, terrain at most 3 degrees and intensity at least 30 gives
`go`; intermediate conditions are `marginal`. These are conservative heuristic
thresholds, not calibrated local sighting probabilities or travel advice.
Terrain covers 19 sampled bearings from northwest to northeast, to 20 km.
It excludes trees, buildings, distant terrain beyond that radius and access
conditions. Coarse raster sampling can miss narrow ridges. Null cells and
absent terrain remain unknown. Synthetic test terrain proves computation only.

Sources: [NOAA product and fallback description](https://www.spaceweather.gov/products/aurora-30-minute-forecast),
[MET instant-variable contract](https://api.met.no/doc/locationforecast/datamodel),
[GMTED2010 metadata and terms](https://topotools.cr.usgs.gov/gmted_viewer/gmted2010_fgdc_metadata.html).

## Met Office warnings

Plan, check and light list the `Met Office` source in `meta.sources` when they screen activities for regional warnings. If that source is absent, the answer includes no warning assessment. Each walk or site fixture supplies a warning_region code from one of the six Scottish RSS feeds. The writers derive it from the OS Boundary-Line council area that contains the walk start or site. A missing region, incomplete observation or observation older than five minutes produces unknown coverage with the official Met Office link. Yellow caps go at marginal. Amber and Red yield no. The assessment includes the original warning title, description and link.

## Stargazing outlook

Use `outlook` (GET `/v1/outlook`) for seasonal planning. Compare historical CERRA totals for calendar months in an inclusive Europe/London date range of up to one year (default one year from today). Rate ranks clear-dark share among months with at least 300 dark hours. Absolute ranks total clear-dark hours. Missing climatology and weather are unknown. For spans up to seven days, local astronomy gives daily UTC intervals with sun below -12 degrees and moon below -0.833 degrees.

## Planned roadworks near walk starts

Plan and check can include an optional `road_note` for Scottish A/trunk-road closures,
including motorways, and explicit `Convoy Working` activities listed in the
Scottish Road Works Register. Roads qualify when the street name starts with
an A or M number (with an optional `t` suffix), or contains `trunk road`.
Portable traffic lights alone do not qualify. A match is within 5 km straight-line
distance of the walk start to the
provider's plotted location. There is no approach-route or last-road routing
and no route graph. Notes never affect weather verdicts, ranking or eligibility.
Check applies the same rule to nearby alternatives and each listed other date.

The requested date is a Europe/London civil date, including daylight-saving
changes. Start and end are the provider's expected window, with both civil
dates included. Equal timestamps and a same-date midnight end before a daytime
start occur in the export. These are single-day windows. A listed multi-week
range does not mean a continuous closure. Notes retain source reference,
phase, status, UTC timestamps, location and the full free-text description,
including overnight restrictions and amnesties. Up to three activities appear
in stable identity order; `truncated` reports additional matches.

“Planned works listed; check Traffic Scotland on the day.” The daily register
can lag reality. It excludes unplanned incidents, landslips and crashes from
this coverage; emergency and urgent categories are filtered out. Missing
notes never mean roads are open. The optional feed stays outside readiness.
Invalid, missing, unsupported, future-dated or source data aged 36 hours or
more produces no notes. Failed polls and conditional 304s preserve source
clocks. Plan validators include the snapshot digest and freshness state.

Source: [Scottish Road Works Commissioner, SRWR open data](https://roadworks.scot/opendata),
under [OGL v3](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/).

### Winter avalanche forecasts

From 1 December through 30 April inclusive, plan and check include
`winter_note` when the walk starts inside one of six approximate area
boxes. The boxes in `internal/connector/trip.go` include a margin for
approach routes around Lochaber, Glencoe, Creag Meagaidh, the Northern
and Southern Cairngorms, and Torridon. The note gives the area name and
a link to its SAIS avalanche forecast. The connector makes no avalanche
assessment, and the link has no effect on the walk verdict.
