Commit the packet builder and the blind scorer as tools, with the blind-test result as a data file the site reads, and check estimates against their recorded inputs

This commit is contained in:
swaits committed 2026-11-20 12:59:44 -07:00
1 parent ebccfb2e33
commit 40f4cd43c4
8 files changed
+1478 -146

No files matched your search

+75 -110
View File
@@ -15,8 +15,12 @@ against sourced seasons says how often that matters.
Commands: fit (fit the model and record the leave-one-out figure), trial
(compare the climate sources), warm (read every point's climate into the
cache), propose (the review list), proposals (stage accepted estimates
for the refresh pipeline) and check (rerun every estimate and the fit).
cache), propose (the review list), estimates (the trails whose season is an
estimate) and check (rerun the machine estimate for every estimate and
flag any whose inputs changed, and the fit). The seasons themselves are
set by judgement from the packets of tools/season_judge.py, which also
stages them for the refresh pipeline; the machine estimate is one input
to that judgement and is not written to a record on its own.
"""
import sys
@@ -680,101 +684,44 @@ def _toml_str(text):
return '"' + str(text).replace("\\", "\\\\").replace('"', '\\"') + '"'
def _parse_months(text):
months = []
for piece in (text or "").replace(",", " ").replace(";", " ").split():
months.append(int(piece))
return sorted(set(months))
def inputs_signature(est):
"""What an estimate rests on, as a small comparable record: the machine
estimate's months and a digest of the climate at the high and low
ground and of the sourced trails it was compared with."""
normals = est["normals"]
med = season_model.medians(normals) if all(n is not None for n in normals) else None
material = json.dumps({"med": med, "near": [n[0] for n in est["neighbours"]]},
sort_keys=True)
return {"machine": sorted(est["months"] or []),
"digest": hashlib.sha256(material.encode()).hexdigest()[:16]}
def proposals(root, reviewed_csv, given_dir=None):
"""Stage one change proposal per accepted reviewed row (a row with
months). A row with a note was adjusted by hand, and its method
sentence says so. Returns how many proposals were staged."""
with open(reviewed_csv, newline="", encoding="utf-8") as f:
reviewed = list(csv.DictReader(f))
staging = refresh.staging_dir(root, given_dir, create=True)
out = os.path.join(staging, "staged", "season-estimate")
today = datetime.date.today().isoformat()
source = season_climate.SOURCE
report = []
for row in reviewed:
tid = (row.get("id") or "").strip()
try:
months = _parse_months(row.get("proposed_months"))
except ValueError:
raise ValueError(f"{tid}: proposed_months {row.get('proposed_months')!r} "
"is not a list of month numbers")
if not tid or not months:
continue
rec = refresh.load_toml(os.path.join(root, tid, "trail.toml"))
hike = rec.get("hike") or {}
if hike.get("season"):
raise ValueError(f"{tid}: already has a season")
points, kind = sample_points(root, rec)
phrase = season.phrase_for(months)
method = season.method_sentence(source["name"], source["period"],
len(points), kind, RULE_VERSION)
note = (row.get("note") or "").strip()
comparable = (row.get("comparable") or "").strip()
if note and comparable:
method = method[:-1] + f", and adjusted by hand against {comparable}."
quote = (f"Monthly climate ({source['period']}) from {source['name']} "
f"gives {phrase} at the trail elevation.")
page = source["url"]
lines = ["[[proposal]]", 'kind = "change"', f"id = {_toml_str(tid)}",
f"date = {_toml_str(today)}",
f"summary = {_toml_str('Add an estimated season: ' + phrase + '.')}", ""]
def load_inputs(root):
path = os.path.join(root, "tools", "season_inputs.json")
try:
with open(path, encoding="utf-8") as f:
return json.load(f)
except OSError:
return {}
def edit(field, new_toml, old_toml=None):
lines.append("[[proposal.edit]]")
lines.append(f"field = {_toml_str(field)}")
if old_toml is not None:
lines.append(f"old = {old_toml}")
lines.append(f"new = {new_toml}")
lines.append(f"page = {_toml_str(page)}")
lines.append(f"quote = {_toml_str(quote)}")
lines.append("")
edit("hike.season", _toml_str(phrase))
edit("hike.months", "[" + ", ".join(str(m) for m in months) + "]")
edit("hike.season_basis", _toml_str("estimate"))
edit("hike.season_method", _toml_str(method))
checked_old = hike.get("checked")
edit("hike.checked", _toml_str(today),
_toml_str(checked_old) if checked_old else None)
lines += ["[[proposal.append]]", 'table = "hike.source"',
f"page = {_toml_str(page)}", f"quote = {_toml_str(quote)}", "",
"[proposal.append.entry]",
f"url = {_toml_str(page)}",
f"publisher = {_toml_str(source['publisher'])}",
'facts = ["season", "months"]', "",
"[proposal.history]",
f"change = {_toml_str('A season was estimated from climate: ' + phrase + '.')}",
f"basis = {_toml_str('No page states a season; it is estimated from climate (rule version ' + str(RULE_VERSION) + ').')}",
f"basis_url = {_toml_str(page)}",
'asked_by = "the dataset\'s own check"',
'fields = ["hike.season", "hike.months", "hike.season_basis", "hike.season_method"]',
""]
d = os.path.join(out, tid)
os.makedirs(d, exist_ok=True)
with open(os.path.join(d, "proposal.toml"), "w", encoding="utf-8") as f:
f.write("\n".join(lines))
remark = f"estimated season {phrase}" + (f"; note: {note}" if note else "")
report.append((tid, "changed", page, remark))
os.makedirs(out, exist_ok=True)
with open(os.path.join(out, "report.csv"), "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["id", "outcome", "pages", "remark"])
writer.writerows(report)
return len(report)
def estimates(root):
"""The ids of the records whose season is an estimate, in order."""
return [tid for tid, rec in _records(root)
if (rec.get("hike") or {}).get("season_basis") == "estimate"]
def check(root, fetch):
"""Rerun every estimated season and the leave-one-out fit. Returns
(ok, lines): not ok when an estimate would now come out different,
when the leave-one-out match share has fallen by more than 0.02
from season_fit.json, or when that file does not pass."""
"""Rerun the machine estimate for every estimated season and the
leave-one-out fit. Returns (ok, lines): not ok when an estimate's
inputs have changed since they were recorded in
tools/season_inputs.json (the machine estimate, the climate at the
trail, or the sourced trails it is compared with), when the
leave-one-out match share has fallen by more than 0.02 from
tools/season_fit.json, or when the blind test of the judged method
(tools/season_blind_test.json) is missing or below the bar. A changed
estimate is a flag for a person to look at, not a rewrite."""
import season_judge
try:
fit = load_fit(root)
except OSError:
@@ -783,18 +730,31 @@ def check(root, fetch):
params = load_params(root)
ok, lines, checked = True, [], 0
refs = references(root, fetch)
recorded = load_inputs(root)
for tid, rec in _records(root):
hike = rec.get("hike") or {}
if hike.get("season_basis") != "estimate":
continue
checked += 1
est = estimate(root, dict(rec, id=tid), params, fetch, refs)
old = sorted(int(m) for m in hike.get("months") or [])
new = sorted(est["months"] or [])
if new != old:
sig = inputs_signature(estimate(root, dict(rec, id=tid), params, fetch, refs))
then = recorded.get(tid)
if then is None:
ok = False
detail = est["phrase"] or est["reason"]
lines.append(f"{tid}: estimate was {old}, now {new} ({detail})")
lines.append(f"{tid}: no inputs are recorded for this estimate: run "
"python3 tools/season_judge.py inputs")
elif sig["machine"] != then["machine"]:
ok = False
lines.append(f"{tid}: inputs changed: the machine estimate was {then['machine']}, "
f"now {sig['machine']}; the season is {sorted(hike.get('months') or [])}")
elif sig["digest"] != then["digest"]:
ok = False
lines.append(f"{tid}: inputs changed: the climate or the similar sourced trails differ "
f"(machine estimate still {sig['machine']}); the season is "
f"{sorted(hike.get('months') or [])}")
for tid in sorted(set(recorded) - set(estimates(root))):
ok = False
lines.append(f"{tid}: has recorded inputs but is no longer an estimate: remove it "
"from tools/season_inputs.json")
sourced = sourced_trails(root, fetch)
if any(s[1] is not None for s in sourced):
_p, now, _loo = fit_sourced(sourced)
@@ -808,12 +768,21 @@ def check(root, fetch):
f"fit got worse: leave-one-out matches "
f"{now['within1']}/{now['n']} ({now_share:.2f}), "
f"was {stored['within1']}/{stored['n']} ({was_share:.2f})")
if not fit.get("passes"):
try:
blind = season_judge.load_blind_test(os.path.join(root, "tools", "season_blind_test.json"))
problems = season_judge.check_blind_test(blind)
if problems:
ok = False
lines += [f"tools/season_blind_test.json: {p}" for p in problems]
elif blind["share"] < BAR["within1_min"]:
ok = False
lines.append(f"the blind test matched {blind['share']:.2f}, under the bar of "
f"{BAR['within1_min']:.2f}; estimates must not ship")
except (OSError, ValueError, KeyError):
ok = False
lines.append("tools/season_fit.json does not pass the bar; "
"estimates must not ship")
lines.append("tools/season_blind_test.json is missing or unreadable")
if ok:
lines.append(f"check passed: {checked} estimated seasons unchanged")
lines.append(f"check passed: {checked} estimated seasons rest on the same inputs")
return ok, lines
@@ -892,9 +861,9 @@ def cmd_propose(args):
return 0
def cmd_proposals(args):
count = proposals(ROOT, args.reviewed, args.dir)
print(f"{count} proposals staged")
def cmd_estimates(args):
for tid in estimates(ROOT):
print(tid)
return 0
@@ -932,13 +901,9 @@ def main(argv=None):
propose_parser.add_argument("--cache", default=None,
help="climate cache directory")
propose_parser.set_defaults(func=cmd_propose)
proposals_parser = sub.add_parser(
"proposals", help="stage proposals from a reviewed list")
proposals_parser.add_argument("--reviewed", required=True,
help="reviewed estimates CSV")
proposals_parser.add_argument("--dir", default=None,
help="staging directory")
proposals_parser.set_defaults(func=cmd_proposals)
estimates_parser = sub.add_parser(
"estimates", help="list the trails whose season is an estimate")
estimates_parser.set_defaults(func=cmd_estimates)
check_parser = sub.add_parser(
"check", help="rerun every estimate and the fit")
check_parser.add_argument("--cache", default=None,
+24
View File
@@ -0,0 +1,24 @@
{
"date": "2026-11-20",
"measure": "within one month at each end of the season a page states",
"tested": 148,
"matched": 114,
"share": 0.77,
"by_confidence": {
"high": {
"tested": 52,
"matched": 48,
"share": 0.92
},
"medium": {
"tested": 76,
"matched": 55,
"share": 0.72
},
"low": {
"tested": 20,
"matched": 11,
"share": 0.55
}
}
}
+626
View File
@@ -0,0 +1,626 @@
#!/usr/bin/env python3
"""Packets, blind scoring and proposals for seasons set by judgement.
Python 3 standard library only. Where no page states a season, a reviewer
sets it from a packet: the trail's location, elevation, monthly climate
normals (tools/season_climate.py), the machine estimate of
tools/estimate_season.py and the most similar sourced trails. The method
was tested blind: the same reviewers estimated the trails whose season a
page states, from identical packets with the season hidden, and the share
they matched is in tools/season_blind_test.json, which the site reads.
docs/season-judging.md says how a reviewer works.
Commands:
packets write one packet per trail, and the three part lists
score score reviewers' answer files against the sourced seasons
(--write records the figures in tools/season_blind_test.json)
proposals stage the judged seasons for the trails with no season, for
python3 tools/refresh.py collect and apply
inputs record the machine estimate and the inputs of every estimate,
so the monthly check can see when they change
An answer file is tab separated, one trail a line, no header: id, months
(comma separated, 1 to 12), season phrase, confidence (high, medium or
low) and one sentence saying what sets the season there.
"""
import sys
sys.dont_write_bytecode = True
import argparse
import datetime
import json
import os
import random
import re
import statistics
HERE = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, HERE)
import estimate_season as E # noqa: E402
import refresh # noqa: E402
import season # noqa: E402
import season_climate as C # noqa: E402
import season_model as M # noqa: E402
ROOT = os.path.dirname(HERE)
BLIND_TEST = os.path.join(ROOT, "tools", "season_blind_test.json")
JUDGED = os.path.join(ROOT, "tools", "season_judged.tsv")
PAGES = os.path.join(ROOT, "tools", "season_judged_pages.json")
INPUTS = os.path.join(ROOT, "tools", "season_inputs.json")
SEED = 20261120
PARTS = 3
NCOMP = 10
PLACE_WEIGHT = 0.1 # climate-distance units per 1000 km between sample-point centres
KM_PER_MILE = 1.609344
CONFIDENCES = ("high", "medium", "low")
LEAD = "Judged from the climate at the trail's elevation and from similar trails."
MONTHS = ["January", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December"]
ABB = [m[:3] for m in MONTHS]
# ---------------------------------------------------------------------------
# Hiding the season: a packet never carries a sentence that bears on timing.
_MONTH_RE = re.compile(
r"\b(?:January|February|March|April|May|June|July|August|September|October|November|"
r"December|Jan|Feb|Mar|Apr|Jun|Jul|Aug|Sept?|Oct|Nov|Dec)\b(?!\s+[A-Z])\.?")
_SEASON_RE = re.compile(
r"\b(?:summer|winter|spring|fall|autumn|seasons?|seasonal|year[- ]?round|all[- ]year|"
r"snow[- ]?free|snowmelt|snow[- ]melt|snowpack|monsoons?|best time|time of year|when to go|"
r"(?:warm|warmer|cold|colder|cool|cooler|hot|wet|dry|snowy|shoulder) months?)\b", re.I)
_LEAD_SEASON_RE = re.compile(r"^(?:Summer|Winter|Spring|Fall|Autumn|Seasons?|Seasonal)\b")
_SPLIT = re.compile(r"(?<=[.!?])\s+(?=[A-Z0-9\"'(])")
def mentions_season(sentence):
"""True when a sentence names a month or a season. A capitalised month
counts unless it starts a name ("May Lake"); a season word counts in
lower case or opening the sentence, so "Summer Lake" does not."""
sentence = re.sub(r"\bhot springs?\b", "", sentence, flags=re.I)
if _MONTH_RE.search(sentence):
return True
for found in _SEASON_RE.finditer(sentence):
word = found.group(0)
if word[0].islower() or word.lower().startswith(("year", "all", "snow")):
return True
return bool(_LEAD_SEASON_RE.match(sentence))
def clean(text):
"""(text without the sentences that bear on timing, those sentences)."""
kept, removed = [], []
for sentence in _SPLIT.split(str(text or "").strip()):
if not sentence:
continue
(removed if mentions_season(sentence) else kept).append(sentence)
return " ".join(kept), removed
def shown(kept, original):
if not original:
return "(not on file)"
return kept or "(none left after removing sentences that mention a season)"
# ---------------------------------------------------------------------------
# The blind protocol: trails are split into parts, and a trail's comparable
# trails never come from its own part.
def split_parts(sourced, others, n=PARTS, seed=SEED):
"""Deal the sourced and the other trails separately into n parts, in a
seeded shuffle, so every part holds a share of each."""
rng = random.Random(seed)
parts = [[] for _ in range(n)]
for group in (sourced, others):
group = list(group)
rng.shuffle(group)
for k, tid in enumerate(group):
parts[k % n].append(tid)
return [sorted(p) for p in parts]
def comparables(tid, part_of, sourced_ids, meds, centres, k=NCOMP, place_weight=PLACE_WEIGHT):
"""The k sourced trails closest to tid in climate and place, never itself
and never one dealt to its own part."""
if tid not in meds:
return []
rows = []
for other in sourced_ids:
if other == tid or part_of.get(other) == part_of.get(tid) or other not in meds:
continue
d = M.distance(meds[tid], meds[other])
km = C.haversine_km(*centres[tid], *centres[other])
rows.append((d + place_weight * km / 1000.0, other))
rows.sort()
return [other for _score, other in rows[:k]]
# ---------------------------------------------------------------------------
# The packet.
def _ft(metres):
return int(round(metres * 3.28084))
def _f(celsius):
return celsius * 9 / 5 + 32
def _ll(lat, lon):
return (f"{abs(lat):.1f}{'N' if lat >= 0 else 'S'}",
f"{abs(lon):.1f}{'W' if lon <= 0 else 'E'}")
def packet_text(rec, info, machine, comparables, pages=None, precip=None):
"""The packet for one trail, as text.
info: {"points": [PointNormals or None], "kind": "track"|"ends"|"place",
"profile": (highest_m, lowest_m) or None}. machine: the machine
estimate's months. comparables: rows of (name, regions, high ground
feet, season phrase, months). pages: what disagreeing pages say, or
None. precip: millimetres a month at each point, or None. The trail's
own season is never used."""
hike = rec.get("hike") or {}
tid = rec["id"]
out = [f"# Trail packet: {tid}", "", "## The trail", ""]
out += [f"- id: {tid}", f"- name: {rec['name']}",
f"- common name: {rec.get('common_name') or '(none on file)'}",
f"- country: {rec['country']}",
f"- states or provinces: {', '.join(rec.get('regions') or []) or '(none on file)'}",
f"- length: {rec['length_km'] / KM_PER_MILE:.0f} miles",
f"- kind: {rec.get('kind') or '(not on file)'}",
f"- shape: {hike.get('shape') or '(not on file)'}",
f"- terrain: {', '.join(hike.get('terrain') or []) or '(not on file)'}",
f"- travel: {hike.get('travel') or '(not on file)'}"]
hp, name = hike.get("high_point_m"), hike.get("high_point")
out.append("- high point: " + (f"{_ft(hp)} ft" + (f" ({name})" if name else "")
if hp is not None else "(not on file)"))
days = hike.get("days")
out.append("- typical days: " + (f"{days[0]} to {days[1]}" if days and len(days) == 2
and days[0] != days[1] else (str(days[0]) if days else "(not on file)")))
out += ["", "## Summary, start and end", "",
"(Sentences that bear on timing have been removed.)", ""]
for label, key in (("Summary", "summary"), ("Start", "start"), ("End", "end")):
kept, _removed = clean(hike.get(key))
out.append(f"{label}: {shown(kept, hike.get(key))}")
points = M.usable(info["points"])
out += ["", "## Where it is", ""]
if points:
lats, lons = [p.lat for p in points], [p.lon for p in points]
south, _ = _ll(min(lats), 0)
north, _ = _ll(max(lats), 0)
_, west = _ll(0, min(lons))
_, east = _ll(0, max(lons))
out += [f"- sample points: {len(points)}",
f"- southernmost: {south}; northernmost: {north}",
f"- westernmost: {west}; easternmost: {east}",
f"- rough extent: {south} to {north}, {west} to {east}" if len(points) > 1
else f"- rough extent: a single point at {south}, {west}"]
out.append("- location is: " + {
"track": "a real track (points spaced along it)",
"ends": "start and end points only (no track)",
"place": "a region-centre fallback (no track and no end points; the centre of "
"the first region's box)"}[info["kind"]])
out += ["", "## Elevation", ""]
if points:
high, low = M.high_low(points)
out.append(f"- high ground (the upper quarter of the sample points): "
f"{_ft(statistics.median(p.elev_m for p in high))} ft")
out.append(f"- low ground (the lower half of the sample points): "
f"{_ft(statistics.median(p.elev_m for p in low))} ft")
prof = info.get("profile")
out.append("- track's highest and lowest points: " + (
f"{_ft(prof[0])} ft and {_ft(prof[1])} ft" if prof else "(no track elevation on file)"))
out += ["", "## Climate normals (1981 to 2010)", ""]
if points:
pr_of = {}
if precip and len(precip) == len(points) and all(precip):
pr_of = {id(p): pr for p, pr in zip(points, precip)}
def by_month(group, get):
return [statistics.median(get(p)[m] for p in group) for m in range(12)]
hh = by_month(high, lambda p: p.tmax_c)
ll = by_month(low, lambda p: p.tmax_c)
out.append("Mean daily high in degrees F, " + ("and monthly precipitation in inches, "
if pr_of else "")
+ "at the high ground and at the low ground.")
out.append("")
if pr_of:
ph = by_month(high, lambda p: pr_of[id(p)])
pl = by_month(low, lambda p: pr_of[id(p)])
out += ["| month | high ground F | low ground F | high ground precip in | low ground precip in |",
"|---|---|---|---|---|"]
out += [f"| {ABB[m]} | {_f(hh[m]):.0f} | {_f(ll[m]):.0f} | {ph[m] / 25.4:.1f} | {pl[m] / 25.4:.1f} |"
for m in range(12)]
else:
out += ["| month | high ground F | low ground F |", "|---|---|---|"]
out += [f"| {ABB[m]} | {_f(hh[m]):.0f} | {_f(ll[m]):.0f} |" for m in range(12)]
out += ["", "(Precipitation is not available for this trail.)"]
else:
out.append("No climate data is available for this trail's location.")
out += ["", "## Machine estimate", "",
"Labelled: machine estimate, right about two times in three.", "",
"Months: " + (", ".join(map(str, machine)) + " (" + ", ".join(MONTHS[m - 1] for m in machine) + ")"
if machine else "none"),
"", "## Comparable trails", "",
"The ten trails with a season on record that are most similar in climate and "
"nearest in place (this trail is never listed).", ""]
if comparables:
out += ["| trail | state | high ground elevation | season | months |", "|---|---|---|---|---|"]
out += [f"| {n} | {', '.join(regions)} | {feet} ft | {phrase} | {', '.join(map(str, months))} |"
for n, regions, feet, phrase, months in comparables]
else:
out.append("(none)")
if pages:
out += ["", "## What pages say", "", "Published pages disagree about this trail's season.", "", pages]
return "\n".join(out) + "\n"
# ---------------------------------------------------------------------------
# Answers and the blind score.
def read_answers(path, known):
"""({id: (months, phrase, confidence, why)}, [(line number, problem)])."""
answers, problems, known = {}, [], set(known)
with open(path, encoding="utf-8") as f:
for n, raw in enumerate(f, 1):
line = raw.rstrip("\n")
if not line.strip() or line.startswith("#") or line.lower().startswith("id\t"):
continue
c = line.split("\t")
if len(c) < 4:
problems.append((n, f"expected at least 4 tab-separated columns, got {len(c)}"))
continue
tid, text, phrase, conf = c[0].strip(), c[1].strip(), c[2].strip(), c[3].strip().lower()
why = c[4].strip() if len(c) > 4 else ""
if tid not in known:
problems.append((n, f"unknown id {tid!r}"))
elif tid in answers:
problems.append((n, f"duplicate id {tid}"))
elif conf not in CONFIDENCES:
problems.append((n, f"{tid}: confidence must be high, medium or low: {conf!r}"))
else:
try:
months = sorted({int(x) for x in re.split(r"[,\s]+", text) if x})
except ValueError:
problems.append((n, f"{tid}: months are not numbers: {text!r}"))
continue
if not months or months[0] < 1 or months[-1] > 12:
problems.append((n, f"{tid}: months empty or outside 1 to 12: {text!r}"))
continue
answers[tid] = (months, phrase, conf, why)
return answers, problems
def score(answers, truth):
"""The blind result: for every trail whose season a page states (truth,
{id: months}) whether the reviewer's months match within a month at each
end, in all and by the reviewer's confidence. A trail with no answer is
tested and counts as missed; an answer for a trail not in truth is not
scored."""
by = {c: {"tested": 0, "matched": 0} for c in CONFIDENCES}
tested = matched = unanswered = 0
for tid, months in sorted(truth.items()):
tested += 1
if tid not in answers:
unanswered += 1
continue
got, _phrase, conf, _why = answers[tid]
hit = bool(M.score(got, months)[0])
matched += hit
by[conf]["tested"] += 1
by[conf]["matched"] += hit
return {"tested": tested, "matched": matched, "unanswered": unanswered, "by_confidence": by}
def _share(matched, tested):
return round(matched / tested, 2) if tested else 0.0
def write_blind_test(path, figures, date):
doc = {
"date": date,
"measure": "within one month at each end of the season a page states",
"tested": figures["tested"],
"matched": figures["matched"],
"share": _share(figures["matched"], figures["tested"]),
"by_confidence": {
c: {"tested": v["tested"], "matched": v["matched"],
"share": _share(v["matched"], v["tested"])}
for c, v in figures["by_confidence"].items()},
}
with open(path, "w", encoding="utf-8") as f:
json.dump(doc, f, indent=1, sort_keys=False)
f.write("\n")
def load_blind_test(path=BLIND_TEST):
with open(path, encoding="utf-8") as f:
return json.load(f)
def check_blind_test(doc):
"""Problems with the figure file: the parts must add up to the whole and
each share must be the matched count over the tested count."""
problems = []
by = doc.get("by_confidence") or {}
if sorted(by) != sorted(CONFIDENCES):
problems.append("by_confidence must hold high, medium and low")
return problems
if sum(v["tested"] for v in by.values()) != doc["tested"]:
problems.append("the confidence groups do not add up to the trails tested")
if sum(v["matched"] for v in by.values()) != doc["matched"]:
problems.append("the confidence groups do not add up to the trails matched")
for name, v in [("all", doc)] + list(by.items()):
if v["matched"] > v["tested"]:
problems.append(f"{name}: more matched than tested")
elif v["share"] != _share(v["matched"], v["tested"]):
problems.append(f"{name}: the share is not matched over tested")
return problems
# ---------------------------------------------------------------------------
# Writing the judged seasons: proposals for refresh.py collect and apply.
def method_text(why, confidence, lead=LEAD):
"""The season_method an estimate carries: how it was set, what sets the
season there, and the confidence."""
return f"{lead} {why.strip()} Confidence: {confidence}."
def proposals(root, answers_path, pages_path, given_dir=None):
"""Stage one proposal for every trail with no season that has an answer.
A trail named in the pages file was set by judgement from pages that
differ: its season is `sources`, citing those pages, with the sentences
the file gives as its method. Every other is an `estimate` citing the
climate data. Returns how many were staged."""
ids = refresh.trail_ids(root)
answers, problems = read_answers(answers_path, ids)
if problems:
raise ValueError("; ".join(f"line {n}: {t}" for n, t in problems))
pages = {}
if pages_path and os.path.exists(pages_path):
with open(pages_path, encoding="utf-8") as f:
pages = json.load(f)
staging = refresh.staging_dir(root, given_dir, create=True)
out = os.path.join(staging, "staged", "season-judged")
today = datetime.date.today().isoformat()
source = C.SOURCE
report = []
for tid in ids:
rec = refresh.load_toml(os.path.join(root, tid, "trail.toml"))
hike = rec.get("hike") or {}
if hike.get("season") or tid not in answers:
continue
months, _phrase, conf, why = answers[tid]
phrase = season.phrase_for(months)
judged_pages = pages.get(tid)
if judged_pages:
basis = "sources"
method = f"{judged_pages['why'].strip()} Confidence: {conf}."
cites = [(s["url"], s["publisher"], s["quote"]) for s in judged_pages["sources"]]
note = "the pages differ; set by judgement"
else:
basis = "estimate"
method = method_text(why, conf)
quote = (f"Monthly climate ({source['period']}) from {source['name']} "
f"at the trail elevation, read with the seasons of similar trails.")
cites = [(source["url"], source["publisher"], quote)]
note = "estimated from climate"
page, _publisher, quote = cites[0]
lines = ["[[proposal]]", 'kind = "change"', f"id = {E._toml_str(tid)}",
f"date = {E._toml_str(today)}",
f"summary = {E._toml_str('Add a season, ' + note + ': ' + phrase + '.')}", ""]
def edit(field, new_toml, old_toml=None):
lines.append("[[proposal.edit]]")
lines.append(f"field = {E._toml_str(field)}")
if old_toml is not None:
lines.append(f"old = {old_toml}")
lines.append(f"new = {new_toml}")
lines.append(f"page = {E._toml_str(page)}")
lines.append(f"quote = {E._toml_str(quote)}")
lines.append("")
edit("hike.season", E._toml_str(phrase))
edit("hike.months", "[" + ", ".join(str(m) for m in months) + "]")
edit("hike.season_basis", E._toml_str(basis))
edit("hike.season_method", E._toml_str(method))
checked_old = hike.get("checked")
edit("hike.checked", E._toml_str(today), E._toml_str(checked_old) if checked_old else None)
for url, publisher, q in cites:
lines += ["[[proposal.append]]", 'table = "hike.source"',
f"page = {E._toml_str(url)}", f"quote = {E._toml_str(q)}", "",
"[proposal.append.entry]",
f"url = {E._toml_str(url)}",
f"publisher = {E._toml_str(publisher)}",
'facts = ["season", "months"]', ""]
if basis == "estimate":
change = f"A season was estimated: {phrase}."
why_basis = ("No page states a season. It was set by judgement from the climate "
"at the trail's elevation and from similar trails.")
else:
change = f"A season was set from pages that differ: {phrase}."
why_basis = ("The pages that state a season differ and none is the managing body, "
"association or route author, so it was set by judgement from all of "
"them and the climate estimate.")
lines += ["[proposal.history]", f"change = {E._toml_str(change)}",
f"basis = {E._toml_str(why_basis)}",
f"basis_url = {E._toml_str(page)}",
'asked_by = "the dataset\'s own check"',
'fields = ["hike.season", "hike.months", "hike.season_basis", "hike.season_method"]',
""]
d = os.path.join(out, tid)
os.makedirs(d, exist_ok=True)
with open(os.path.join(d, "proposal.toml"), "w", encoding="utf-8") as f:
f.write("\n".join(lines))
report.append((tid, "changed", page, f"season {phrase}; {note}"))
os.makedirs(out, exist_ok=True)
import csv
with open(os.path.join(out, "report.csv"), "w", newline="", encoding="utf-8") as f:
writer = csv.writer(f)
writer.writerow(["id", "outcome", "pages", "remark"])
writer.writerows(report)
return len(report)
# ---------------------------------------------------------------------------
# Command line.
def _truth(root):
truth = {}
for tid, rec in E._records(root):
hike = rec.get("hike") or {}
if season.read_from_a_page(hike):
truth[tid] = sorted(int(m) for m in hike.get("months") or [])
return truth
def build_packets(root, out_dir, fetch, precip_file=None, pages_text=None):
"""Write packets/<id>.md and part-N.txt under out_dir. Reads the climate
through fetch (the cache); returns the number of packets."""
recs = {tid: dict(rec, id=tid) for tid, rec in E._records(root)}
ids = sorted(recs)
truth = _truth(root)
precip = {}
if precip_file:
with open(precip_file, encoding="utf-8") as f:
precip = json.load(f)
params = E.load_params(root)
refs = E.references(root, fetch)
info, meds, centres = {}, {}, {}
for tid in ids:
pts, kind = E.sample_points(root, recs[tid])
norms = E.normals_at(pts, fetch)
profile = None
if kind == "track":
try:
with open(os.path.join(root, tid, "elevation.json"), encoding="utf-8") as f:
data = json.load(f)
profile = (data["highest"]["m"], data["lowest"]["m"])
except (OSError, KeyError, TypeError, ValueError):
profile = None
got = M.usable(norms)
info[tid] = {"points": got or [], "kind": kind, "profile": profile}
if got:
meds[tid] = M.medians(got)
centres[tid] = (sum(p.lat for p in got) / len(got), sum(p.lon for p in got) / len(got))
parts = split_parts([t for t in ids if t in truth], [t for t in ids if t not in truth])
part_of = {t: n for n, p in enumerate(parts) for t in p}
os.makedirs(os.path.join(out_dir, "packets"), exist_ok=True)
for n, part in enumerate(parts, 1):
with open(os.path.join(out_dir, f"part-{n}.txt"), "w", encoding="utf-8") as f:
f.write("\n".join(part) + "\n")
pages = {}
if os.path.exists(PAGES):
with open(PAGES, encoding="utf-8") as f:
pages = json.load(f)
for tid in ids:
rec = recs[tid]
est = E.estimate(root, rec, params, fetch, refs)
comp = []
for other in comparables(tid, part_of, sorted(truth), meds, centres):
o = recs[other]
high, _low = M.high_low(info[other]["points"])
comp.append((o["name"], o.get("regions") or [],
_ft(statistics.median(p.elev_m for p in high)),
str((o.get("hike") or {}).get("season")), truth[other]))
text = packet_text(rec, info[tid], est["months"] or [], comp,
pages=_pages_text(pages.get(tid)),
precip=precip.get(tid))
with open(os.path.join(out_dir, "packets", f"{tid}.md"), "w", encoding="utf-8") as f:
f.write(text)
return len(ids)
def _pages_text(entry):
if not entry:
return None
publishers = "; ".join(s["publisher"] for s in entry["sources"])
return f"Publisher(s): {publishers}\nMonths each gives: {entry.get('months_text', '')}"
def cmd_packets(args):
fetch = E._fetch_with_cache(args.cache)
n = build_packets(ROOT, args.out, fetch, args.precip)
print(f"{n} packets written to {args.out}/packets")
return 0
def cmd_score(args):
ids = refresh.trail_ids(ROOT)
truth = _truth(ROOT)
answers = {}
for path in args.answers:
got, problems = read_answers(path, ids)
for n, text in problems:
print(f"{path} line {n}: {text}")
answers.update(got)
figures = score(answers, truth)
t, m = figures["tested"], figures["matched"]
print(f"owner's measure (within one month at each end): {m} of {t} = {100 * m / t:.1f}%"
f" ({figures['unanswered']} unanswered)")
for c in CONFIDENCES:
v = figures["by_confidence"][c]
print(f" {c:<7} {v['matched']:>3} of {v['tested']:<3} = "
f"{100 * v['matched'] / v['tested'] if v['tested'] else 0:.1f}%")
if args.write:
write_blind_test(args.write, figures, args.date or datetime.date.today().isoformat())
print(f"written to {args.write}")
return 0
def cmd_proposals(args):
n = proposals(ROOT, args.answers, args.pages, args.dir)
print(f"{n} proposals staged")
return 0
def cmd_inputs(args):
fetch = E._fetch_with_cache(args.cache)
params = E.load_params(ROOT)
refs = E.references(ROOT, fetch)
doc = {}
for tid, rec in E._records(ROOT):
if (rec.get("hike") or {}).get("season_basis") == "estimate":
doc[tid] = E.inputs_signature(E.estimate(ROOT, dict(rec, id=tid), params, fetch, refs))
with open(args.write, "w", encoding="utf-8") as f:
json.dump(doc, f, indent=1, sort_keys=True)
f.write("\n")
print(f"inputs of {len(doc)} estimates written to {args.write}")
return 0
def main(argv=None):
parser = argparse.ArgumentParser(description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
sub = parser.add_subparsers(dest="command", required=True)
p = sub.add_parser("packets", help="write the packets and part lists")
p.add_argument("--out", required=True)
p.add_argument("--precip", default=None,
help="JSON {id: [twelve monthly mm for each sample point]}; optional")
p.add_argument("--cache", default=None)
p.set_defaults(func=cmd_packets)
p = sub.add_parser("score", help="score answer files against the sourced seasons")
p.add_argument("answers", nargs="+")
p.add_argument("--write", default=None, help="record the figures in this JSON file")
p.add_argument("--date", default=None)
p.set_defaults(func=cmd_score)
p = sub.add_parser("proposals", help="stage the judged seasons for refresh.py")
p.add_argument("--answers", default=JUDGED)
p.add_argument("--pages", default=PAGES)
p.add_argument("--dir", default=None)
p.set_defaults(func=cmd_proposals)
p = sub.add_parser("inputs", help="record the inputs of every estimate")
p.add_argument("--write", default=INPUTS)
p.add_argument("--cache", default=None)
p.set_defaults(func=cmd_inputs)
args = parser.parse_args(argv)
return args.func(args)
if __name__ == "__main__":
sys.exit(main())
+223
View File
@@ -0,0 +1,223 @@
across-utah-route 4,5,6,9,10 April to June and September to October medium Desert heat in summer and snow in the Henrys, La Sals and Bryce country in winter leave spring and fall.
akshayuk-pass 7,8 July to August medium Arctic Baffin Island is frozen and snowbound until late June and freezes up again by September, so the walkable window is the two summer months.
alexander-mackenzie 6,7,8,9 June to September medium Snow lingers on the Interior Plateau and Tweedsmuir highlands into June and autumn rain and early snow return in October.
allegheny-trail 4,5,6,7,8,9,10 April to October medium Mid-elevation West Virginia mountains are mild and green from April to October, with winter snow and ice and summer humidity making the edges less pleasant.
alpine-trail-7 7,8,9 July to September high Heavy winter snow at 7,000 feet in the Swan Range melts out by mid-July, and snow returns in October.
american-discovery-trail 4,5,6,7,8,9,10 April to October low A coast-to-coast thru-hike starts in spring and must reach the Colorado and Sierra high ground in summer before autumn snow, so the whole route fits April to October.
appalachian 3,4,5,6,7,8,9,10 March to October high A northbound thru-hike starts in March-April in Georgia and reaches Katahdin by September-October before Maine's snow, so the season spans March to October.
appalachian-high-route 4,5,6,9,10 Spring and fall medium Mountain loop over 5,000-foot ridges in NC and TN where summer is hot and humid and winter is icy, so spring and fall are the comfortable windows.
arizona 3,4,5,9,10,11 Spring and fall medium Low desert is too hot in summer and the high forest and Grand Canyon rim hold snow in winter, so thru-hikers go north from March to May or flip into fall.
avon 4,5,6,7,8,9,10 April to October medium Winter snow and early-spring mud on Ontario farmland end with the thaw, and the walk runs until late fall.
backbone 1,2,3,4,5,10,11,12 October to May medium Santa Monica Mountains chaparral is baking hot and dry from June to September, so the cool wetter months and spring wildflowers are the walking season.
baker 4,5,6,9,10 April to June and September to October medium Humid, buggy summers and icy, muddy winters in western Pennsylvania make spring and fall the usual walking months.
bartram 3,4,5,9,10,11 Spring and fall medium Blue Ridge route with summer heat and haze below and winter ice on the 5,000-foot balds, so spring and fall are best.
basin-and-range-trail 4,5,9,10 Spring and fall high Nevada desert route with scorching summer heat and little water and snow on the high ranges in winter, so spring and fall are the windows.
batona 3,4,5,9,10,11 March to May and September to November medium Flat Pine Barrens walking is best when it is cool, away from summer heat, ticks and biting flies.
bay-circuit 3,4,5,9,10,11 March to May and September to November medium Humid, buggy summers and icy winters in low-lying eastern Massachusetts leave spring and fall, though it can be walked all year.
bayou-state-trail 1,2,3,4,11,12 November to April medium Summer heat, humidity, mosquitoes and storms in Louisiana push hiking into the cool, dry winter and early spring.
beartooth-high-route 7,8,9 July to September high Cross-country route at about 11,000 feet in the Beartooths where snow lingers into July and returns by late September, so only mid-summer works.
benton-mackaye 3,4,5,9,10,11 Spring and fall medium Southern Appalachian ridges up to 5800 ft are pleasant in spring and fall, while summer is hot, humid and buggy and winter brings ice.
big-bend-100 1,2,3,11,12 November to March high Chihuahuan Desert heat above 90F from May to September makes the cool months the only sensible window.
big-seki-loop 7,8,9 July to September high High Sierra passes up to 13,000 ft hold snow into early July and fresh snow returns by October, leaving July to September.
bigfoot-trail 7,8,9 July to September medium Klamath-Siskiyou high ground holds snow into June and gets heavy autumn rain from October, so the dry summer months fit.
bitterroots-80-mile-route 7,8,9 July to September medium High Selway-Bitterroot ground near 7,900 ft holds snow into early July and fall snow returns by October.
black-canyon 1,2,3,4,10,11,12 October to April high Sonoran Desert foothills are dangerously hot from May to September, so the cool months from October to April are the season.
blue-mountains-trail 5,6,9,10 May to June and September to October low Hot dry summers in the canyons and snow in the Wallowas and Blues outside late spring and early fall limit the window, though high sections are fine in midsummer.
border-route 5,6,7,8,9,10 Late May to October medium Northern Minnesota boundary-waters ridges are snow-bound and muddy until May and bugs peak in June and July, but the trail is walkable from May through fall.
boreal-trail 6,7,8,9 June to September medium Saskatchewan boreal forest has long cold winters and is frozen into May, leaving the short warm summer for hiking.
boundary-trail-mount-st-helens 7,8,9,10 July to October high Cascade ridges around 5,000 feet hold snow until July, and heavy rain starts in late October.
boundary-trail-pasayten 7,8,9 July to September high The Pasayten high country at 5,500 to 7,500 feet is under snow until early July, and snow returns in October.
brazeau-loop 7,8,9 July to September high Jasper's high passes and river fords need snowmelt to subside, so it is walkable from July until the first snow in September.
bristol-hills-trail 5,6,7,8,9,10 May to October medium Snow and mud make winter and early spring uncommon for walking, so the comfortable months run from late spring through fall.
brooks-range-traverse 6,7,8,9 June to September low Arctic tundra is frozen and snowbound most of the year, with river breakup in early June and freeze-up and snow by mid-September.
bruce-trail 4,5,6,7,8,9,10 April to October medium The Niagara Escarpment is icy and muddy through winter and early spring, so end-to-end hikes run from the April thaw to the end of October.
buckeye 3,4,5,9,10,11 Spring and fall medium Ohio summers are hot, humid and buggy and winters are cold and muddy, so spring and fall are the comfortable thru-hiking windows.
california-coastal 4,5,6,7,8,9,10 April to October low The coast can be walked all year, but winter storms bring heavy rain in the north and leave some sections passable only at low tide, so a full walk suits the dry months.
canol 7,8 July and August medium Mackenzie Mountains trail where snow lingers on the passes into late June and the first snow returns in early September, leaving July and August.
centennial-sd 5,6,9,10 May to June and September to October medium Black Hills summer heat and thunderstorms and winter snow leave late spring and early fall as the best months.
central-wilderness-grand-tour 6,7,8,9,10 June to October medium Mid-elevation Golden Trout Wilderness melts out early, but Coyote Lakes Pass and Kern crossings need low snow and low water, so summer through early fall.
central-wind-rivers-loop 7,8,9 July to September high Wind River Range snow and swollen creeks persist until mid-July and winter returns by late September.
chinese-wall-circuit 7,8,9 July to September high The Bob Marshall high country near 8,500 ft holds snow until July and gets fall snow by late September.
circle-of-solitude 7,8,9 July to September high High passes like Colby, Avalanche and Forester stay snowbound and high-water crossings last into July, with autumn storms after September.
cohos 6,7,8,9,10 June to October medium The pages differ: The Trek gives May to October and Backpacking Routes gives June to November. It was set by judgement from both and from the climate, since snow and mud last into late May and cold sets in by late October.
colorado-trail 7,8,9 July to September high San Juan and Collegiate high ground above 12,000 ft is snow-covered until early July and snows again by late September.
condor-trail 3,4,5,10,11 Spring and fall medium Los Padres coast ranges are very hot and dry from June to September and wet in midwinter, so spring and fall are the windows.
conestoga-trail 3,4,5,9,10,11 March to May and September to November medium The low Lancaster County hills are hot, humid and tick-ridden in summer, so the cool months suit it best.
conservation-trail 4,5,6,7,8,9,10 April to October medium Low-elevation western New York is snowy in winter and muddy in March, and can be walked from April until late fall.
continental-divide 5,6,7,8,9,10 May to October medium A thru-hike must start north of the Mexican border after the desert winter and clear the San Juans, Wyoming and Montana high ground between the June snowmelt and the first October storms.
corvallis-to-the-sea 5,6,7,8,9,10 May to October medium Very wet, muddy Coast Range winters push the walk into the drier months from late spring through early fall.
cottonwood-trail 6,7,8,9 June to September medium Yukon mountain passes are snow-covered until June and cold and snowy again by late September, leaving the short summer.
cranberry-lake-50 6,7,8,9,10 June to October medium Adirondack snow and mud in spring and black flies into June leave summer and fall as the usual window.
cross-vermont 5,6,7,8,9,10 May to October medium A low-elevation route of mostly rail trail and quiet roads, where winter snow and mud season bracket a long snow-free stretch from May to October.
dan-zhur-donjek 7,8 July to August medium Subarctic Kluane high country with glacial river crossings is snowbound until late June and snows again by early September.
deadman-and-cloud-canyons 7,8,9 July to September high High Sierra passes like Elizabeth Pass and Colby Pass hold snow and stream crossings run high until July, and autumn storms begin in October.
deadman-creek-loop 1,2,3,4,11,12 November to April medium Low Sonoran desert at about 2,200 ft reaches 90 to 100 F from May to September, so the walk belongs in the cool season.
deseret-hiking-route 5,6,7,8,9,10 May to October low A route from southern Utah desert canyons to the Pioneer Mountains of Idaho needs the high ground clear of snow and the south not scorching.
desert-trail 4,5,6,9,10 April to June and September to October low Waterless desert is too hot in summer and snowy in winter, so a full walk runs through spring and early fall.
desert-winter-thru-hike 1,2,3,11,12 November to March medium Designed as a winter route through Sonoran, Colorado and Mojave deserts that are too hot from April through October.
donut-hole 4,5,6,9,10 April to June and September to October low Unbridged streams run high in early spring, and the valleys are hot, humid and buggy in midsummer, so the shoulder months suit best.
eagle-cap-traverse 7,8,9 July to September high Wallowa high passes near 7,000 ft hold snow until early July and fall storms arrive in October.
east-beach-trail 5,6,7,8,9 May to September medium Haida Gwaii beach walking is best in the drier months, as heavy rain and storms dominate from October through winter.
east-coast-trail 6,7,8,9 June to September medium Newfoundland's cold, foggy shoulder seasons and lingering snow and ice leave summer into early fall as the comfortable window.
eastern-continental-trail 1,2,3,4,5,6,7,8,9,10 January to October low A thru-hike of about 300 days starts in the Florida winter and has to finish in the Gaspe before the November snows.
eastern-sierra-high-route 7,8,9 July to September high Cross-country passes above 10,500 feet need the snow to have melted, which is from mid-July through September.
finger-lakes 4,5,6,7,8,9,10 April to October medium The pages differ: one Trek page gives winter, spring, summer and fall, and a table on the same page gives spring, summer and fall. It was set by judgement from both and from the climate, since snow lies from December to March and early spring is muddy.
florida 1,2,3,11,12 November to March high Subtropical heat, wet-season flooding and bugs from May to October make the cool dry months the thru-hiking season.
foothills 3,4,5,9,10,11 Spring and fall medium Blue Ridge escarpment trail is comfortable in spring and fall, with hot humid summers and some winter ice at the higher end.
fremont 6,7,8,9,10 June to October medium Oregon ridge route at 6,000 to 8,000 feet is snow-covered into early June and snowy again by November, with dry summers.
ganaraska 4,5,6,7,8,9,10 April to October medium Southern Ontario is snowy in winter and muddy in March, and the trail can be walked from April until late fall.
general-george-crook 4,5,6,9,10 April to June and September to October medium Rim country is snowy in winter, and the July and August monsoon brings lightning and storms, leaving spring and fall.
georgia-loop 3,4,5,9,10,11 March to May and September to November medium The north Georgia mountains are hot, humid and stormy in summer and cold and icy on the ridges in winter.
gila-centennial-loop 3,4,5,9,10,11 March to May and September to November medium Gila canyons at 6,000 feet are hot from June to August, with monsoon storms and flash floods, and cold in winter.
gospel-hump-loop 7,8,9 July to September high Idaho subalpine ridges around 7,000 feet hold snow until late June and get snow again by October, so only summer into early fall works.
grand-enchantment 3,4,5,10,11 March to May, and October to November low The route crosses hot Sonoran desert and 10,000 ft Mogollon peaks, so a spring or fall thru-hike avoids summer heat at low ground and winter snow high up.
grand-moab-route 6,9,10 June and September to October low The route crosses 12,000-foot La Sal snow until June and desert canyons above 95F in July and August, which leaves early summer and fall.
grand-sawtooth-loop 7,8,9 July to September high Sawtooth passes and lake basins hold snow into early July and fall storms return in late September.
grand-teton-loop 7,8,9 July to September high Paintbrush Divide and Hurricane Pass hold snow into July and are snowy again by October, leaving July to September.
grand-valley-trail 4,5,6,7,8,9,10 April to October medium A low-elevation southern Ontario footpath that can be walked in all but deep winter and the muddy early spring.
great-basin-trail 4,5,6,9,10 April to June and September to October low Scarce water and 80 F summer heat in the valleys, plus winter snow on the ranges, favour spring and early fall.
great-colorado-route 6,7,8,9 June to September medium A route linking fourteeners and passes above 12,000 ft needs the snow gone, so it runs from early summer into early fall.
great-divide-trail 7,8,9 July to September high Alberta and BC Rockies passes stay snow-covered until early July and fresh snow returns in September, so thru-hikers walk July to mid-September.
great-eastern 4,5,6,7,8,9,10 April to October low A very long Appalachian walk, started in spring in Alabama and carried through summer humidity and into fall to avoid winter in the north.
great-plains-trail 5,6,7,8,9,10 May to October low A north-to-south prairie route from Saskatchewan to Texas is walked from late spring to fall, avoiding cold northern winters and heat in the south by timing.
great-western-divide-loop 7,8,9 July to September medium Kaweah Gap and the Great Western Divide hold deep snow into early July, and autumn storms return by October.
great-western-loop 4,5,6,7,8,9,10 April to October low A roughly 208-day circuit of western trails starts in spring from the Arizona desert and must clear the Sierra, Rockies and Cascades in summer before fall snow.
green-river-lakes-titcomb-basin-loop 7,8,9 July to September high The northern Wind Rivers hold snow and high water into mid-July and get fall storms by late September.
guadalupe-ridge-trail 3,4,10,11 Spring and fall medium Chihuahuan Desert lowlands are very hot from May to September and the ridge gets cold and windy in winter, so spring and fall are best.
hayduke-trail 4,5,9,10 April to May and September to October medium Canyon country is too hot in summer and the Henry Mountains and Boulder snow in winter, so thru-hikers start in spring or fall.
heart-lake-two-ocean-plateau-loop 7,8,9 July to September high Yellowstone's high backcountry has deep snow and high water into late June and returns to winter by October, so July to September is the window.
high-country-pathway 5,6,7,8,9,10 May to October medium Northern Michigan forest is snowbound in winter and muddy in early spring, and walkable from May to October, with bugs the main summer complaint.
high-sierra 7,8,9 July to September high Kaweah Gap and Whitney's high ground hold snow and run high streams until July, and autumn storms start in October.
highlands 3,4,5,9,10,11 March to May and September to November medium The low New Jersey and New York Highlands ridges are hot, humid and buggy in summer and icy in midwinter.
highline 4,5,6,9,10 April to June, and September to October medium Mogollon Rim at 6,000 ft is warm and dry in spring and fall, with summer monsoon storms in July and August and snow in winter.
hoosier-heritage-trail 3,4,5,9,10,11 March to May and September to November medium Indiana has hot, humid summers with ticks and thick vegetation, so spring and fall are the most comfortable months.
horse-shoe 3,4,5,9,10,11 March to May and September to November medium Southeast Pennsylvania has humid, buggy summers and icy winters, which leaves spring and fall.
hot-springs-trail 4,5,6,7,8,9 April to September low A northbound route of about 110 days from coastal California to Idaho needs the Sierra and the northern mountains clear of snow, so it runs from spring to early fall.
iat-newfoundland-labrador 6,7,8,9 June to September medium Western Newfoundland is cold, snowy and boggy until June, and storms and snow return in October.
ice-age 5,6,7,8,9,10 May to October medium The pages differ: one Trek page gives summer and fall and another gives summer only. It was set by judgement from both and from the climate, since snow and mud last through April and a hard freeze comes by November.
idaho-centennial 6,7,8,9 June to September medium Snow on the mountain sections lasts into June while the southern desert gets hot, so a north-bound walk runs June through September.
international-appalachian-trail-maine 6,7,8,9,10 June to October medium Northern Maine is snowbound and muddy until late May and frozen from November, and fall is best once the bugs fade.
island-walk 6,7,8,9,10 June to October medium Prince Edward Island is cold and wet in spring and late fall, so the walk is done in the warm months.
itijjagiaq-trail 7,8 July to August medium Baffin Island's Katannilik park is frozen and used by skiers and snowmobilers until June, so summer hiking is limited to July and August before September freeze.
john-muir 7,8,9 July to September high High Sierra passes above 11,000 ft are snow-choked until early July and storms and cold return in late September, so thru-hikes run July to September.
kanab-canyon-loop 3,4,5,10,11 Spring and fall high Grand Canyon inner gorge is dangerously hot from June to September with monsoon storms, so spring and fall are the standard seasons.
kings-canyon-high-basin-route 7,8,9 July to September high Off-trail travel over 12,000 ft passes needs the snow gone and stable weather, which only holds from July to September.
knobstone 3,4,5,9,10,11 March to May and September to November medium Southern Indiana summers are hot, humid and tick-ridden, while the steep, leafless bluffs in the cool shoulder seasons are the draw.
koroc-palmer-loop 7,8 July to August medium The Torngat Mountains in the Arctic are snowbound until late June and freeze again by September, leaving a short July and August window.
la-cloche 6,7,8,9,10 June to October medium Killarney is snowbound in winter and buggy in spring, so the warm months are the main window, with September and early October the best.
laurel-highlands 4,5,6,7,8,9,10 April to October medium Moderate Pennsylvania ridge at about 2,500 feet is snowy in midwinter but mild enough from April to October.
lone-star 1,2,3,11,12 November to March high East Texas piney woods are hot, humid and buggy for much of the year, so the cool winter months are the hiking season.
long-path 4,5,6,9,10 April to June and September to October medium Humid, buggy summers and icy winters in the Hudson Valley and Catskills favour spring and fall.
long-trail 6,7,8,9,10 June to October high Green Mountain ridges are muddy and snowy until late May and wintry by November, so thru-hikers walk June to October.
lost-coast 5,6,7,8,9 May to September high Heavy winter rain, slides and high tides make parts of the coast impassable, so the dry months with workable low tides are used.
lowest-to-highest-route 5,6,10 Late May to June, or October low Badwater is lethal in summer heat while Whitney holds snow until June, so the route fits a narrow window in late spring or early fall.
loyalsock 4,5,6,9,10 April to June and September to October medium Rocky, wet terrain in northern Pennsylvania is best in the cool shoulder seasons, before the humid, buggy summer.
maah-daah-hey 5,6,9,10 May to June and September to October medium Badlands clay turns to impassable gumbo when wet and summer is hot, so late spring and early fall are the usual months.
maricopa-trail 1,2,3,4,10,11,12 October to April high Phoenix-area Sonoran Desert is above 95F from May to September, so the cool months from October to April are the season.
mason-dixon 3,4,5,9,10,11 March to May and September to November medium The low Susquehanna valley is hot and humid in summer, so the cool spring and fall months suit best.
massanutten 3,4,5,9,10,11 Spring and fall medium Virginia ridge circuit with hot humid summers and cold winters, so spring and fall are most comfortable.
mattabesett 3,4,5,9,10,11 Spring and fall medium Low Connecticut traprock ridges are best in spring and fall, with summer humidity, heat and ticks and some winter ice on ledges.
metacomet-monadnock 4,5,6,9,10 Spring and early summer, and fall low New England ridge walking is cold and icy in winter and humid and buggy in midsummer, so spring and fall are favoured.
mid-state 4,5,6,7,8,9,10 April to October medium Pennsylvania ridge and plateau trail at about 2,000 feet is snowy in winter but fine from April to October, with summer humidity and ticks.
middle-fork-kings-river 7,8,9 July to September high Muir Pass and Hell-for-Sure Pass hold snow into early July and storms return in autumn, so July to September.
middle-fork-trail 6,7,8,9,10 June to October low Idaho river canyon and high bench trail clears of snow in June and gets cold wet weather by November, though low canyon heat peaks in July.
midland-to-mackinac-trail 6,7,8,9,10 June to October medium Snow and mud last into April in northern Michigan, and the walk is comfortable from June through early fall.
midstate-ma 4,5,6,9,10,11 April to June and September to November medium The gentle central Massachusetts hills are pleasant in spring and fall, with humid, buggy summers and cold, icy winters.
milestone-basin-and-the-upper-kern 7,8,9 July to September high Sierra passes above 10,000 ft and Kern fords stay snowy and high into early July, with autumn storms returning in October.
mogollon-rim-trail 4,5,9,10 April to May and September to October low Low desert sections reach 90 F by June and the White Mountains and Blue Range hold snow in winter, so spring and fall fit a full crossing.
mojave-sonoran-trail 1,2,3,11,12 November to March high Colorado River desert lowlands reach 100F from May to September, so the cool winter months are the only practical window.
monadnock-sunapee 6,7,8,9,10 June to October medium New Hampshire snow, mud and black flies linger into early June and the summit ridges are snowy from late fall.
montana-trail 6,7,8,9 June to September low A 90-to-122-day crossing from the Divide to the plains starts after mountain snow clears in June and aims to finish before winter on the Missouri breaks.
mountains-to-sea 3,4,5,9,10,11 March to May and September to November medium High Smokies and Blue Ridge are cold in winter while the Piedmont and coast are hot and humid in summer, so cool shoulder seasons suit a full walk.
nankoweap-bright-angel-loop 5,9,10 May and September to October low The Grand Canyon inner canyon is dangerously hot from June to August and the North Rim road is snowed in over winter, leaving late spring and early fall.
nepisiguit-migmaq-trail 6,7,8,9 June to September medium Northern New Brunswick is snowy and muddy through May and cold by October, with river and bug conditions favouring summer.
new-england 4,5,6,9,10 April to June and September to October medium Traprock ridges are cold and icy in winter and hot, humid and buggy in July and August, so spring and fall suit best.
north-boundary 7,8,9 July to September medium Snake Indian Pass and the Smoky River crossings need snowmelt in the Jasper backcountry, and winter returns by October.
north-country 5,6,7,8,9,10 May to October low A thru-hike across the northern states starts after the North Dakota spring thaw and must finish before winter sets in the Adirondacks and Vermont by late October.
north-south 3,4,5,9,10,11 March to May and September to November medium Rhode Island woods are humid and buggy in summer and cold in winter.
north-south-lbl 3,4,5,9,10,11 March to May and September to November medium The forests of western Kentucky and Tennessee are hot, humid and tick-ridden in summer, so spring and fall are favoured.
north-umpqua 6,7,8,9,10 June to October medium The upper Cascade sections near 6,000 feet hold snow into June and see heavy rain and snow from late October, though the river canyon can be walked earlier.
northern-colorado-trail 7,8,9 July to September medium Flat Tops and Rocky Mountain high ground above 11,000 ft is snowbound until early July and snows again by late September.
northern-new-mexico-loop 6,7,8,9,10 June to October low The Sangre de Cristo and Jemez high ground holds snow into June, and lower desert stretches are hot in midsummer, so a whole loop fits June to October.
northville-placid 6,7,8,9,10 June to October medium Adirondack wilderness trail is wet, snowy and muddy until late May, with black flies in May and June and cold weather by late October.
oak-ridges 4,5,6,7,8,9,10 April to October medium The southern Ontario moraine is snowy and muddy over winter and can be walked from April until late fall.
ocean-to-lake 1,2,3,11,12 November to March high South Florida is hot, wet and buggy from May to October with flooded swamp and prairie, so the cooler dry months are used.
oregon-coast 5,6,7,8,9 May to September medium The coast gets 10-16 inches of rain a month from November to March and the drier months from May to September make beach walking and creek crossings workable.
oregon-desert 4,5,6,9,10 Spring and fall medium High desert at 3,000-8,000 ft is hot and waterless in July and August and cold in winter, so spring and fall are the walking windows.
ottawa-temiskaming-highland-trail 6,7,8,9,10 June to October medium Northeastern Ontario forest is snowbound and muddy until May, with black flies in early summer, and cold by November.
ouachita 3,4,5,10,11 October to November and March to May medium The pages differ: one gives April to November, one gives late October to late March, and one gives all year. It was set by judgement from all three and from the climate, since summers are hot and humid with ticks and winters are cold but walkable.
ozark-highlands 3,4,5,10,11 Spring and fall medium Arkansas Ozark summers are hot, humid and buggy and winters are cold but popular for leaf-off views, so spring and fall are the typical seasons.
ozark-trail 3,4,5,9,10,11 March to May and September to November medium The pages differ: one Trek page gives spring or fall and another adds winter. It was set by judgement from both and from the climate, since the heat, humidity and ticks of July and August make summer a poor choice.
pacific-crest 4,5,6,7,8,9,10 April to October medium A thru-hike starts at the desert border in April or May, crosses the Sierra after the June to July snowmelt, and must finish the Washington Cascades by early October.
pacific-northwest 7,8,9 July to September medium An east-to-west thru-hike starts in Glacier after the snow clears in early July and must finish through the wet Olympic coast before October rain and early snow.
paumanok-path 3,4,5,9,10,11 March to May and September to November medium Long Island is humid and tick-heavy in summer, and the pine barrens are pleasant in the cool shoulder seasons.
pfiffner-traverse 7,8,9 July to September high A Continental Divide crest route above 11,000 feet with off-trail passes needs the snow gone, which is from July until the first big September storms.
pinhoti 3,4,5,10,11 Spring and fall medium Alabama and Georgia hills are hot and humid from June to September, and winter is wet and cold, so spring and fall are best.
powell-plateau-loop 5,9,10 May and September to October low The Grand Canyon's North Rim access is snowed in until May and the inner canyon is very hot in June to August, leaving late spring and early fall.
prescott-circle 3,4,5,9,10,11 March to May and September to November medium Prescott's high desert is hot in June to August with monsoon storms in July and August, while winters are cool but usually walkable, so shoulder seasons are best.
ptarmigan-glenns-lake-highline-loop 7,8,9 July to September high Glacier's Ptarmigan Tunnel, Stoney Indian Pass and Highline are snow-blocked until mid-July and the first snows come in late September.
quehanna 4,5,6,7,8,9,10 April to October medium Pennsylvania state forest trail at about 2,000 ft is walkable from April to October, with winter snow and March mud outside the season.
rae-lakes-loop 7,8,9 July to September high Glen Pass at 11,978 ft keeps snow into early July and the Kings River crossings run high, with autumn storms after September.
rideau-trail 4,5,6,7,8,9,10 April to October medium Eastern Ontario is snowy and muddy over winter, and the trail can be walked from April until late fall.
ring-the-peak 6,7,8,9,10 June to October low A loop around Pikes Peak that mixes stretches near 11,000 feet with lower trails, and is snow-free from about June to October.
river-to-river 3,4,5,10,11 Spring and fall medium Southern Illinois summers are hot, humid and buggy, with trailside poison ivy and ticks, so spring and fall are the comfortable seasons.
route-in-between 4,5,6,7,8,9,10 April to October low A Mexico-to-Canada link route through Arizona desert, Utah canyons and Idaho mountains has to chain a spring start with high Idaho snow clearing by summer and finishing before fall.
rutherford-lake-loop 7,8,9 July to September high Yosemite's south boundary passes at over 9,000 feet hold snow until early July, and autumn storms begin in October.
san-diego-trans-county-trail 1,2,3,4,11,12 November to April medium The Salton Sea end and the desert washes are over 100F in summer, so the cool months are used, with the 4,900-foot mountains still mild in winter.
santa-fe-to-taos 7,8,9 July to September medium Sangre de Cristo peaks near 12,000 ft are snowbound until late June and afternoon monsoon storms peak in July and August.
sawtooth-wilderness-high-route 7,8,9 July to September high Mostly cross-country passes near 9,000 feet and above need the snow gone, which is from mid-July through September.
sea-to-sea-route 4,5,6,7,8,9,10 April to October low A 7,775-mile coast-to-coast network across the northern prairie, the Rockies and the Cascades can only be walked from spring thaw to autumn snow.
selway-river-trail 4,5,6,9,10 Spring and fall medium A low river canyon at 2,000 to 3,000 feet is free of snow early but reaches the mid-80s with fire risk in July and August, so spring and early fall are used.
sentier-international-appalaches 6,7,8,9 June to September medium Gaspesie's Chic-Choc summits keep snow into June and the cold and snow return in October, so summer is the window.
shawangunk-ridge-trail 3,4,5,9,10,11 March to May and September to November medium A Hudson Valley ridge with humid, buggy summers and icy winters, so spring and fall are the most comfortable months.
sheltowee-trace 3,4,5,10,11 Spring and fall medium Kentucky's Daniel Boone National Forest is hot, humid and buggy in summer and cold in winter, so spring and fall are best.
shenipsit-trail 3,4,5,9,10,11 March to May and September to November medium Central Connecticut has humid, buggy summers and cold, icy winters, so spring and fall are best.
sierra-grand-traverse 7,8,9 July to September high Over 40 passes between 9,000 and 12,000 ft are snow-covered until July, and fall storms close the high country by October.
sierra-high-route 7,8,9 July to September high The pages differ: Backpacking Routes gives late July to mid-September, and Skurka warns the route is off-limits to all but expert mountaineers from November through May. It was set by judgement from both and from the climate at the passes, which are near 12,000 feet.
silver-moccasin-trail 4,5,6,10,11 April to June and October to November medium San Gabriel low canyons exceed 85 F in midsummer and Mount Baden-Powell is snowy in winter, so spring and autumn suit best.
siskiyou-peaks-trail 7,8,9 July to September medium The summits and cirque lakes are snowbound until late June, and Shasta is climbed in summer.
sky-islands-traverse 3,4,5,9,10,11 March to May and September to November low Summer heat and the July and August monsoon storms in southeastern Arizona push the walk into spring and fall.
solitude-loop 7,8,9 July to September high Cloud Peak Wilderness at 9,000 to 11,000 feet holds snow into early July, and winter storms return in late September.
south-boundary 7,8,9 July to September high Jasper's Cairn and Rocky passes near 6,000 ft and glacial river fords need snowmelt and low water, so early July to mid-September.
south-lake-to-north-lake 7,8,9 July to September high Bishop, Muir and Piute passes above 11,000 ft hold snow into early July and storms return in late September.
southeastern-serpentine-trail 3,4,5,10,11 Spring and fall medium A 30-35 day link of southern Appalachian trails is walked in spring and fall to dodge summer heat, humidity and bugs and winter ice on the higher sections.
southern-sierra-high-route 7,8,9 July to September high Cross-country passes above 12,000 ft near Whitney hold snow into July and storms return by late September.
southwestern-horseshoe 3,4,5,9,10,11 Spring and fall low Joining the Hayduke, Arizona and Grand Enchantment trails across Utah, Arizona and New Mexico desert means spring or fall to avoid summer heat and monsoon, with the highest ground snow-free by late spring.
standing-stone 4,5,6,9,10 April to June and September to October medium Humid, buggy summers and icy winters on the Pennsylvania ridges leave spring and fall as the usual window.
stein-valley-traverse 7,8,9 July to September medium The traverse tops out around 7,000 feet, where snow lingers into July, and heavy rain starts in October.
sunapee-ragged-kearsarge 6,7,8,9,10 June to October medium New Hampshire snow and mud last into spring and black flies into early June, with foliage-season walking into early October.
sunshine-coast 6,7,8,9 June to September medium The coast is drenched by 8-14 inches of rain a month from October to March and the mountaintop sections hold snow until June, so the dry summer months are the season.
superior-hiking 5,6,7,8,9,10 May to October medium Lake Superior's North Shore is snowy and cold from November to April and buggy in June and July, so May to October with September and October favoured.
susquehannock 5,6,7,8,9,10 May to October medium Northern Pennsylvania plateau stays snowy and wet through April, so late spring through early fall is the walking season.
sycamore-canyon-az 3,4,10,11 March to April and October to November medium Low canyon country at 3,800 ft tops 90 F from June to September, so the loop belongs in the cooler spring and fall months.
tahoe-rim 6,7,8,9,10 June to October medium The 10,000 ft ridgelines are snow-covered into June and again from late October, so thru-hikers walk from about late June to early October.
tahoe-yosemite-trail 7,8,9 July to September high High Sierra passes up to about 10,000 feet hold snow until early July, and fall storms arrive in October.
teton-crest 7,8,9 July to September high Crest passes above 10,000 feet hold snow until mid-July and storms and snow return by late September or October.
teton-crest-route 7,8,9 July to September high Crest passes up to 10,700 ft hold snow into July and are wintry again by October, so July to September.
teton-range-traverse 7,8,9 July to September high The Teton crest and Yellowstone Plateau are snow-covered until early July and wintry again by October, so July to September.
teton-wilderness-loop 7,8,9 July to September high Two Ocean Pass and the Yellowstone River fords need snowmelt runoff to drop, which comes in mid-July, and fall storms arrive in late September.
thames-valley-trail 5,6,7,8,9,10 May to October low Southwestern Ontario farmland trail is muddy and cold in early spring and snow-covered in winter, so it is walked from late spring to fall.
thorofare-and-south-boundary-trail 7,8,9 July to September high Remote Yellowstone backcountry with deep snow and high river fords until early July, and snow returns in October.
timberline 7,8,9 July to September high Mount Hood's snowfields and glacial stream crossings are at their best from mid-July through September before heavy autumn rain returns.
toiyabe-crest 7,8,9 July to September medium Nevada crest at 10,000 feet is snow-covered into late June and cold again by October, leaving the dry summer.
tonto-trail 1,2,3,4,11,12 November to April medium The Grand Canyon Tonto Platform is 90-100F from May to September with scarce water, so the cool months from November to April are the walking season.
trans-adirondack-route 6,7,8,9,10 June to October low Adirondack wilderness with deep snow and mud into May, black flies in May and June, and winter returning in November.
traversee-charlevoix 6,7,8,9,10 June to October medium The guided cabin crossing runs from after the Quebec thaw and black-fly peak through early October, avoiding the snowbound winter.
tuscarora 3,4,5,9,10,11 March to May and September to November medium The Ridge and Valley Appalachians are hot, humid and buggy in summer and icy in winter, so spring and fall are the comfortable months.
uinta-highline 7,8,9 July to September high Most of the trail is above 10,000 ft over 12,000 ft passes, so snow keeps it closed until early July and storms return by late September.
vagabond-loop 3,4,5,6,7,8,9,10 March to October low A 3,500-mile circuit of Arizona, Utah, Colorado and New Mexico must start in the desert in early spring and cross the high Colorado Trail country in summer, before fall snow.
vancouver-island 6,7,8,9 June to September medium Heavy Pacific rain from October to April and snow on the high alpine sections make early summer to September the window.
vancouver-island-backbone 7,8,9 July to September medium Alpine ridges in the island interior hold snow until July and wet autumn storms begin in October; the packet's low elevation looks like a location error.
warrior-trail 3,4,5,9,10,11 March to May and September to November medium Farmland ridges in southwestern Pennsylvania are overgrown, humid and buggy in summer and icy in winter.
wasatch-traverse 7,8,9 July to September low The high Wasatch ridges and off-trail sections hold snow until late June and get early autumn storms, so midsummer fits a whole traverse.
washington-coast-trail 5,6,7,8,9 May to September high Heavy rain from October to April and tide-dependent headlands make the drier months from May to September the usual window.
waskahegan 5,6,7,8,9,10 May to October low Edmonton-area farmland and parkland is snow-covered and muddy from November to April, and walked from late spring to early fall.
west-coast-trail 5,6,7,8,9 May to September high The trail is only open and reservable from May to September because of heavy autumn to spring rain and storms.
western-uplands 5,6,7,8,9,10 May to October medium The Algonquin backcountry is frozen and snowy into April, buggy in late spring and cold by late October.
wind-river-high-route-dixon-wilson 7,8,9 July to September medium Days above 10,000 ft on the Divide need the snow gone, which happens in mid-July, and storms return in September.
wind-river-high-route-skurka 7,8,9 July to September high A mostly off-trail route at 10,000-12,000 ft with snowfields and big stream fords needs melt-out, which comes in mid-July and ends with September storms.
wind-river-highline-trail 7,8,9 July to September high Bridger Wilderness benchlands and passes hold snow and high water into early July and winter returns by late September.
wonderland 7,8,9 July to September high Mount Rainier's high ground keeps snow into July and heavy autumn rain begins in October, so mid-July to September is the window.
wyoming-range 7,8,9 July to September high Crest-top trail at 9,000 ft or more is snowbound until early July and snows again by late September.
yosemite-high-route 7,8,9 July to September high Mostly off-trail at 8,000 to 11,000 feet, so snowmelt, high stream crossings and early snow limit it to July through September.
yosemite-high-sierra-camp-loop 7,8,9 July to September high Tuolumne's high passes and the camps are snow-bound until late June and shut for the season by early September, so July to September.
1 across-utah-route 4,5,6,9,10 April to June and September to October medium Desert heat in summer and snow in the Henrys, La Sals and Bryce country in winter leave spring and fall.
2 akshayuk-pass 7,8 July to August medium Arctic Baffin Island is frozen and snowbound until late June and freezes up again by September, so the walkable window is the two summer months.
3 alexander-mackenzie 6,7,8,9 June to September medium Snow lingers on the Interior Plateau and Tweedsmuir highlands into June and autumn rain and early snow return in October.
4 allegheny-trail 4,5,6,7,8,9,10 April to October medium Mid-elevation West Virginia mountains are mild and green from April to October, with winter snow and ice and summer humidity making the edges less pleasant.
5 alpine-trail-7 7,8,9 July to September high Heavy winter snow at 7,000 feet in the Swan Range melts out by mid-July, and snow returns in October.
6 american-discovery-trail 4,5,6,7,8,9,10 April to October low A coast-to-coast thru-hike starts in spring and must reach the Colorado and Sierra high ground in summer before autumn snow, so the whole route fits April to October.
7 appalachian 3,4,5,6,7,8,9,10 March to October high A northbound thru-hike starts in March-April in Georgia and reaches Katahdin by September-October before Maine's snow, so the season spans March to October.
8 appalachian-high-route 4,5,6,9,10 Spring and fall medium Mountain loop over 5,000-foot ridges in NC and TN where summer is hot and humid and winter is icy, so spring and fall are the comfortable windows.
9 arizona 3,4,5,9,10,11 Spring and fall medium Low desert is too hot in summer and the high forest and Grand Canyon rim hold snow in winter, so thru-hikers go north from March to May or flip into fall.
10 avon 4,5,6,7,8,9,10 April to October medium Winter snow and early-spring mud on Ontario farmland end with the thaw, and the walk runs until late fall.
11 backbone 1,2,3,4,5,10,11,12 October to May medium Santa Monica Mountains chaparral is baking hot and dry from June to September, so the cool wetter months and spring wildflowers are the walking season.
12 baker 4,5,6,9,10 April to June and September to October medium Humid, buggy summers and icy, muddy winters in western Pennsylvania make spring and fall the usual walking months.
13 bartram 3,4,5,9,10,11 Spring and fall medium Blue Ridge route with summer heat and haze below and winter ice on the 5,000-foot balds, so spring and fall are best.
14 basin-and-range-trail 4,5,9,10 Spring and fall high Nevada desert route with scorching summer heat and little water and snow on the high ranges in winter, so spring and fall are the windows.
15 batona 3,4,5,9,10,11 March to May and September to November medium Flat Pine Barrens walking is best when it is cool, away from summer heat, ticks and biting flies.
16 bay-circuit 3,4,5,9,10,11 March to May and September to November medium Humid, buggy summers and icy winters in low-lying eastern Massachusetts leave spring and fall, though it can be walked all year.
17 bayou-state-trail 1,2,3,4,11,12 November to April medium Summer heat, humidity, mosquitoes and storms in Louisiana push hiking into the cool, dry winter and early spring.
18 beartooth-high-route 7,8,9 July to September high Cross-country route at about 11,000 feet in the Beartooths where snow lingers into July and returns by late September, so only mid-summer works.
19 benton-mackaye 3,4,5,9,10,11 Spring and fall medium Southern Appalachian ridges up to 5800 ft are pleasant in spring and fall, while summer is hot, humid and buggy and winter brings ice.
20 big-bend-100 1,2,3,11,12 November to March high Chihuahuan Desert heat above 90F from May to September makes the cool months the only sensible window.
21 big-seki-loop 7,8,9 July to September high High Sierra passes up to 13,000 ft hold snow into early July and fresh snow returns by October, leaving July to September.
22 bigfoot-trail 7,8,9 July to September medium Klamath-Siskiyou high ground holds snow into June and gets heavy autumn rain from October, so the dry summer months fit.
23 bitterroots-80-mile-route 7,8,9 July to September medium High Selway-Bitterroot ground near 7,900 ft holds snow into early July and fall snow returns by October.
24 black-canyon 1,2,3,4,10,11,12 October to April high Sonoran Desert foothills are dangerously hot from May to September, so the cool months from October to April are the season.
25 blue-mountains-trail 5,6,9,10 May to June and September to October low Hot dry summers in the canyons and snow in the Wallowas and Blues outside late spring and early fall limit the window, though high sections are fine in midsummer.
26 border-route 5,6,7,8,9,10 Late May to October medium Northern Minnesota boundary-waters ridges are snow-bound and muddy until May and bugs peak in June and July, but the trail is walkable from May through fall.
27 boreal-trail 6,7,8,9 June to September medium Saskatchewan boreal forest has long cold winters and is frozen into May, leaving the short warm summer for hiking.
28 boundary-trail-mount-st-helens 7,8,9,10 July to October high Cascade ridges around 5,000 feet hold snow until July, and heavy rain starts in late October.
29 boundary-trail-pasayten 7,8,9 July to September high The Pasayten high country at 5,500 to 7,500 feet is under snow until early July, and snow returns in October.
30 brazeau-loop 7,8,9 July to September high Jasper's high passes and river fords need snowmelt to subside, so it is walkable from July until the first snow in September.
31 bristol-hills-trail 5,6,7,8,9,10 May to October medium Snow and mud make winter and early spring uncommon for walking, so the comfortable months run from late spring through fall.
32 brooks-range-traverse 6,7,8,9 June to September low Arctic tundra is frozen and snowbound most of the year, with river breakup in early June and freeze-up and snow by mid-September.
33 bruce-trail 4,5,6,7,8,9,10 April to October medium The Niagara Escarpment is icy and muddy through winter and early spring, so end-to-end hikes run from the April thaw to the end of October.
34 buckeye 3,4,5,9,10,11 Spring and fall medium Ohio summers are hot, humid and buggy and winters are cold and muddy, so spring and fall are the comfortable thru-hiking windows.
35 california-coastal 4,5,6,7,8,9,10 April to October low The coast can be walked all year, but winter storms bring heavy rain in the north and leave some sections passable only at low tide, so a full walk suits the dry months.
36 canol 7,8 July and August medium Mackenzie Mountains trail where snow lingers on the passes into late June and the first snow returns in early September, leaving July and August.
37 centennial-sd 5,6,9,10 May to June and September to October medium Black Hills summer heat and thunderstorms and winter snow leave late spring and early fall as the best months.
38 central-wilderness-grand-tour 6,7,8,9,10 June to October medium Mid-elevation Golden Trout Wilderness melts out early, but Coyote Lakes Pass and Kern crossings need low snow and low water, so summer through early fall.
39 central-wind-rivers-loop 7,8,9 July to September high Wind River Range snow and swollen creeks persist until mid-July and winter returns by late September.
40 chinese-wall-circuit 7,8,9 July to September high The Bob Marshall high country near 8,500 ft holds snow until July and gets fall snow by late September.
41 circle-of-solitude 7,8,9 July to September high High passes like Colby, Avalanche and Forester stay snowbound and high-water crossings last into July, with autumn storms after September.
42 cohos 6,7,8,9,10 June to October medium The pages differ: The Trek gives May to October and Backpacking Routes gives June to November. It was set by judgement from both and from the climate, since snow and mud last into late May and cold sets in by late October.
43 colorado-trail 7,8,9 July to September high San Juan and Collegiate high ground above 12,000 ft is snow-covered until early July and snows again by late September.
44 condor-trail 3,4,5,10,11 Spring and fall medium Los Padres coast ranges are very hot and dry from June to September and wet in midwinter, so spring and fall are the windows.
45 conestoga-trail 3,4,5,9,10,11 March to May and September to November medium The low Lancaster County hills are hot, humid and tick-ridden in summer, so the cool months suit it best.
46 conservation-trail 4,5,6,7,8,9,10 April to October medium Low-elevation western New York is snowy in winter and muddy in March, and can be walked from April until late fall.
47 continental-divide 5,6,7,8,9,10 May to October medium A thru-hike must start north of the Mexican border after the desert winter and clear the San Juans, Wyoming and Montana high ground between the June snowmelt and the first October storms.
48 corvallis-to-the-sea 5,6,7,8,9,10 May to October medium Very wet, muddy Coast Range winters push the walk into the drier months from late spring through early fall.
49 cottonwood-trail 6,7,8,9 June to September medium Yukon mountain passes are snow-covered until June and cold and snowy again by late September, leaving the short summer.
50 cranberry-lake-50 6,7,8,9,10 June to October medium Adirondack snow and mud in spring and black flies into June leave summer and fall as the usual window.
51 cross-vermont 5,6,7,8,9,10 May to October medium A low-elevation route of mostly rail trail and quiet roads, where winter snow and mud season bracket a long snow-free stretch from May to October.
52 dan-zhur-donjek 7,8 July to August medium Subarctic Kluane high country with glacial river crossings is snowbound until late June and snows again by early September.
53 deadman-and-cloud-canyons 7,8,9 July to September high High Sierra passes like Elizabeth Pass and Colby Pass hold snow and stream crossings run high until July, and autumn storms begin in October.
54 deadman-creek-loop 1,2,3,4,11,12 November to April medium Low Sonoran desert at about 2,200 ft reaches 90 to 100 F from May to September, so the walk belongs in the cool season.
55 deseret-hiking-route 5,6,7,8,9,10 May to October low A route from southern Utah desert canyons to the Pioneer Mountains of Idaho needs the high ground clear of snow and the south not scorching.
56 desert-trail 4,5,6,9,10 April to June and September to October low Waterless desert is too hot in summer and snowy in winter, so a full walk runs through spring and early fall.
57 desert-winter-thru-hike 1,2,3,11,12 November to March medium Designed as a winter route through Sonoran, Colorado and Mojave deserts that are too hot from April through October.
58 donut-hole 4,5,6,9,10 April to June and September to October low Unbridged streams run high in early spring, and the valleys are hot, humid and buggy in midsummer, so the shoulder months suit best.
59 eagle-cap-traverse 7,8,9 July to September high Wallowa high passes near 7,000 ft hold snow until early July and fall storms arrive in October.
60 east-beach-trail 5,6,7,8,9 May to September medium Haida Gwaii beach walking is best in the drier months, as heavy rain and storms dominate from October through winter.
61 east-coast-trail 6,7,8,9 June to September medium Newfoundland's cold, foggy shoulder seasons and lingering snow and ice leave summer into early fall as the comfortable window.
62 eastern-continental-trail 1,2,3,4,5,6,7,8,9,10 January to October low A thru-hike of about 300 days starts in the Florida winter and has to finish in the Gaspe before the November snows.
63 eastern-sierra-high-route 7,8,9 July to September high Cross-country passes above 10,500 feet need the snow to have melted, which is from mid-July through September.
64 finger-lakes 4,5,6,7,8,9,10 April to October medium The pages differ: one Trek page gives winter, spring, summer and fall, and a table on the same page gives spring, summer and fall. It was set by judgement from both and from the climate, since snow lies from December to March and early spring is muddy.
65 florida 1,2,3,11,12 November to March high Subtropical heat, wet-season flooding and bugs from May to October make the cool dry months the thru-hiking season.
66 foothills 3,4,5,9,10,11 Spring and fall medium Blue Ridge escarpment trail is comfortable in spring and fall, with hot humid summers and some winter ice at the higher end.
67 fremont 6,7,8,9,10 June to October medium Oregon ridge route at 6,000 to 8,000 feet is snow-covered into early June and snowy again by November, with dry summers.
68 ganaraska 4,5,6,7,8,9,10 April to October medium Southern Ontario is snowy in winter and muddy in March, and the trail can be walked from April until late fall.
69 general-george-crook 4,5,6,9,10 April to June and September to October medium Rim country is snowy in winter, and the July and August monsoon brings lightning and storms, leaving spring and fall.
70 georgia-loop 3,4,5,9,10,11 March to May and September to November medium The north Georgia mountains are hot, humid and stormy in summer and cold and icy on the ridges in winter.
71 gila-centennial-loop 3,4,5,9,10,11 March to May and September to November medium Gila canyons at 6,000 feet are hot from June to August, with monsoon storms and flash floods, and cold in winter.
72 gospel-hump-loop 7,8,9 July to September high Idaho subalpine ridges around 7,000 feet hold snow until late June and get snow again by October, so only summer into early fall works.
73 grand-enchantment 3,4,5,10,11 March to May, and October to November low The route crosses hot Sonoran desert and 10,000 ft Mogollon peaks, so a spring or fall thru-hike avoids summer heat at low ground and winter snow high up.
74 grand-moab-route 6,9,10 June and September to October low The route crosses 12,000-foot La Sal snow until June and desert canyons above 95F in July and August, which leaves early summer and fall.
75 grand-sawtooth-loop 7,8,9 July to September high Sawtooth passes and lake basins hold snow into early July and fall storms return in late September.
76 grand-teton-loop 7,8,9 July to September high Paintbrush Divide and Hurricane Pass hold snow into July and are snowy again by October, leaving July to September.
77 grand-valley-trail 4,5,6,7,8,9,10 April to October medium A low-elevation southern Ontario footpath that can be walked in all but deep winter and the muddy early spring.
78 great-basin-trail 4,5,6,9,10 April to June and September to October low Scarce water and 80 F summer heat in the valleys, plus winter snow on the ranges, favour spring and early fall.
79 great-colorado-route 6,7,8,9 June to September medium A route linking fourteeners and passes above 12,000 ft needs the snow gone, so it runs from early summer into early fall.
80 great-divide-trail 7,8,9 July to September high Alberta and BC Rockies passes stay snow-covered until early July and fresh snow returns in September, so thru-hikers walk July to mid-September.
81 great-eastern 4,5,6,7,8,9,10 April to October low A very long Appalachian walk, started in spring in Alabama and carried through summer humidity and into fall to avoid winter in the north.
82 great-plains-trail 5,6,7,8,9,10 May to October low A north-to-south prairie route from Saskatchewan to Texas is walked from late spring to fall, avoiding cold northern winters and heat in the south by timing.
83 great-western-divide-loop 7,8,9 July to September medium Kaweah Gap and the Great Western Divide hold deep snow into early July, and autumn storms return by October.
84 great-western-loop 4,5,6,7,8,9,10 April to October low A roughly 208-day circuit of western trails starts in spring from the Arizona desert and must clear the Sierra, Rockies and Cascades in summer before fall snow.
85 green-river-lakes-titcomb-basin-loop 7,8,9 July to September high The northern Wind Rivers hold snow and high water into mid-July and get fall storms by late September.
86 guadalupe-ridge-trail 3,4,10,11 Spring and fall medium Chihuahuan Desert lowlands are very hot from May to September and the ridge gets cold and windy in winter, so spring and fall are best.
87 hayduke-trail 4,5,9,10 April to May and September to October medium Canyon country is too hot in summer and the Henry Mountains and Boulder snow in winter, so thru-hikers start in spring or fall.
88 heart-lake-two-ocean-plateau-loop 7,8,9 July to September high Yellowstone's high backcountry has deep snow and high water into late June and returns to winter by October, so July to September is the window.
89 high-country-pathway 5,6,7,8,9,10 May to October medium Northern Michigan forest is snowbound in winter and muddy in early spring, and walkable from May to October, with bugs the main summer complaint.
90 high-sierra 7,8,9 July to September high Kaweah Gap and Whitney's high ground hold snow and run high streams until July, and autumn storms start in October.
91 highlands 3,4,5,9,10,11 March to May and September to November medium The low New Jersey and New York Highlands ridges are hot, humid and buggy in summer and icy in midwinter.
92 highline 4,5,6,9,10 April to June, and September to October medium Mogollon Rim at 6,000 ft is warm and dry in spring and fall, with summer monsoon storms in July and August and snow in winter.
93 hoosier-heritage-trail 3,4,5,9,10,11 March to May and September to November medium Indiana has hot, humid summers with ticks and thick vegetation, so spring and fall are the most comfortable months.
94 horse-shoe 3,4,5,9,10,11 March to May and September to November medium Southeast Pennsylvania has humid, buggy summers and icy winters, which leaves spring and fall.
95 hot-springs-trail 4,5,6,7,8,9 April to September low A northbound route of about 110 days from coastal California to Idaho needs the Sierra and the northern mountains clear of snow, so it runs from spring to early fall.
96 iat-newfoundland-labrador 6,7,8,9 June to September medium Western Newfoundland is cold, snowy and boggy until June, and storms and snow return in October.
97 ice-age 5,6,7,8,9,10 May to October medium The pages differ: one Trek page gives summer and fall and another gives summer only. It was set by judgement from both and from the climate, since snow and mud last through April and a hard freeze comes by November.
98 idaho-centennial 6,7,8,9 June to September medium Snow on the mountain sections lasts into June while the southern desert gets hot, so a north-bound walk runs June through September.
99 international-appalachian-trail-maine 6,7,8,9,10 June to October medium Northern Maine is snowbound and muddy until late May and frozen from November, and fall is best once the bugs fade.
100 island-walk 6,7,8,9,10 June to October medium Prince Edward Island is cold and wet in spring and late fall, so the walk is done in the warm months.
101 itijjagiaq-trail 7,8 July to August medium Baffin Island's Katannilik park is frozen and used by skiers and snowmobilers until June, so summer hiking is limited to July and August before September freeze.
102 john-muir 7,8,9 July to September high High Sierra passes above 11,000 ft are snow-choked until early July and storms and cold return in late September, so thru-hikes run July to September.
103 kanab-canyon-loop 3,4,5,10,11 Spring and fall high Grand Canyon inner gorge is dangerously hot from June to September with monsoon storms, so spring and fall are the standard seasons.
104 kings-canyon-high-basin-route 7,8,9 July to September high Off-trail travel over 12,000 ft passes needs the snow gone and stable weather, which only holds from July to September.
105 knobstone 3,4,5,9,10,11 March to May and September to November medium Southern Indiana summers are hot, humid and tick-ridden, while the steep, leafless bluffs in the cool shoulder seasons are the draw.
106 koroc-palmer-loop 7,8 July to August medium The Torngat Mountains in the Arctic are snowbound until late June and freeze again by September, leaving a short July and August window.
107 la-cloche 6,7,8,9,10 June to October medium Killarney is snowbound in winter and buggy in spring, so the warm months are the main window, with September and early October the best.
108 laurel-highlands 4,5,6,7,8,9,10 April to October medium Moderate Pennsylvania ridge at about 2,500 feet is snowy in midwinter but mild enough from April to October.
109 lone-star 1,2,3,11,12 November to March high East Texas piney woods are hot, humid and buggy for much of the year, so the cool winter months are the hiking season.
110 long-path 4,5,6,9,10 April to June and September to October medium Humid, buggy summers and icy winters in the Hudson Valley and Catskills favour spring and fall.
111 long-trail 6,7,8,9,10 June to October high Green Mountain ridges are muddy and snowy until late May and wintry by November, so thru-hikers walk June to October.
112 lost-coast 5,6,7,8,9 May to September high Heavy winter rain, slides and high tides make parts of the coast impassable, so the dry months with workable low tides are used.
113 lowest-to-highest-route 5,6,10 Late May to June, or October low Badwater is lethal in summer heat while Whitney holds snow until June, so the route fits a narrow window in late spring or early fall.
114 loyalsock 4,5,6,9,10 April to June and September to October medium Rocky, wet terrain in northern Pennsylvania is best in the cool shoulder seasons, before the humid, buggy summer.
115 maah-daah-hey 5,6,9,10 May to June and September to October medium Badlands clay turns to impassable gumbo when wet and summer is hot, so late spring and early fall are the usual months.
116 maricopa-trail 1,2,3,4,10,11,12 October to April high Phoenix-area Sonoran Desert is above 95F from May to September, so the cool months from October to April are the season.
117 mason-dixon 3,4,5,9,10,11 March to May and September to November medium The low Susquehanna valley is hot and humid in summer, so the cool spring and fall months suit best.
118 massanutten 3,4,5,9,10,11 Spring and fall medium Virginia ridge circuit with hot humid summers and cold winters, so spring and fall are most comfortable.
119 mattabesett 3,4,5,9,10,11 Spring and fall medium Low Connecticut traprock ridges are best in spring and fall, with summer humidity, heat and ticks and some winter ice on ledges.
120 metacomet-monadnock 4,5,6,9,10 Spring and early summer, and fall low New England ridge walking is cold and icy in winter and humid and buggy in midsummer, so spring and fall are favoured.
121 mid-state 4,5,6,7,8,9,10 April to October medium Pennsylvania ridge and plateau trail at about 2,000 feet is snowy in winter but fine from April to October, with summer humidity and ticks.
122 middle-fork-kings-river 7,8,9 July to September high Muir Pass and Hell-for-Sure Pass hold snow into early July and storms return in autumn, so July to September.
123 middle-fork-trail 6,7,8,9,10 June to October low Idaho river canyon and high bench trail clears of snow in June and gets cold wet weather by November, though low canyon heat peaks in July.
124 midland-to-mackinac-trail 6,7,8,9,10 June to October medium Snow and mud last into April in northern Michigan, and the walk is comfortable from June through early fall.
125 midstate-ma 4,5,6,9,10,11 April to June and September to November medium The gentle central Massachusetts hills are pleasant in spring and fall, with humid, buggy summers and cold, icy winters.
126 milestone-basin-and-the-upper-kern 7,8,9 July to September high Sierra passes above 10,000 ft and Kern fords stay snowy and high into early July, with autumn storms returning in October.
127 mogollon-rim-trail 4,5,9,10 April to May and September to October low Low desert sections reach 90 F by June and the White Mountains and Blue Range hold snow in winter, so spring and fall fit a full crossing.
128 mojave-sonoran-trail 1,2,3,11,12 November to March high Colorado River desert lowlands reach 100F from May to September, so the cool winter months are the only practical window.
129 monadnock-sunapee 6,7,8,9,10 June to October medium New Hampshire snow, mud and black flies linger into early June and the summit ridges are snowy from late fall.
130 montana-trail 6,7,8,9 June to September low A 90-to-122-day crossing from the Divide to the plains starts after mountain snow clears in June and aims to finish before winter on the Missouri breaks.
131 mountains-to-sea 3,4,5,9,10,11 March to May and September to November medium High Smokies and Blue Ridge are cold in winter while the Piedmont and coast are hot and humid in summer, so cool shoulder seasons suit a full walk.
132 nankoweap-bright-angel-loop 5,9,10 May and September to October low The Grand Canyon inner canyon is dangerously hot from June to August and the North Rim road is snowed in over winter, leaving late spring and early fall.
133 nepisiguit-migmaq-trail 6,7,8,9 June to September medium Northern New Brunswick is snowy and muddy through May and cold by October, with river and bug conditions favouring summer.
134 new-england 4,5,6,9,10 April to June and September to October medium Traprock ridges are cold and icy in winter and hot, humid and buggy in July and August, so spring and fall suit best.
135 north-boundary 7,8,9 July to September medium Snake Indian Pass and the Smoky River crossings need snowmelt in the Jasper backcountry, and winter returns by October.
136 north-country 5,6,7,8,9,10 May to October low A thru-hike across the northern states starts after the North Dakota spring thaw and must finish before winter sets in the Adirondacks and Vermont by late October.
137 north-south 3,4,5,9,10,11 March to May and September to November medium Rhode Island woods are humid and buggy in summer and cold in winter.
138 north-south-lbl 3,4,5,9,10,11 March to May and September to November medium The forests of western Kentucky and Tennessee are hot, humid and tick-ridden in summer, so spring and fall are favoured.
139 north-umpqua 6,7,8,9,10 June to October medium The upper Cascade sections near 6,000 feet hold snow into June and see heavy rain and snow from late October, though the river canyon can be walked earlier.
140 northern-colorado-trail 7,8,9 July to September medium Flat Tops and Rocky Mountain high ground above 11,000 ft is snowbound until early July and snows again by late September.
141 northern-new-mexico-loop 6,7,8,9,10 June to October low The Sangre de Cristo and Jemez high ground holds snow into June, and lower desert stretches are hot in midsummer, so a whole loop fits June to October.
142 northville-placid 6,7,8,9,10 June to October medium Adirondack wilderness trail is wet, snowy and muddy until late May, with black flies in May and June and cold weather by late October.
143 oak-ridges 4,5,6,7,8,9,10 April to October medium The southern Ontario moraine is snowy and muddy over winter and can be walked from April until late fall.
144 ocean-to-lake 1,2,3,11,12 November to March high South Florida is hot, wet and buggy from May to October with flooded swamp and prairie, so the cooler dry months are used.
145 oregon-coast 5,6,7,8,9 May to September medium The coast gets 10-16 inches of rain a month from November to March and the drier months from May to September make beach walking and creek crossings workable.
146 oregon-desert 4,5,6,9,10 Spring and fall medium High desert at 3,000-8,000 ft is hot and waterless in July and August and cold in winter, so spring and fall are the walking windows.
147 ottawa-temiskaming-highland-trail 6,7,8,9,10 June to October medium Northeastern Ontario forest is snowbound and muddy until May, with black flies in early summer, and cold by November.
148 ouachita 3,4,5,10,11 October to November and March to May medium The pages differ: one gives April to November, one gives late October to late March, and one gives all year. It was set by judgement from all three and from the climate, since summers are hot and humid with ticks and winters are cold but walkable.
149 ozark-highlands 3,4,5,10,11 Spring and fall medium Arkansas Ozark summers are hot, humid and buggy and winters are cold but popular for leaf-off views, so spring and fall are the typical seasons.
150 ozark-trail 3,4,5,9,10,11 March to May and September to November medium The pages differ: one Trek page gives spring or fall and another adds winter. It was set by judgement from both and from the climate, since the heat, humidity and ticks of July and August make summer a poor choice.
151 pacific-crest 4,5,6,7,8,9,10 April to October medium A thru-hike starts at the desert border in April or May, crosses the Sierra after the June to July snowmelt, and must finish the Washington Cascades by early October.
152 pacific-northwest 7,8,9 July to September medium An east-to-west thru-hike starts in Glacier after the snow clears in early July and must finish through the wet Olympic coast before October rain and early snow.
153 paumanok-path 3,4,5,9,10,11 March to May and September to November medium Long Island is humid and tick-heavy in summer, and the pine barrens are pleasant in the cool shoulder seasons.
154 pfiffner-traverse 7,8,9 July to September high A Continental Divide crest route above 11,000 feet with off-trail passes needs the snow gone, which is from July until the first big September storms.
155 pinhoti 3,4,5,10,11 Spring and fall medium Alabama and Georgia hills are hot and humid from June to September, and winter is wet and cold, so spring and fall are best.
156 powell-plateau-loop 5,9,10 May and September to October low The Grand Canyon's North Rim access is snowed in until May and the inner canyon is very hot in June to August, leaving late spring and early fall.
157 prescott-circle 3,4,5,9,10,11 March to May and September to November medium Prescott's high desert is hot in June to August with monsoon storms in July and August, while winters are cool but usually walkable, so shoulder seasons are best.
158 ptarmigan-glenns-lake-highline-loop 7,8,9 July to September high Glacier's Ptarmigan Tunnel, Stoney Indian Pass and Highline are snow-blocked until mid-July and the first snows come in late September.
159 quehanna 4,5,6,7,8,9,10 April to October medium Pennsylvania state forest trail at about 2,000 ft is walkable from April to October, with winter snow and March mud outside the season.
160 rae-lakes-loop 7,8,9 July to September high Glen Pass at 11,978 ft keeps snow into early July and the Kings River crossings run high, with autumn storms after September.
161 rideau-trail 4,5,6,7,8,9,10 April to October medium Eastern Ontario is snowy and muddy over winter, and the trail can be walked from April until late fall.
162 ring-the-peak 6,7,8,9,10 June to October low A loop around Pikes Peak that mixes stretches near 11,000 feet with lower trails, and is snow-free from about June to October.
163 river-to-river 3,4,5,10,11 Spring and fall medium Southern Illinois summers are hot, humid and buggy, with trailside poison ivy and ticks, so spring and fall are the comfortable seasons.
164 route-in-between 4,5,6,7,8,9,10 April to October low A Mexico-to-Canada link route through Arizona desert, Utah canyons and Idaho mountains has to chain a spring start with high Idaho snow clearing by summer and finishing before fall.
165 rutherford-lake-loop 7,8,9 July to September high Yosemite's south boundary passes at over 9,000 feet hold snow until early July, and autumn storms begin in October.
166 san-diego-trans-county-trail 1,2,3,4,11,12 November to April medium The Salton Sea end and the desert washes are over 100F in summer, so the cool months are used, with the 4,900-foot mountains still mild in winter.
167 santa-fe-to-taos 7,8,9 July to September medium Sangre de Cristo peaks near 12,000 ft are snowbound until late June and afternoon monsoon storms peak in July and August.
168 sawtooth-wilderness-high-route 7,8,9 July to September high Mostly cross-country passes near 9,000 feet and above need the snow gone, which is from mid-July through September.
169 sea-to-sea-route 4,5,6,7,8,9,10 April to October low A 7,775-mile coast-to-coast network across the northern prairie, the Rockies and the Cascades can only be walked from spring thaw to autumn snow.
170 selway-river-trail 4,5,6,9,10 Spring and fall medium A low river canyon at 2,000 to 3,000 feet is free of snow early but reaches the mid-80s with fire risk in July and August, so spring and early fall are used.
171 sentier-international-appalaches 6,7,8,9 June to September medium Gaspesie's Chic-Choc summits keep snow into June and the cold and snow return in October, so summer is the window.
172 shawangunk-ridge-trail 3,4,5,9,10,11 March to May and September to November medium A Hudson Valley ridge with humid, buggy summers and icy winters, so spring and fall are the most comfortable months.
173 sheltowee-trace 3,4,5,10,11 Spring and fall medium Kentucky's Daniel Boone National Forest is hot, humid and buggy in summer and cold in winter, so spring and fall are best.
174 shenipsit-trail 3,4,5,9,10,11 March to May and September to November medium Central Connecticut has humid, buggy summers and cold, icy winters, so spring and fall are best.
175 sierra-grand-traverse 7,8,9 July to September high Over 40 passes between 9,000 and 12,000 ft are snow-covered until July, and fall storms close the high country by October.
176 sierra-high-route 7,8,9 July to September high The pages differ: Backpacking Routes gives late July to mid-September, and Skurka warns the route is off-limits to all but expert mountaineers from November through May. It was set by judgement from both and from the climate at the passes, which are near 12,000 feet.
177 silver-moccasin-trail 4,5,6,10,11 April to June and October to November medium San Gabriel low canyons exceed 85 F in midsummer and Mount Baden-Powell is snowy in winter, so spring and autumn suit best.
178 siskiyou-peaks-trail 7,8,9 July to September medium The summits and cirque lakes are snowbound until late June, and Shasta is climbed in summer.
179 sky-islands-traverse 3,4,5,9,10,11 March to May and September to November low Summer heat and the July and August monsoon storms in southeastern Arizona push the walk into spring and fall.
180 solitude-loop 7,8,9 July to September high Cloud Peak Wilderness at 9,000 to 11,000 feet holds snow into early July, and winter storms return in late September.
181 south-boundary 7,8,9 July to September high Jasper's Cairn and Rocky passes near 6,000 ft and glacial river fords need snowmelt and low water, so early July to mid-September.
182 south-lake-to-north-lake 7,8,9 July to September high Bishop, Muir and Piute passes above 11,000 ft hold snow into early July and storms return in late September.
183 southeastern-serpentine-trail 3,4,5,10,11 Spring and fall medium A 30-35 day link of southern Appalachian trails is walked in spring and fall to dodge summer heat, humidity and bugs and winter ice on the higher sections.
184 southern-sierra-high-route 7,8,9 July to September high Cross-country passes above 12,000 ft near Whitney hold snow into July and storms return by late September.
185 southwestern-horseshoe 3,4,5,9,10,11 Spring and fall low Joining the Hayduke, Arizona and Grand Enchantment trails across Utah, Arizona and New Mexico desert means spring or fall to avoid summer heat and monsoon, with the highest ground snow-free by late spring.
186 standing-stone 4,5,6,9,10 April to June and September to October medium Humid, buggy summers and icy winters on the Pennsylvania ridges leave spring and fall as the usual window.
187 stein-valley-traverse 7,8,9 July to September medium The traverse tops out around 7,000 feet, where snow lingers into July, and heavy rain starts in October.
188 sunapee-ragged-kearsarge 6,7,8,9,10 June to October medium New Hampshire snow and mud last into spring and black flies into early June, with foliage-season walking into early October.
189 sunshine-coast 6,7,8,9 June to September medium The coast is drenched by 8-14 inches of rain a month from October to March and the mountaintop sections hold snow until June, so the dry summer months are the season.
190 superior-hiking 5,6,7,8,9,10 May to October medium Lake Superior's North Shore is snowy and cold from November to April and buggy in June and July, so May to October with September and October favoured.
191 susquehannock 5,6,7,8,9,10 May to October medium Northern Pennsylvania plateau stays snowy and wet through April, so late spring through early fall is the walking season.
192 sycamore-canyon-az 3,4,10,11 March to April and October to November medium Low canyon country at 3,800 ft tops 90 F from June to September, so the loop belongs in the cooler spring and fall months.
193 tahoe-rim 6,7,8,9,10 June to October medium The 10,000 ft ridgelines are snow-covered into June and again from late October, so thru-hikers walk from about late June to early October.
194 tahoe-yosemite-trail 7,8,9 July to September high High Sierra passes up to about 10,000 feet hold snow until early July, and fall storms arrive in October.
195 teton-crest 7,8,9 July to September high Crest passes above 10,000 feet hold snow until mid-July and storms and snow return by late September or October.
196 teton-crest-route 7,8,9 July to September high Crest passes up to 10,700 ft hold snow into July and are wintry again by October, so July to September.
197 teton-range-traverse 7,8,9 July to September high The Teton crest and Yellowstone Plateau are snow-covered until early July and wintry again by October, so July to September.
198 teton-wilderness-loop 7,8,9 July to September high Two Ocean Pass and the Yellowstone River fords need snowmelt runoff to drop, which comes in mid-July, and fall storms arrive in late September.
199 thames-valley-trail 5,6,7,8,9,10 May to October low Southwestern Ontario farmland trail is muddy and cold in early spring and snow-covered in winter, so it is walked from late spring to fall.
200 thorofare-and-south-boundary-trail 7,8,9 July to September high Remote Yellowstone backcountry with deep snow and high river fords until early July, and snow returns in October.
201 timberline 7,8,9 July to September high Mount Hood's snowfields and glacial stream crossings are at their best from mid-July through September before heavy autumn rain returns.
202 toiyabe-crest 7,8,9 July to September medium Nevada crest at 10,000 feet is snow-covered into late June and cold again by October, leaving the dry summer.
203 tonto-trail 1,2,3,4,11,12 November to April medium The Grand Canyon Tonto Platform is 90-100F from May to September with scarce water, so the cool months from November to April are the walking season.
204 trans-adirondack-route 6,7,8,9,10 June to October low Adirondack wilderness with deep snow and mud into May, black flies in May and June, and winter returning in November.
205 traversee-charlevoix 6,7,8,9,10 June to October medium The guided cabin crossing runs from after the Quebec thaw and black-fly peak through early October, avoiding the snowbound winter.
206 tuscarora 3,4,5,9,10,11 March to May and September to November medium The Ridge and Valley Appalachians are hot, humid and buggy in summer and icy in winter, so spring and fall are the comfortable months.
207 uinta-highline 7,8,9 July to September high Most of the trail is above 10,000 ft over 12,000 ft passes, so snow keeps it closed until early July and storms return by late September.
208 vagabond-loop 3,4,5,6,7,8,9,10 March to October low A 3,500-mile circuit of Arizona, Utah, Colorado and New Mexico must start in the desert in early spring and cross the high Colorado Trail country in summer, before fall snow.
209 vancouver-island 6,7,8,9 June to September medium Heavy Pacific rain from October to April and snow on the high alpine sections make early summer to September the window.
210 vancouver-island-backbone 7,8,9 July to September medium Alpine ridges in the island interior hold snow until July and wet autumn storms begin in October; the packet's low elevation looks like a location error.
211 warrior-trail 3,4,5,9,10,11 March to May and September to November medium Farmland ridges in southwestern Pennsylvania are overgrown, humid and buggy in summer and icy in winter.
212 wasatch-traverse 7,8,9 July to September low The high Wasatch ridges and off-trail sections hold snow until late June and get early autumn storms, so midsummer fits a whole traverse.
213 washington-coast-trail 5,6,7,8,9 May to September high Heavy rain from October to April and tide-dependent headlands make the drier months from May to September the usual window.
214 waskahegan 5,6,7,8,9,10 May to October low Edmonton-area farmland and parkland is snow-covered and muddy from November to April, and walked from late spring to early fall.
215 west-coast-trail 5,6,7,8,9 May to September high The trail is only open and reservable from May to September because of heavy autumn to spring rain and storms.
216 western-uplands 5,6,7,8,9,10 May to October medium The Algonquin backcountry is frozen and snowy into April, buggy in late spring and cold by late October.
217 wind-river-high-route-dixon-wilson 7,8,9 July to September medium Days above 10,000 ft on the Divide need the snow gone, which happens in mid-July, and storms return in September.
218 wind-river-high-route-skurka 7,8,9 July to September high A mostly off-trail route at 10,000-12,000 ft with snowfields and big stream fords needs melt-out, which comes in mid-July and ends with September storms.
219 wind-river-highline-trail 7,8,9 July to September high Bridger Wilderness benchlands and passes hold snow and high water into early July and winter returns by late September.
220 wonderland 7,8,9 July to September high Mount Rainier's high ground keeps snow into July and heavy autumn rain begins in October, so mid-July to September is the window.
221 wyoming-range 7,8,9 July to September high Crest-top trail at 9,000 ft or more is snowbound until early July and snows again by late September.
222 yosemite-high-route 7,8,9 July to September high Mostly off-trail at 8,000 to 11,000 feet, so snowmelt, high stream crossings and early snow limit it to July through September.
223 yosemite-high-sierra-camp-loop 7,8,9 July to September high Tuolumne's high passes and the camps are snow-bound until late June and shut for the season by early September, so July to September.
+98
View File
@@ -0,0 +1,98 @@
{
"sierra-high-route": {
"why": "The pages differ: Backpacking Routes gives late July to mid-September, and Skurka warns the route is off-limits to all but expert mountaineers from November through May. It was set by judgement from both and from the climate at the passes, which are near 12,000 feet.",
"months_text": "The Skurka page says the route is probably off-limits to all but the most experienced mountaineers from November through May and lists hazards by month; Backpacking Routes gives late July to mid-September",
"sources": [
{
"url": "https://andrewskurka.com/adventures/sierra-high-route/logistical-considerations/",
"publisher": "Andrew Skurka",
"quote": "For all but the most experienced mountaineers, the SHR is probably off-limits from November through May"
},
{
"url": "https://backpackingroutes.com/sierra-high-route/",
"publisher": "Backpacking Routes",
"quote": "The best time to hike the Sierra High Route is late July to mid-September."
}
]
},
"cohos": {
"why": "The pages differ: The Trek gives May to October and Backpacking Routes gives June to November. It was set by judgement from both and from the climate, since snow and mud last into late May and cold sets in by late October.",
"months_text": "The Trek 5-10; Backpacking Routes 6-11",
"sources": [
{
"url": "https://thetrek.co/10-trails-can-find-long-distance-solitude-2020/",
"publisher": "The Trek",
"quote": "Thru-hiking season : May to October"
},
{
"url": "https://backpackingroutes.com/cohos-trail/",
"publisher": "Backpacking Routes",
"quote": "Season : Summer , Fall"
}
]
},
"ouachita": {
"why": "The pages differ: one gives April to November, one gives late October to late March, and one gives all year. It was set by judgement from all three and from the climate, since summers are hot and humid with ticks and winters are cold but walkable.",
"months_text": "The Hiking Life 4-11; Backpacking Routes 10-3; The Trek 1-12",
"sources": [
{
"url": "https://thehikinglife.com/2014/07/ouachita-trail/",
"publisher": "The Hiking Life",
"quote": "Season : April to November."
},
{
"url": "https://backpackingroutes.com/ouachita-trail/",
"publisher": "Backpacking Routes",
"quote": "Late October through late March is very possible, with the bulk of the hikers hitting it in November."
},
{
"url": "https://thetrek.co/10-trails-can-find-long-distance-solitude-2020/",
"publisher": "The Trek",
"quote": "Thru-hiking season: Year-round"
}
]
},
"ice-age": {
"why": "The pages differ: one Trek page gives summer and fall and another gives summer only. It was set by judgement from both and from the climate, since snow and mud last through April and a hard freeze comes by November.",
"months_text": "The Trek list 6-11; The Trek article 6-8",
"sources": [
{
"url": "https://thetrek.co/a-list-of-long-distance-trails-in-the-us/",
"publisher": "The Trek",
"quote": "Hiking season: Summer, Fall"
},
{
"url": "https://thetrek.co/the-best-time-of-year-to-hike-these-23-popular-long-trails/",
"publisher": "The Trek",
"quote": "The Ice Age Trail Best Time: Summer"
}
]
},
"ozark-trail": {
"why": "The pages differ: one Trek page gives spring or fall and another adds winter. It was set by judgement from both and from the climate, since the heat, humidity and ticks of July and August make summer a poor choice.",
"months_text": "The Trek article 3-5 and 9-11; The Trek list 12-5 and 9-11",
"sources": [
{
"url": "https://thetrek.co/the-best-time-of-year-to-hike-these-23-popular-long-trails/",
"publisher": "The Trek",
"quote": "Best Time: Spring or Fall"
},
{
"url": "https://thetrek.co/a-list-of-long-distance-trails-in-the-us/",
"publisher": "The Trek",
"quote": "Hiking season: Winter, Spring, Fall"
}
]
},
"finger-lakes": {
"why": "The pages differ: one Trek page gives winter, spring, summer and fall, and a table on the same page gives spring, summer and fall. It was set by judgement from both and from the climate, since snow lies from December to March and early spring is muddy.",
"months_text": "The Trek trail entry 1-12; The Trek table 3-11",
"sources": [
{
"url": "https://thetrek.co/a-list-of-long-distance-trails-in-the-us/",
"publisher": "The Trek",
"quote": "Hiking season: Winter, Spring, Summer, Fall"
}
]
}
}
+88 -36
View File
@@ -384,35 +384,88 @@ class ProposeCheckTest(unittest.TestCase):
("aaa", "Aaa", {"extra_hike": months_extra + self.ENDS}),
])
EST = ('season = "All year"\n'
'months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n'
'season_basis = "estimate"\n'
'season_method = "Judged from climate. Confidence: low."\n')
def blind_doc(self, root, share=0.77, tested=100):
matched = int(round(share * tested))
doc = {"date": "2026-11-20", "tested": tested, "matched": matched,
"share": round(matched / tested, 2),
"by_confidence": {
"high": {"tested": tested, "matched": matched,
"share": round(matched / tested, 2)},
"medium": {"tested": 0, "matched": 0, "share": 0.0},
"low": {"tested": 0, "matched": 0, "share": 0.0}}}
with open(os.path.join(root, "tools", "season_blind_test.json"), "w") as f:
json.dump(doc, f)
def record_inputs(self, root, tid="aaa", **change):
params = E.load_params(root)
rec = E.refresh.load_toml(os.path.join(root, tid, "trail.toml"))
sig = E.inputs_signature(E.estimate(root, dict(rec, id=tid), params, mild_fetch,
E.references(root, mild_fetch)))
sig.update(change)
with open(os.path.join(root, "tools", "season_inputs.json"), "w") as f:
json.dump({tid: sig}, f)
def checked_repo(self, tmp, **kw):
root = self.est_repo(tmp, self.EST)
self.fit_doc(root)
self.blind_doc(root, **kw)
return root
def test_check_passes_when_nothing_changed(self):
import tempfile, shutil
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.est_repo(
tmp,
'season = "All year"\n'
'months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]\n'
'season_basis = "estimate"\nseason_method = "Estimated."\n')
self.fit_doc(root)
root = self.checked_repo(tmp)
E._REFS.clear()
self.record_inputs(root)
ok, lines = E.check(root, mild_fetch)
self.assertTrue(ok, lines)
def test_check_names_the_trail_whose_estimate_changed(self):
import tempfile, shutil
def test_check_flags_an_estimate_whose_machine_estimate_changed(self):
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.est_repo(
tmp,
'season = "June to July"\nmonths = [6, 7]\n'
'season_basis = "estimate"\nseason_method = "Estimated."\n')
self.fit_doc(root)
root = self.checked_repo(tmp)
E._REFS.clear()
self.record_inputs(root, machine=[6, 7])
ok, lines = E.check(root, mild_fetch)
self.assertFalse(ok)
self.assertTrue(any("aaa" in line and "[6, 7]" in line
self.assertTrue(any("aaa" in line and "inputs changed" in line and "[6, 7]" in line
for line in lines), lines)
def test_check_flags_an_estimate_whose_climate_digest_changed(self):
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.checked_repo(tmp)
E._REFS.clear()
self.record_inputs(root, digest="0" * 16)
ok, lines = E.check(root, mild_fetch)
self.assertFalse(ok)
self.assertTrue(any("aaa" in line and "inputs changed" in line for line in lines), lines)
def test_check_flags_an_estimate_with_no_recorded_inputs(self):
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.checked_repo(tmp)
E._REFS.clear()
ok, lines = E.check(root, mild_fetch)
self.assertFalse(ok)
self.assertTrue(any("aaa" in line and "no inputs are recorded" in line for line in lines), lines)
def test_check_fails_when_the_blind_test_is_under_the_bar(self):
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.checked_repo(tmp, share=0.6)
E._REFS.clear()
self.record_inputs(root)
ok, lines = E.check(root, mild_fetch)
self.assertFalse(ok)
self.assertTrue(any("blind test" in line for line in lines), lines)
def test_check_fails_when_the_fit_got_worse(self):
import tempfile, shutil
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
# one sourced trail that mild all-year normals cannot match
@@ -420,32 +473,31 @@ class ProposeCheckTest(unittest.TestCase):
'season_basis = "source"\n' + self.ENDS)
root = self.repo_with(tmp, [("only", "Only", {"extra_hike": extra})])
self.fit_doc(root, within1=4, n=4)
self.blind_doc(root)
E._REFS.clear()
ok, lines = E.check(root, mild_fetch)
self.assertFalse(ok)
self.assertTrue(any("fit got worse" in line for line in lines), lines)
def test_proposals_collect_cleanly(self):
import tempfile, shutil, csv
def test_the_estimates_command_lists_only_estimates(self):
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.repo_with(tmp, [("aaa", "Aaa", {"extra_hike": self.ENDS})])
stage = os.path.join(tmp, "stage")
os.makedirs(os.path.join(stage, "season"))
reviewed = os.path.join(stage, "season", "estimates.reviewed.csv")
with open(reviewed, "w", newline="") as f:
w = csv.writer(f)
w.writerow(["id", "proposed_months", "phrase", "kind", "flags",
"comparable", "comparable_phrase", "note"])
w.writerow(["aaa", "6 7 8 9", "June to September", "ends",
"no-track", "", "", ""])
self.assertEqual(E.proposals(root, reviewed, stage), 1)
code, out = TR.main(root, "--dir", stage, "collect")
self.assertEqual(code, 0, out)
import refresh as R
coll = R.load_toml(os.path.join(stage, "collected.toml"))
props = coll["proposal"]
self.assertEqual(len(props), 1)
self.assertEqual(props[0]["status"], "proposed", out)
root = self.repo_with(tmp, [
("aaa", "Aaa", {"extra_hike": self.EST + self.ENDS}),
("bbb", "Bbb", {"extra_hike": 'season = "June"\nmonths = [6]\n'
'season_basis = "source"\n' + self.ENDS}),
])
self.assertEqual(E.estimates(root), ["aaa"])
def test_a_season_with_a_method_is_not_a_sourced_season(self):
tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, tmp, True)
root = self.repo_with(tmp, [
("aaa", "Aaa", {"extra_hike": 'season = "June"\nmonths = [6]\nseason_basis = "sources"\n'
'season_method = "The pages differ. Confidence: low."\n' + self.ENDS}),
])
E._PHRASES.clear()
self.assertEqual(E._phrases(root), {})
class SeasonKindTest(unittest.TestCase):
+290
View File
@@ -0,0 +1,290 @@
"""Tests for tools/season_judge.py: the packets reviewers judge a season from,
the blind scoring, and the proposals that write the judged seasons.
Run from the repository root:
python3 -m unittest discover tools/tests
"""
import json
import os
import shutil
import sys
import tempfile
import unittest
sys.dont_write_bytecode = True
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
import season_judge as J # noqa: E402
import season_climate as C # noqa: E402
import season_model as M # noqa: E402
import estimate_season as E # noqa: E402
import test_refresh as TR # noqa: E402
import refresh as R # noqa: E402
import trail_history # noqa: E402
import validate as V # noqa: E402
class CleanTest(unittest.TestCase):
def test_a_sentence_that_bears_on_timing_is_removed_and_logged(self):
kept, removed = J.clean("A pretty ridge walk. Best in July and August. It has huts.")
self.assertEqual(kept, "A pretty ridge walk. It has huts.")
self.assertEqual(removed, ["Best in July and August."])
def test_season_words_count_but_place_names_do_not(self):
self.assertTrue(J.mentions_season("Snowmelt comes late."))
self.assertTrue(J.mentions_season("Open year-round."))
self.assertFalse(J.mentions_season("It crosses May Lake and Summer Lake."))
self.assertFalse(J.mentions_season("It passes the Hot Springs."))
def test_nothing_left_is_said_so(self):
kept, _ = J.clean("Best in summer.")
self.assertEqual(kept, "")
self.assertIn("none left", J.shown(kept, "x"))
self.assertEqual(J.shown("", None), "(not on file)")
class SplitTest(unittest.TestCase):
def test_parts_are_disjoint_balanced_and_repeatable(self):
src = [f"s{i}" for i in range(10)]
oth = [f"o{i}" for i in range(7)]
parts = J.split_parts(src, oth, 3, 1)
flat = [t for p in parts for t in p]
self.assertEqual(sorted(flat), sorted(src + oth))
for part in parts:
self.assertIn(sum(t in src for t in part), (3, 4))
self.assertIn(sum(t in oth for t in part), (2, 3))
self.assertEqual(parts, J.split_parts(src, oth, 3, 1))
self.assertNotEqual(parts, J.split_parts(src, oth, 3, 2))
def med(base):
return ([base] * 12, [base] * 12)
class ComparablesTest(unittest.TestCase):
def test_a_trail_is_never_compared_with_its_own_part_or_itself(self):
part_of = {"me": 0, "mate": 0, "a": 1, "b": 2}
meds = {k: med(10.0) for k in part_of}
centres = {k: (45.0, -110.0) for k in part_of}
got = J.comparables("me", part_of, ["mate", "a", "b", "me"], meds, centres, k=10)
self.assertEqual(sorted(got), ["a", "b"])
def test_the_nearest_in_climate_and_place_come_first(self):
part_of = {"me": 0, "near": 1, "far": 1, "cold": 2}
meds = {"me": med(10.0), "near": med(10.0), "far": med(10.0), "cold": med(-5.0)}
centres = {"me": (45.0, -110.0), "near": (45.5, -110.0),
"far": (30.0, -80.0), "cold": (45.1, -110.0)}
got = J.comparables("me", part_of, ["near", "far", "cold"], meds, centres, k=2)
self.assertEqual(got, ["near", "far"])
def info(kind="track"):
pts = [C.PointNormals(lat=44.0 + i, lon=-110.0, elev_m=1000.0 * (i + 1),
tmax_c=tuple(float(v) for v in range(12)))
for i in range(4)]
return {"points": pts, "kind": kind, "profile": (3500.0, 800.0)}
class PacketTest(unittest.TestCase):
def rec(self):
return {"id": "tt", "name": "Test Trail", "country": "US", "regions": ["WY"],
"length_km": 160.9344, "kind": "trail",
"hike": {"summary": "A ridge walk. Best in July. It has huts.",
"start": "Trailhead.", "terrain": ["alpine"], "high_point_m": 3000,
"days": [8, 10]}}
def text(self, **kw):
args = dict(rec=self.rec(), info=info(), machine=[6, 7, 8],
comparables=[], pages=None, precip=None)
args.update(kw)
return J.packet_text(**args)
def test_the_packet_states_the_trail_in_miles_and_feet_and_hides_timing(self):
t = self.text()
self.assertIn("length: 100 miles", t)
self.assertIn("high point: 9843 ft", t)
self.assertIn("A ridge walk. It has huts.", t)
self.assertNotIn("Best in July", t)
def test_it_never_carries_the_trails_own_season(self):
rec = self.rec()
rec["hike"].update(season="July to September", months=[7, 8, 9], season_basis="primary")
t = self.text(rec=rec)
self.assertNotIn("July to September", t)
def test_it_gives_the_machine_estimate_and_the_climate(self):
t = self.text()
self.assertIn("Months: 6, 7, 8 (June, July, August)", t)
self.assertIn("| Jan |", t)
self.assertIn("Precipitation is not available", t)
def test_precipitation_is_given_when_supplied(self):
t = self.text(precip=[[25.4] * 12] * 4)
self.assertIn("precip in", t)
self.assertNotIn("Precipitation is not available", t)
def test_what_pages_say_appears_only_when_given(self):
self.assertNotIn("What pages say", self.text())
self.assertIn("Months each gives: A 5-10", self.text(pages="Publisher(s): A\nMonths each gives: A 5-10"))
def test_a_trail_with_no_climate_says_so(self):
t = self.text(info=dict(info(), points=[]), machine=[])
self.assertIn("No climate data is available", t)
self.assertIn("Months: none", t)
class AnswersTest(unittest.TestCase):
def write(self, text):
d = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, d, True)
path = os.path.join(d, "a.tsv")
with open(path, "w") as f:
f.write(text)
return path
def test_good_rows_are_read_and_bad_rows_are_named(self):
path = self.write(
"aa\t7,8,9\tJuly to September\thigh\tSnow melts.\n"
"bb\t\tNone\thigh\tEmpty.\n"
"cc\t13\tX\thigh\tOut of range.\n"
"dd\t6\tJune\tsure\tBad confidence.\n"
"aa\t6\tJune\tlow\tDuplicate.\n"
"zz\t6\tJune\tlow\tUnknown.\n"
"ee\t5,6\tMay to June\tmedium\tFine.\n")
ans, problems = J.read_answers(path, ["aa", "bb", "cc", "dd", "ee"])
self.assertEqual(sorted(ans), ["aa", "ee"])
self.assertEqual(ans["aa"], ([7, 8, 9], "July to September", "high", "Snow melts."))
self.assertEqual(len(problems), 5)
class ScoreTest(unittest.TestCase):
def test_matches_are_counted_within_a_month_at_each_end_by_confidence(self):
truth = {"a": [6, 7, 8, 9], "b": [6, 7, 8, 9], "c": [6, 7, 8, 9], "d": [1, 2, 3]}
ans = {"a": ([6, 7, 8, 9], "", "high", ""), # exact
"b": ([7, 8, 9, 10], "", "medium", ""), # one month at each end
"c": ([1, 2, 3], "", "low", ""), # wrong
"x": ([1], "", "high", "")} # not a sourced trail: ignored
got = J.score(ans, truth)
self.assertEqual(got["tested"], 4)
self.assertEqual(got["matched"], 2)
self.assertEqual(got["by_confidence"]["high"], {"tested": 1, "matched": 1})
self.assertEqual(got["by_confidence"]["medium"], {"tested": 1, "matched": 1})
self.assertEqual(got["by_confidence"]["low"], {"tested": 1, "matched": 0})
# d was never answered: it counts as tested and missed
self.assertEqual(got["unanswered"], 1)
def test_the_figure_file_round_trips_and_shares_are_computed(self):
figures = {"tested": 148, "matched": 114, "unanswered": 0,
"by_confidence": {"high": {"tested": 52, "matched": 48},
"medium": {"tested": 76, "matched": 55},
"low": {"tested": 20, "matched": 11}}}
d = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, d, True)
path = os.path.join(d, "t.json")
J.write_blind_test(path, figures, "2026-11-20")
got = J.load_blind_test(path)
self.assertEqual(got["date"], "2026-11-20")
self.assertEqual(got["tested"], 148)
self.assertEqual(got["matched"], 114)
self.assertEqual(got["share"], 0.77)
self.assertEqual(got["by_confidence"]["high"]["share"], 0.92)
self.assertEqual(got["by_confidence"]["low"]["share"], 0.55)
def test_a_loaded_file_must_add_up(self):
bad = {"date": "2026-11-20", "tested": 10, "matched": 5, "share": 0.5,
"by_confidence": {"high": {"tested": 4, "matched": 5, "share": 1.0},
"medium": {"tested": 3, "matched": 1, "share": 0.33},
"low": {"tested": 3, "matched": 1, "share": 0.33}}}
self.assertTrue(J.check_blind_test(bad))
class CommittedFilesTest(unittest.TestCase):
def test_the_committed_blind_test_adds_up_and_passes_the_bar(self):
got = J.load_blind_test(os.path.join(J.ROOT, "tools", "season_blind_test.json"))
self.assertEqual(J.check_blind_test(got), [])
self.assertGreaterEqual(got["share"], E.BAR["within1_min"])
def test_every_judged_row_is_well_formed_and_matches_its_record(self):
ids = R.trail_ids(J.ROOT)
ans, problems = J.read_answers(os.path.join(J.ROOT, "tools", "season_judged.tsv"), ids)
self.assertEqual(problems, [])
self.assertEqual(sorted(ans), sorted(ids))
for tid in ids:
hike = R.load_toml(os.path.join(J.ROOT, tid, "trail.toml")).get("hike") or {}
if hike.get("season_basis") == "estimate" or hike.get("season_method"):
months, _phrase, conf, _why = ans[tid]
self.assertEqual(months, hike["months"], tid)
self.assertEqual(J.season.confidence_of(hike["season_method"]), conf, tid)
class ProposalsTest(unittest.TestCase):
HIKE = 'start_lonlat = [-110.0, 43.0]\nend_lonlat = [-110.0, 43.2]\n'
def setUp(self):
self.tmp = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.tmp, True)
self.root = TR.make_repo(self.tmp, trails=[
("aaa", "Aaa", {"extra_hike": self.HIKE}),
("bbb", "Bbb", {"extra_hike": self.HIKE}),
("ccc", "Ccc", {"extra_hike": 'season = "June"\nmonths = [6]\nseason_basis = "source"\n' + self.HIKE}),
])
self.stage = os.path.join(self.tmp, "stage")
os.makedirs(self.stage)
self.answers = os.path.join(self.tmp, "judged.tsv")
with open(self.answers, "w") as f:
f.write("aaa\t7,8,9\tJuly to September\thigh\tSnow melts late.\n"
"bbb\t5,6,7,8,9,10\tMay to October\tmedium\tThe pages differ.\n"
"ccc\t1,2\tJanuary to February\tlow\tNot used: it has a season.\n")
self.pages = os.path.join(self.tmp, "pages.json")
with open(self.pages, "w") as f:
json.dump({"bbb": {
"why": "The pages differ: one says May to September and one says June to October. "
"It was set by judgement from both and from the climate.",
"sources": [
{"url": "https://a.example/bbb", "publisher": "Guide A", "quote": "Season: May to September"},
{"url": "https://b.example/bbb", "publisher": "Guide B", "quote": "Season: June to October"}]}}, f)
def test_only_trails_with_no_season_are_staged(self):
n = J.proposals(self.root, self.answers, self.pages, self.stage)
self.assertEqual(n, 2)
def test_collect_and_apply_write_valid_records_with_history(self):
J.proposals(self.root, self.answers, self.pages, self.stage)
code, out = TR.main(self.root, "--dir", self.stage, "collect")
self.assertEqual(code, 0, out)
coll = R.load_toml(os.path.join(self.stage, "collected.toml"))
self.assertEqual({p["status"] for p in coll["proposal"]}, {"proposed"}, out)
with open(os.path.join(self.stage, "owner.csv"), "w") as f:
f.write("pid,decision,digest\n")
for p in coll["proposal"]:
f.write(f"{p['pid']},accept,{p['digest']}\n")
code, out = TR.main(self.root, "--dir", self.stage, "collect")
self.assertEqual(code, 0, out)
code, out = TR.main(self.root, "--dir", self.stage, "apply")
self.assertEqual(code, 0, out)
a = R.load_toml(os.path.join(self.root, "aaa", "trail.toml"))
h = a["hike"]
self.assertEqual((h["season"], h["months"], h["season_basis"]),
("July to September", [7, 8, 9], "estimate"))
self.assertTrue(h["season_method"].endswith("Confidence: high."))
self.assertIn("Snow melts late.", h["season_method"])
self.assertEqual(len(h["source"]), 3) # two the record had, and the climate data
self.assertEqual(h["source"][-1]["facts"], ["season", "months"])
self.assertIn("chelsa", h["source"][-1]["url"])
errors = []
V.check_hike("aaa", a, errors)
trail_history.check_entries("aaa", a, errors)
# (the fixture's own end-point fields are not what is under test)
self.assertEqual([e for e in errors if "lonlat" not in e], [], errors)
self.assertTrue(any("hike.season" in (e.get("fields") or []) for e in a["history"]))
b = R.load_toml(os.path.join(self.root, "bbb", "trail.toml"))["hike"]
self.assertEqual(b["season_basis"], "sources")
self.assertIn("The pages differ", b["season_method"])
self.assertEqual([s["publisher"] for s in b["source"]][-2:], ["Guide A", "Guide B"])
errors = []
V.check_hike("bbb", {"hike": b}, errors)
self.assertEqual([e for e in errors if "lonlat" not in e], [], errors)
if __name__ == "__main__":
unittest.main()