Bin directional observations across the north boundary, retain calm and missing readings separately, and report sector shares with a clear speed-band contract.
Wind roses: map direction, speed and calm conditions without losing the denominator
Write down what a direction means
A wind rose summarizes how often wind arrived from each compass sector, often subdivided by speed. In meteorological usage, a north reading means air came from the north; an arrow showing where the air travels points south. Confusing origin with travel direction rotates the interpretation by half a circle. Other directional datasets, such as vehicle headings, may use the direction of travel instead, so the chart title must say which convention applies. Angles wrap: 359 degrees and 1 degree belong next to each other, not at opposite ends of a linear axis. Choose a compass origin, clockwise ordering and sector count before grouping. With eight equal sectors, a north-centered bin covers angles near both zero and 360 degrees. Encoding choices and wrapped coordinates explain why a straight numeric interval can be misleading here.
Separate calm from missing and invalid
When wind speed falls below a declared calm threshold, direction is physically uninformative or not reported. Give calm observations a separate count and share. A missing direction with a measurable wind speed is a data-quality issue, not calm. A missing speed is another quality issue. Decide whether the reporting denominator includes all valid measured periods, calm plus directional periods, or only non-calm directional periods, and put that choice beside every percentage. Comparing two stations using different calm thresholds changes the result even if their actual wind conditions match. Time spacing also matters: ten readings captured in one busy hour should not carry the same meaning as ten evenly spaced hours if the goal is time exposure. The example assumes one equally weighted observation per scheduled time slot and rejects malformed data. Denominator policy and missing-period rules must be fixed before charting.
Keep speed bands and radial scale explicit
A sector wedge can be divided into speed bands, but its total must reconcile to the number of qualifying observations in that sector. Use one speed unit throughout, non-overlapping boundaries and a named rule for observations exactly on a boundary. Here bands are below 6, from 6 through less than 14, and 14 or above, in metres per second. The code places a value of exactly 6 into the middle band. Label whether radius encodes count, percent of all valid periods, or percent within a sector. These answer different questions. If wedge angle is fixed, radial length is easy to compare but geometric area grows with its square; do not say area represents frequency unless the rendering actually uses an area-correct transform. Give a companion table of sector totals, band counts and shares. Area encoding and accessible alternatives cover those distinctions.
Compare stations on matched exposure
A rose from one winter month should not be compared casually with a full-year rose from another location. Align the observation window, sampling cadence, sensor height and missingness policy. Report the number of eligible time slots and the share excluded for missing readings; a direction bias can be produced by a sensor that drops out during storms. A wind rose aggregates away sequence. A short storm and recurring moderate winds may occupy the same direction sector but have different operational meaning. For an exposure or safety decision, pair the rose with a time-series chart and separate gust statistics. Do not infer local causes from sector frequencies alone. Seasonal subseries can expose changing seasonal patterns, while small multiples keep station comparisons on a common radial scale.
Worked contract
from math import isfinite
SECTORS = ("N", "NE", "E", "SE", "S", "SW", "W", "NW")
def wind_rose_ledger(readings: list[tuple[str, float | None, float | None]],
calm_below: float = 1.0):
if not isfinite(calm_below) or calm_below < 0:
raise ValueError("calm threshold must be finite and nonnegative")
sector_bands = [[0, 0, 0] for _ in SECTORS]
seen_slots = set()
calm = missing = 0
for slot_id, direction_from_degrees, speed_mps in readings:
if not slot_id or slot_id in seen_slots:
raise ValueError("each scheduled slot needs a unique ID")
seen_slots.add(slot_id)
if speed_mps is None or direction_from_degrees is None:
missing += 1
continue
if (not isfinite(speed_mps) or speed_mps < 0 or
not isfinite(direction_from_degrees) or
not 0 <= direction_from_degrees < 360):
raise ValueError("speed and direction must use declared units")
if speed_mps < calm_below:
calm += 1
continue
sector = int((direction_from_degrees + 22.5) // 45) % 8
band = 0 if speed_mps < 6 else 1 if speed_mps < 14 else 2
sector_bands[sector][band] += 1
measured = len(readings) - missing
if measured == 0:
raise ValueError("no measured slots")
directional = sum(sum(bands) for bands in sector_bands)
assert directional + calm == measured
return {
"measured": measured, "missing": missing, "calm": calm,
"calm_share": calm / measured,
"sector_bands": dict(zip(SECTORS, sector_bands)),
}
hourly_readings = [("hour-47", 359.0, 5.0), ("hour-48", 1.0, 6.0),
("hour-49", 47.0, 14.0), ("hour-50", 271.0, 0.4),
("hour-51", None, 9.0)]
rose = wind_rose_ledger(hourly_readings)
assert rose["sector_bands"]["N"] == [1, 1, 0]
assert rose["sector_bands"]["NE"] == [0, 0, 1]
assert (rose["measured"], rose["calm"], rose["missing"]) == (4, 1, 1)
assert rose["calm_share"] == 0.25Performance and operating cost
For N scheduled readings, validation and accumulation take O(N) expected time; the slot-ID set uses O(N) space, while the fixed eight-by-three tally uses O(1). The example groups 359 and 1 degrees into north, assigns exactly 6 metres per second to the middle speed band, and counts a measured low-speed west reading as calm. Four measured hours form the denominator, so calm share is 25 percent. The fifth scheduled hour is missing, not calm. A real deployment should monitor missing-share changes and may need duration weighting when observation intervals are unequal.
Common Mistakes
- Reading meteorological wind direction as the direction air travels toward.
- Placing angles near zero and 360 degrees in distant bins.
- Converting missing directions into calm readings or silently dropping them from every count.
- Comparing roses with different sampling windows, calm thresholds or radial denominators.
Validation drill
Build a rose for 83 scheduled hourly slots from a sensor log. Reconcile directional, calm and missing counts, document the direction convention and speed units, then compare two matched seasons using the same sectors and radial scale.
